[llvm] [VPlan] Fix miscompile when widening induction with loop-variant step (PR #206010)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 00:55:46 PDT 2026
================
@@ -686,7 +720,10 @@ createWidenInductionRecipe(PHINode *Phi, VPPhi *PhiR, VPIRValue *Start,
// Update wide induction increments to use the same step as the corresponding
// wide induction. This enables detecting induction increments directly in
// VPlan and removes redundant splats.
- if (match(BackedgeVal, m_Add(m_Specific(PhiR), m_VPValue())))
+ bool HasVariantStepIncrement =
+ hasVariantStepIncrement(BackedgeVal, PhiR, IndDesc, PSE, OrigLoop);
----------------
fhahn wrote:
Can check the SCEV itself for invariance, something like
```suggestion
VPValue *IncStep;
if (match(BackedgeVal, m_c_Add(m_Specific(PhiR), m_VPValue(IncStep)))) {
const SCEV *IncStepSCEV = vputils::getSCEVExprForVPValue(IncStep, PSE);
HasVariantStepIncrement = isa<SCEVCouldNotCompute>(IncStepSCEV) ||
!SE.isLoopInvariant(IncStepSCEV, &OrigLoop);
}
```
https://github.com/llvm/llvm-project/pull/206010
More information about the llvm-commits
mailing list