diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-02-06 18:39:23 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-02-06 18:39:23 +0000 |
commit | 9f2ae7e2d122db53b26828b3e9a4a49a1d1a77d6 (patch) | |
tree | 643d7e3e4bfbb49703db6bee1331edf1b1befaa3 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 332351d9b98f993e4d0eb83a98ff4d4bb619b541 (diff) | |
download | llvm-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.cpp | 13 |
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. |