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

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 08:47:36 PST 2025


================
@@ -2370,6 +2370,23 @@ struct VPFirstOrderRecurrencePHIRecipe : public VPHeaderPHIRecipe {
 #endif
 };
 
+// Possible variants of a reduction.
+
+// This reduction is ordered and in-loop.
+struct RdxOrderedInLoop {};
+// This reduction is in-loop.
+struct RdxInLoop {};
+// This reduction isn't partial, ordered or in-loop.
+struct RdxNormal {};
----------------
gbossu wrote:

I did spend some time double checking because this contradicted my understanding of "normal" reductions.

The corresponding recipe for the `%update` will just be a `WIDEN` of the scalar `add`, not a `WidenReduction` recipe. I also checked the code, and I think the only place where we create a `RdxNormal` reduction is alongside a ScaleFactor > 1`. So AFAIU, `RdxNormal` can be renamed to `RdxPartial`. Which is a form of inloop reduction where the elements are reduced to `VF / ScaleFactor` in the loop, and to a scalar in the middle block.

For other styles,I do agree with your comment, thanks for writing all the details :)

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


More information about the llvm-commits mailing list