[llvm-branch-commits] [llvm] [LV] Use VPReductionRecipe for partial reductions (PR #147513)

Gaƫtan Bossu via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 20 03:33:19 PDT 2025


================
@@ -2661,23 +2666,32 @@ class LLVM_ABI_FOR_TEST VPInterleaveEVLRecipe final : public VPInterleaveBase {
   }
 };
 
-/// A recipe to represent inloop reduction operations, performing a reduction on
-/// a vector operand into a scalar value, and adding the result to a chain.
-/// The Operands are {ChainOp, VecOp, [Condition]}.
+/// A recipe to represent inloop, ordered or partial reduction operations. It
+/// performs a reduction on a vector operand into a scalar (vector in the case
+/// of a partial reduction) value, and adds the result to a chain. The Operands
+/// are {ChainOp, VecOp, [Condition]}.
 class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
   /// The recurrence kind for the reduction in question.
   RecurKind RdxKind;
   bool IsOrdered;
   /// Whether the reduction is conditional.
   bool IsConditional = false;
+  /// The scaling factor, relative to the VF, that this recipe's output is
+  /// divided by.
+  /// For outer-loop reductions this is equal to 1.
----------------
gbossu wrote:

I think I'm getting a bit confused. In which case do we get a `VPReductionRecipe` for "outer-loop" reductions? I thought it was only used when the reduction result was computed inside the loop (sometimes partially). For "outer-loop" reductions, don't we "widen everything" and compute the reduction result in the middle block?

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


More information about the llvm-branch-commits mailing list