[llvm] [VPlan] Narrow truncates of an induction plus a constant offset (PR #226035)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 27 13:54:32 PDT 2026
================
@@ -929,7 +932,26 @@ getOptimizableIVOf(VPValue *VPV, PredicatedScalarEvolution &PSE) {
}
llvm_unreachable("should have been covered by switch above");
};
- return IsWideIVInc() ? WideIV : nullptr;
+ if (!PostIncStart)
+ return IsWideIVInc() ? WideIV : nullptr;
+
+ // start + C + i * step stays affine for any constant C, including the step,
+ // 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;
+
+ const APInt *StartC;
+ if (!match(WideIV->getStartValue(), m_APInt(StartC)))
+ return nullptr;
+ *PostIncStart =
----------------
artagnon wrote:
```suggestion
PostIncStart =
```
https://github.com/llvm/llvm-project/pull/226035
More information about the llvm-commits
mailing list