[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)
commitdcc78ec386d4d83293da2ecd23ca85395655e3a7
tree022b5430555d7efe7625d86cf589484c883ef24b
parent6ad63744b337892c119c5dbefcb85eef8fc22415
[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.

llvm-svn: 231483
llvm/include/llvm/IR/ConstantRange.h
llvm/lib/IR/ConstantRange.cpp
llvm/unittests/IR/ConstantRangeTest.cpp