summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-03-21 21:40:32 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-03-21 21:40:32 +0000
commitf0469af63e10f8a78f717d943610593ca260413a (patch)
tree6fc87e4f08a2bd087183528d101091e8a3296951 /llvm
parente351f2006192617494f3bfba72066fd820af90f6 (diff)
downloadbcm5719-llvm-f0469af63e10f8a78f717d943610593ca260413a.tar.gz
bcm5719-llvm-f0469af63e10f8a78f717d943610593ca260413a.zip
Fix INT_MIN gotcha pointed out by Eli Friedman.
llvm-svn: 128028
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index c36f68c2aeb..0f4bfb7b0d9 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -725,9 +725,10 @@ bool llvm::isPowerOfTwo(Value *V, const TargetData *TD, unsigned Depth) {
isPowerOfTwo(SI->getFalseValue(), TD, Depth);
// An exact divide or right shift can only shift off zero bits, so the result
- // is a power of two only if the first operand is a power of two.
- if (match(V, m_Shr(m_Value(), m_Value())) ||
- match(V, m_IDiv(m_Value(), m_Value()))) {
+ // is a power of two only if the first operand is a power of two and not
+ // copying a sign bit (sdiv int_min, 2).
+ if (match(V, m_LShr(m_Value(), m_Value())) ||
+ match(V, m_UDiv(m_Value(), m_Value()))) {
BinaryOperator *BO = cast<BinaryOperator>(V);
if (BO->isExact())
return isPowerOfTwo(BO->getOperand(0), TD, Depth);
OpenPOWER on IntegriCloud