[ConstantRange] Teach multiply to be cleverer about signed ranges.
authorJames Molloy <james.molloy@arm.com>
Fri, 6 Mar 2015 15:50:47 +0000 (15:50 +0000)
committerJames Molloy <james.molloy@arm.com>
Fri, 6 Mar 2015 15:50:47 +0000 (15:50 +0000)
commit4e022da51e7e9645928e505630e78a22ea8d2aad
tree89948dd244c9a2036818021d65bd1d202ccc5dd1
parent653997ebc2faf89d9af220279347c3f913c03ec9
[ConstantRange] Teach multiply to be cleverer about signed ranges.

Multiplication is not dependent on signedness, so just treating
all input ranges as unsigned is not incorrect. However it will cause
overly pessimistic ranges (such as full-set) when used with signed
negative values.

Teach multiply to try to interpret its inputs as both signed and
unsigned, and then to take the most specific (smallest population)
as its result.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231483 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/ConstantRange.h
lib/IR/ConstantRange.cpp
unittests/IR/ConstantRangeTest.cpp