InstSimplify: Correct sdiv x / -1
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 14 Jul 2014 20:38:45 +0000 (20:38 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 14 Jul 2014 20:38:45 +0000 (20:38 +0000)
commitaf9180fd0409431ce1a05f69212483a4d1c5c6c0
tree0842046da2261b17b8164e041de740207d550b94
parent2474e816cc0242d44dae2e7f8f7836f7b3c9adc9
InstSimplify: Correct sdiv x / -1

Determining the bounds of x/ -1 would start off with us dividing it by
INT_MIN.  Suffice to say, this would not work very well.

Instead, handle it upfront by checking for -1 and mapping it to the
range: [INT_MIN + 1, INT_MAX.  This means that the result of our
division can be any value other than INT_MIN.

llvm-svn: 212981
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/compare.ll