[llvm] [VPlan] Optimize resume values of IVs together with other exit values. (PR #174239)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 07:02:21 PST 2026
================
@@ -742,6 +751,30 @@ void VPlanTransforms::createHeaderPhiRecipes(
PhiR->replaceAllUsesWith(HeaderPhiR);
PhiR->eraseFromParent();
}
+
+ for (const auto &[HeaderPhiR, ScalarPhiR] : zip_equal(
+ drop_begin(HeaderVPBB->phis()), Plan.getScalarPreheader()->phis())) {
+ auto *ResumePhiR = cast<VPPhi>(&ScalarPhiR);
+ if (auto *FOR = dyn_cast<VPFirstOrderRecurrencePHIRecipe>(&HeaderPhiR)) {
+ ResumePhiR->setName("scalar.recur.init");
+ auto *ExtractLastLane = cast<VPInstruction>(ResumePhiR->getOperand(0));
+ ExtractLastLane->setName("vector.recur.extract");
+ if (ExtractLastLane->getOpcode() == VPInstruction::ExitingIVValue) {
+ // The FOR's backedge value is shared with an induction and the extract
+ // chain was replaced. Create a fresh one from the backedge value.
----------------
david-arm wrote:
Why do we need to create a fresh one? It would be good to explain the rationale here. I presume it's because multiple uses of a ExitingIVValue can prevent optimisations?
https://github.com/llvm/llvm-project/pull/174239
More information about the llvm-commits
mailing list