aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2020-11-30 15:43:39 +0000
committerFlorian Hahn <flo@fhahn.com>2020-12-01 14:23:21 +0000
commit7a4f1d59b82e5defbce4498347291e6ef9f1281c (patch)
tree0581cae755b50b093c93ec65c594312835f8389d /llvm/lib/Transforms/Scalar
parent4431c212a0a08c2b6552e6a476a15b142d7c6bb9 (diff)
downloadllvm-project-7a4f1d59b82e5defbce4498347291e6ef9f1281c.tar.gz
[ConstraintElimination] Decompose GEP %ptr, ZEXT(SHL()).
Add support to decompose a GEP with a ZEXT(SHL()) operand.
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/ConstraintElimination.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 5c806b6e5486..8e7480bea284 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -64,6 +64,11 @@ static SmallVector<std::pair<int64_t, Value *>, 4> decompose(Value *V) {
return {{0, nullptr},
{1, GEP->getPointerOperand()},
{pow(2, CI->getSExtValue()), Op0}};
+ if (match(GEP->getOperand(GEP->getNumOperands() - 1),
+ m_ZExt(m_NUWShl(m_Value(Op0), m_ConstantInt(CI)))))
+ return {{0, nullptr},
+ {1, GEP->getPointerOperand()},
+ {pow(2, CI->getSExtValue()), Op0}};
return {{0, nullptr},
{1, GEP->getPointerOperand()},