[llvm-branch-commits] [llvm] [LV] Reduce register usage for scaled reductions (PR #133090)
Sander de Smalen via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Apr 8 06:30:02 PDT 2025
================
@@ -5039,10 +5039,26 @@ calculateRegisterUsage(VPlan &Plan, ArrayRef<ElementCount> VFs,
// even in the scalar case.
RegUsage[ClassID] += 1;
} else {
+ ElementCount VF = VFs[J];
+ // The output from scaled phis and scaled reductions actually has
+ // fewer lanes than the VF.
+ if (isa<VPPartialReductionRecipe, VPReductionPHIRecipe>(R)) {
+ auto *ReductionR = dyn_cast<VPReductionPHIRecipe>(R);
+ auto *PartialReductionR = ReductionR ? nullptr : dyn_cast<VPPartialReductionRecipe>(R);
+ unsigned ScaleFactor = ReductionR ? ReductionR->getVFScaleFactor() : PartialReductionR->getVFScaleFactor();
+ VF = VF.divideCoefficientBy(ScaleFactor);
+ }
----------------
sdesmalen-arm wrote:
Maybe create a utility function that returns the scaling factor a `Recipe`, which returns `1` for any recipe other than the `VPPartialReductionRecipe/VPReductionPHIRecipe`.
Also, please run clang-format on your code.
https://github.com/llvm/llvm-project/pull/133090
More information about the llvm-branch-commits
mailing list