InstSimplify: Fix a bug when INT_MIN is in a sdiv
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 4 Jul 2014 00:23:39 +0000 (00:23 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 4 Jul 2014 00:23:39 +0000 (00:23 +0000)
commit00428878bb65cbf2c5620bccda19706cec24c6b9
treeff6651ab2fc10fb1001810ea24b576793f5dc7ae
parent5c58257d39c5061189269e33b49c90cc1e1e57d3
InstSimplify: Fix a bug when INT_MIN is in a sdiv

When INT_MIN is the numerator in a sdiv, we would not properly handle
overflow when calculating the bounds of possible values; abs(INT_MIN) is
not a meaningful number.

Instead, check and handle INT_MIN by reasoning that the largest value is
INT_MIN/-2 and the smallest value is INT_MIN.

This fixes PR20199.

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