[llvm] [VPlan] Narrow truncates of an induction plus a constant offset (PR #226035)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 00:09:33 PDT 2026
================
@@ -929,7 +953,26 @@ getOptimizableIVOf(VPValue *VPV, PredicatedScalarEvolution &PSE) {
}
llvm_unreachable("should have been covered by switch above");
};
- return IsWideIVInc() ? WideIV : nullptr;
+ if (IsWideIVInc())
+ return {WideIV, WideIV->getStartValue()};
+
+ // Look through a constant offset from the induction. The offset need not be
+ // the induction step, as start + C + i * step stays affine for any constant
+ // C, so it can be folded into the start value.
+ const APInt *C;
+ APInt Offset;
+ if (match(VPV, m_c_Add(m_Specific(WideIV), m_APInt(C))))
+ Offset = *C;
+ else if (match(VPV, m_Sub(m_Specific(WideIV), m_APInt(C))))
+ Offset = -*C;
+ else
+ return {nullptr, nullptr};
+
+ if (Offset.isZero())
+ return {nullptr, nullptr};
----------------
artagnon wrote:
Hm, wouldn't this always be folded by simplifyRecipe? Unreachable?
https://github.com/llvm/llvm-project/pull/226035
More information about the llvm-commits
mailing list