[llvm] [LV] Use SCEV to compute final value of complex induction variables (PR #195059)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 23 02:13:54 PDT 2026
================
@@ -1125,8 +1125,44 @@ optimizeLatchExitInductionUser(VPlan &Plan, VPValue *Op,
return nullptr;
}
+static VPValue *optimizeLatchExitIVUserViaSCEV(VPlan &Plan, VPValue *Op,
+ PredicatedScalarEvolution &PSE,
+ VPValue *ResumeTC,
+ const Loop *L) {
+ VPValue *Incoming;
+ if (!match(Op, m_ExtractLastLaneOfLastPart(m_VPValue(Incoming))))
+ return nullptr;
+
+ const SCEV *IncomingSCEV = vputils::getSCEVExprForVPValue(Incoming, PSE, L);
+ const SCEV *Start, *Step;
+ if (!match(IncomingSCEV, m_scev_AffineAddRec(m_SCEV(Start), m_SCEV(Step),
+ m_SpecificLoop(L))))
+ return nullptr;
+
+ auto *ExtractR = cast<VPInstruction>(Op);
+ DebugLoc DL = ExtractR->getDebugLoc();
+ VPBuilder Builder(ExtractR);
+ VPSCEVExpander Expander(Builder, *PSE.getSE(), DL);
+ VPValue *StartVPV = Expander.tryToExpand(Start);
----------------
fhahn wrote:
I don't think that's necessary unless it makes any impact end-to-end. We do not do this in other places we use the expander. In any case, the expander will soon be complete https://github.com/llvm/llvm-project/pull/210013
https://github.com/llvm/llvm-project/pull/195059
More information about the llvm-commits
mailing list