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)
commit312646b71e415bb543ea1c143cca5b9009364b0d
treee1b265fba2fbf52072a831fa2cd9949e8242229e
parente0a56a0cf6cb89cdd6bbdee2c3a5030dd042b982
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212981 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/compare.ll