[llvm] [LV] Add support for absolute difference partial reductions (PR #188043)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 03:07:10 PDT 2026


================
@@ -6406,10 +6445,11 @@ void VPlanTransforms::createPartialReductions(VPlan &Plan,
 
       PartialCost += LinkCost;
       RegularCost += Link.ReductionBinOp->computeCost(VF, CostCtx);
-      if (ExtendedOp.BinOp && ExtendedOp.BinOp != Link.ReductionBinOp)
-        RegularCost += ExtendedOp.BinOp->computeCost(VF, CostCtx);
-      for (VPWidenCastRecipe *Extend : ExtendedOp.CastRecipes)
-        if (Extend)
+      // If ExtendB is not none, then the "ExtendsUser" is the binary operation.
+      if (ExtendedOp.ExtendB.Kind != ExtendKind::PR_None)
+        RegularCost += ExtendedOp.ExtendsUser->computeCost(VF, CostCtx);
+      for (VPValue *Op : ExtendedOp.ExtendsUser->operands())
+        if (auto *Extend = dyn_cast<VPWidenCastRecipe>(Op))
----------------
MacDue wrote:

I think it could be, but that's best left to a follow-up as this PR is primarily intending to allow the user of wider vectors with absolute differences.

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


More information about the llvm-commits mailing list