diff options
| author | Duncan Sands <baldrick@free.fr> | 2011-10-28 18:30:05 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2011-10-28 18:30:05 +0000 |
| commit | 985ba6386d0ebd579063a4eec7c02c0ad1f0ec2d (patch) | |
| tree | 47ef0bd08fa3239759ca2a72e5673a9994b6690d /llvm/lib/Analysis | |
| parent | 57fe0e2e7e8adbbe8193769b9b62a6c17586cead (diff) | |
| download | bcm5719-llvm-985ba6386d0ebd579063a4eec7c02c0ad1f0ec2d.tar.gz bcm5719-llvm-985ba6386d0ebd579063a4eec7c02c0ad1f0ec2d.zip | |
A shift of a power of two is a power of two or zero.
For completeness - not spotted in the wild.
llvm-svn: 143211
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 90757f9798d..9f7b5b501a3 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -769,6 +769,12 @@ bool llvm::isPowerOfTwo(Value *V, const TargetData *TD, bool OrZero, if (Depth++ == MaxDepth) return false; + Value *X = 0, *Y = 0; + // A shift of a power of two is a power of two or zero. + if (OrZero && (match(V, m_Shl(m_Value(X), m_Value())) || + match(V, m_Shr(m_Value(X), m_Value())))) + return isPowerOfTwo(X, TD, /*OrZero*/true, Depth); + if (ZExtInst *ZI = dyn_cast<ZExtInst>(V)) return isPowerOfTwo(ZI->getOperand(0), TD, OrZero, Depth); @@ -776,7 +782,6 @@ bool llvm::isPowerOfTwo(Value *V, const TargetData *TD, bool OrZero, return isPowerOfTwo(SI->getTrueValue(), TD, OrZero, Depth) && isPowerOfTwo(SI->getFalseValue(), TD, OrZero, Depth); - Value *X = 0, *Y = 0; if (OrZero && match(V, m_And(m_Value(X), m_Value(Y)))) { // A power of two and'd with anything is a power of two or zero. if (isPowerOfTwo(X, TD, /*OrZero*/true, Depth) || |

