diff options
author | Florian Hahn <flo@fhahn.com> | 2020-11-30 15:26:51 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2020-12-01 10:58:36 +0000 |
commit | efa9728a50012c9ead2b0110620e8865b36bef73 (patch) | |
tree | 69ca0c5899abefb8774071ddad0bfdd70efd4d61 /llvm/lib/Transforms/Scalar | |
parent | c3fe6ea22e963d7fa3579ecfeff5591449abf583 (diff) | |
download | llvm-project-efa9728a50012c9ead2b0110620e8865b36bef73.tar.gz |
[ConstraintElimination] Decompose GEP %ptr, SHL().
Add support the decompose a GEP with an SHL operand.
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ConstraintElimination.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp index 608ef5337842..5c806b6e5486 100644 --- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp +++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp @@ -57,6 +57,14 @@ static SmallVector<std::pair<int64_t, Value *>, 4> decompose(Value *V) { nullptr}, {1, GEP->getPointerOperand()}}; } + Value *Op0; + ConstantInt *CI; + if (match(GEP->getOperand(GEP->getNumOperands() - 1), + 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()}, {1, GEP->getOperand(GEP->getNumOperands() - 1)}}; |