[polly] [InstCombine] Canonicalise SextADD + GEP (PR #69581)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 26 07:51:46 PDT 2023
================
@@ -2335,6 +2335,28 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
return GetElementPtrInst::Create(GEP.getResultElementType(), NewPtr,
Idx2);
}
+
+ Value *SIdx;
+ if (auto *SextInst = dyn_cast<SExtInst>(GEP.getOperand(1))) {
+ if (auto *AddInst = dyn_cast<BinaryOperator>(SextInst->getOperand(0))) {
+ if (match(GEP.getOperand(1), m_OneUse(m_SExt(m_Value(SIdx)))) &&
+ match(SextInst->getOperand(0),
+ m_OneUse(m_Add(m_Value(Idx1), m_Value(Idx2)))) &&
+ hasNoSignedWrap(*AddInst)) {
----------------
nikic wrote:
Should do something like `if (match(GEP.getOperand(1), m_OneUse(m_SExt(m_OneUse(m_NSWAdd(m_Value(Idx1), m_Value(Idx2))))))` here.
https://github.com/llvm/llvm-project/pull/69581
More information about the llvm-commits
mailing list