[llvm] [LoopVectorizer] Add support for chaining partial reductions (PR #120272)

Nicholas Guy via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 06:41:04 PST 2025


================
@@ -2453,13 +2453,16 @@ class VPPartialReductionRecipe : public VPSingleDefRecipe {
       : VPSingleDefRecipe(VPDef::VPPartialReductionSC,
                           ArrayRef<VPValue *>({Op0, Op1}), ReductionInst),
         Opcode(Opcode) {
-    assert(isa<VPReductionPHIRecipe>(getOperand(1)->getDefiningRecipe()) &&
+    auto *DefiningRecipe = getOperand(1)->getDefiningRecipe();
+    assert((isa<VPReductionPHIRecipe>(DefiningRecipe) ||
+            isa<VPPartialReductionRecipe>(DefiningRecipe)) &&
            "Unexpected operand order for partial reduction recipe");
   }
   ~VPPartialReductionRecipe() override = default;
 
   VPPartialReductionRecipe *clone() override {
-    return new VPPartialReductionRecipe(Opcode, getOperand(0), getOperand(1));
+    return new VPPartialReductionRecipe(Opcode, getOperand(0), getOperand(1),
+                                        getUnderlyingInstr());
----------------
NickGuy-Arm wrote:

As it's not required by the other changes here (I think it was at one point). I'll still remove it from here and re-add it in a separate PR before things start depending on it

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


More information about the llvm-commits mailing list