diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-07-09 18:11:10 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-07-09 18:11:10 +0000 |
commit | ab6ceab8a65e26667a437a4ace7fe93a3772c6ff (patch) | |
tree | abed41e4b29796b9ab0694e5f35dd30cd0ffc9c6 /lib/Analysis | |
parent | 29b741942807bc4c0441d98f1330b70446794b88 (diff) | |
download | external_llvm-ab6ceab8a65e26667a437a4ace7fe93a3772c6ff.zip external_llvm-ab6ceab8a65e26667a437a4ace7fe93a3772c6ff.tar.gz external_llvm-ab6ceab8a65e26667a437a4ace7fe93a3772c6ff.tar.bz2 |
ValueTracking: Fix bugs in isKnownToBeAPowerOfTwo
(add nsw x, (and x, y)) isn't a power of two if x is zero, it's zero
(add nsw x, (xor x, y)) isn't a power of two if y has bits set that aren't set in x
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/ValueTracking.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index b3693b3..1b20a25 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -861,16 +861,14 @@ bool llvm::isKnownToBeAPowerOfTwo(Value *V, bool OrZero, unsigned Depth) { // Adding a power of two to the same power of two is a power of two or // zero. if (BinaryOperator *XBO = dyn_cast<BinaryOperator>(X)) - if (XBO->getOpcode() == Instruction::And || - XBO->getOpcode() == Instruction::Xor) + if (XBO->getOpcode() == Instruction::And) if (XBO->getOperand(0) == Y || XBO->getOperand(1) == Y) - if (isKnownToBeAPowerOfTwo(Y, /*OrZero*/true, Depth)) + if (isKnownToBeAPowerOfTwo(Y, OrZero, Depth)) return true; if (BinaryOperator *YBO = dyn_cast<BinaryOperator>(Y)) - if (YBO->getOpcode() == Instruction::And || - YBO->getOpcode() == Instruction::Xor) + if (YBO->getOpcode() == Instruction::And) if (YBO->getOperand(0) == X || YBO->getOperand(1) == X) - if (isKnownToBeAPowerOfTwo(X, /*OrZero*/true, Depth)) + if (isKnownToBeAPowerOfTwo(X, OrZero, Depth)) return true; } |