[llvm-branch-commits] [llvm] [LoopVectorizer] Bundle partial reductions inside VPMulAccumulateReductionRecipe (PR #136173)

Sander de Smalen via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon May 12 01:42:30 PDT 2025


================
@@ -2432,12 +2437,40 @@ static void tryToCreateAbstractReductionRecipe(VPReductionRecipe *Red,
   Red->replaceAllUsesWith(AbstractR);
 }
 
+/// This function tries to create an abstract recipe from a partial reduction to
+/// hide its mul and extends from cost estimation.
+static void
+tryToCreateAbstractPartialReductionRecipe(VPPartialReductionRecipe *PRed) {
----------------
sdesmalen-arm wrote:

The way I read the code is that at the point of getting to this point in the code, it has recognised a reduction so there is a `VP[Partial]ReductionRecipe`. It then tries to analyse whether that recipe can be transformed into a `VPMulAccumulateReductionRecipe`. For `VPReductionRecipe` it will clamp the range to all the VFs that can be turned into a `VPMulAccumulateReductionRecipe`, but for `VPPartialReductionRecipe` it doesn't do that. I don't see why for partial reductions we'd do something different.

In fact, why wouldn't the `tryToMatchAndCreateMulAccumulateReduction` code be sufficient here? Now that you've made `VPPartialReductionRecipe` a subclass of `VPReductionRecipe`, I'd expect that code to function roughly the same.

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


More information about the llvm-branch-commits mailing list