[llvm] [VPlan] Impl VPlan-based pattern match for ExtendedRed and MulAccRed (PR #113903)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 07:14:41 PDT 2025


================
@@ -2548,6 +2630,172 @@ void VPlanTransforms::handleUncountableEarlyExit(
   LatchExitingBranch->eraseFromParent();
 }
 
+/// This function tries convert extended in-loop reductions to
+/// VPExtendedReductionRecipe and clamp the \p Range if it is beneficial and
+/// valid. The created recipe must be lowered to concrete
+/// recipes before execution.
+static VPExtendedReductionRecipe *
+tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx,
+                                     VFRange &Range) {
+  using namespace VPlanPatternMatch;
+
+  Type *RedTy = Ctx.Types.inferScalarType(Red);
+  VPValue *VecOp = Red->getVecOp();
+
+  // Test if using extended-reduction is profitable and clamp the range.
----------------
sdesmalen-arm wrote:

nit:
```suggestion
  // Clamp the range if using extended-reduction is profitable.
```

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


More information about the llvm-commits mailing list