[llvm] [VPlan] Optimize FindLast of (binop %IV, live-in) by sinking. (PR #183911)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 11:52:17 PDT 2026
================
@@ -5786,16 +5853,37 @@ void VPlanTransforms::optimizeFindIVReductions(VPlan &Plan,
BackedgeVal,
match_fn(m_VPInstruction<VPInstruction::ComputeReductionResult>())));
+ // If IV is an expression to sink, create a new select that tracks the
+ // underlying IV directly and update the backedge value.
+ auto *OrigSelectR = FindLastSelect->getDefiningRecipe();
+ if (SinkExpressionIV) {
+ VPBuilder LoopBuilder(OrigSelectR);
+ auto DL = OrigSelectR->getDebugLoc();
+ VPValue *Cond = OrigSelectR->getOperand(0);
+ if (OrigSelectR->getOperand(1) == PhiR)
+ FindLastSelect =
+ LoopBuilder.createSelect(Cond, PhiR, SinkExpressionIV, DL);
+ else
----------------
fhahn wrote:
added thanks
https://github.com/llvm/llvm-project/pull/183911
More information about the llvm-commits
mailing list