[llvm] [VPlan] Add ReductionStartVector VPInstruction. (PR #142290)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 4 06:21:16 PDT 2025


================
@@ -1153,6 +1153,16 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
       return;
     }
   }
+  // Simplify redundant ReductionStartVector recipes after unrolling.
+  VPValue *StartV;
+  if (match(Def, m_VPInstruction<VPInstruction::ReductionStartVector>(
+                     m_VPValue(StartV), m_VPValue(), m_VPValue()))) {
+    Def->replaceUsesWithIf(StartV, [Def](const VPUser &U, unsigned Idx) {
+      auto *PhiR = dyn_cast<VPReductionPHIRecipe>(&U);
+      return PhiR && Def == PhiR->getOperand(Idx) && PhiR->isInLoop();
----------------
Mel-Chen wrote:

Why need `Def == PhiR->getOperand(Idx)`?

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


More information about the llvm-commits mailing list