[llvm] [LV] Reduce register usage for scaled reductions (PR #133090)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 9 08:38:16 PDT 2025
================
@@ -4874,6 +4874,20 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
}
}
+/// Get the VF scaling factor applied to the recipe's output, if the recipe has
+/// one.
+static unsigned getVFScaleFactor(VPRecipeBase *R) {
+ 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();
+ return ScaleFactor;
+ }
----------------
sdesmalen-arm wrote:
Am I missing something, or can this just be:
```suggestion
if (auto *RR = dyn_cast<VPReductionPHIRecipe>(R))
return RR->getVFScaleFactor();
if (auto *RR =dyn_cast<VPPartialReductionRecipe>(R))
return RR->getVFScaleFactor();
```
?
https://github.com/llvm/llvm-project/pull/133090
More information about the llvm-commits
mailing list