aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2018-02-06 18:39:23 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2018-02-06 18:39:23 +0000
commit9f2ae7e2d122db53b26828b3e9a4a49a1d1a77d6 (patch)
tree643d7e3e4bfbb49703db6bee1331edf1b1befaa3 /llvm/lib/Analysis/ValueTracking.cpp
parent332351d9b98f993e4d0eb83a98ff4d4bb619b541 (diff)
downloadllvm-9f2ae7e2d122db53b26828b3e9a4a49a1d1a77d6.zip
llvm-9f2ae7e2d122db53b26828b3e9a4a49a1d1a77d6.tar.gz
llvm-9f2ae7e2d122db53b26828b3e9a4a49a1d1a77d6.tar.bz2
[InstCombine][ValueTracking] Match non-uniform constant power-of-two vectors
Generalize existing constant matching to work with non-uniform constant vectors as well. Differential Revision: https://reviews.llvm.org/D42818 llvm-svn: 324369
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 14a26b5..5a8bd4b 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1646,14 +1646,11 @@ bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth,
const Query &Q) {
assert(Depth <= MaxDepth && "Limit Search Depth");
- if (const Constant *C = dyn_cast<Constant>(V)) {
- if (C->isNullValue())
- return OrZero;
-
- const APInt *ConstIntOrConstSplatInt;
- if (match(C, m_APInt(ConstIntOrConstSplatInt)))
- return ConstIntOrConstSplatInt->isPowerOf2();
- }
+ // Attempt to match against constants.
+ if (OrZero && match(V, m_Power2OrZero()))
+ return true;
+ if (match(V, m_Power2()))
+ return true;
// 1 << X is clearly a power of two if the one is not shifted off the end. If
// it is shifted off the end then the result is undefined.