summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-05-22 15:41:53 +0000
committerSanjay Patel <spatel@rotateright.com>2016-05-22 15:41:53 +0000
commite2e89ef93604fefb1a145d26e12f43da7a5f24d2 (patch)
tree6a066966e9d915b590c26985b6c8c689851d175c /llvm/lib/Analysis/ValueTracking.cpp
parent4f3fe5b1a6c0bc555d39d4847a9573c1060e045a (diff)
downloadbcm5719-llvm-e2e89ef93604fefb1a145d26e12f43da7a5f24d2.tar.gz
bcm5719-llvm-e2e89ef93604fefb1a145d26e12f43da7a5f24d2.zip
[ValueTracking, InstCombine] extend isKnownToBeAPowerOfTwo() to handle vector splat constants
We could try harder to handle non-splat vector constants too, but that seems much rarer to me. Note that the div test isn't resolved because there's a check for isIntegerTy() guarding that transform. Differential Revision: http://reviews.llvm.org/D20497 llvm-svn: 270369
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-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 19fef59e1f3..38853478c06 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1500,9 +1500,10 @@ bool isKnownToBeAPowerOfTwo(Value *V, bool OrZero, unsigned Depth,
if (Constant *C = dyn_cast<Constant>(V)) {
if (C->isNullValue())
return OrZero;
- if (ConstantInt *CI = dyn_cast<ConstantInt>(C))
- return CI->getValue().isPowerOf2();
- // TODO: Handle vector constants.
+
+ const APInt *ConstIntOrConstSplatInt;
+ if (match(C, m_APInt(ConstIntOrConstSplatInt)))
+ return ConstIntOrConstSplatInt->isPowerOf2();
}
// 1 << X is clearly a power of two if the one is not shifted off the end. If
OpenPOWER on IntegriCloud