[llvm] [VPlan] Introduce VPInstruction::InsertLastLane for start value of VPFirstOrderRecurrencePHIRecipe. (PR #171590)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 10 02:19:15 PST 2025


================
@@ -1443,8 +1443,16 @@ static void simplifyRecipe(VPSingleDefRecipe *Def, VPTypeAnalysis &TypeInfo) {
     return;
   }
 
+  if (match(Def, m_VPInstruction<VPInstruction::InsertLastLane>(
+                     m_VPValue(), m_VPValue(A))))
+    if (Plan->hasScalarVFOnly())
+      return Def->replaceAllUsesWith(A);
+
   if (auto *Phi = dyn_cast<VPFirstOrderRecurrencePHIRecipe>(Def)) {
-    if (Phi->getOperand(0) == Phi->getOperand(1))
+    if (Phi->getOperand(0) == Phi->getOperand(1) ||
+        match(Phi->getOperand(0),
+              m_VPInstruction<VPInstruction::InsertLastLane>(
+                  m_VPValue(), m_Specific(Phi->getOperand(1)))))
       Phi->replaceAllUsesWith(Phi->getOperand(0));
     return;
   }
----------------
Mel-Chen wrote:

I'm wondering if it might be better to postpone the conversion to executePlan time. The simplification process would be a bit simpler that way.
@fhahn What do you think?

https://github.com/llvm/llvm-project/pull/171590


More information about the llvm-commits mailing list