[llvm] [LV] Use VPReductionRecipe for partial reductions (PR #147513)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 09:03:42 PST 2025


================
@@ -2798,6 +2679,21 @@ InstructionCost VPReductionRecipe::computeCost(ElementCount VF,
   std::optional<FastMathFlags> OptionalFMF =
       ElementTy->isFloatingPointTy() ? std::make_optional(FMFs) : std::nullopt;
 
+  if (isPartialReduction()) {
+    InstructionCost CondCost = 0;
+    if (isConditional()) {
+      CmpInst::Predicate Pred = CmpInst::BAD_ICMP_PREDICATE;
+      auto *CondTy = Ctx.Types.inferScalarType(getCondOp());
----------------
sdesmalen-arm wrote:

Should this be:
```
auto *CondTy = cast<VectorType>(toVectorTy(Ctx.Types.inferScalartype(getCondOp()), VF));
```
?

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


More information about the llvm-commits mailing list