[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 15:17:04 PST 2024


================
@@ -7575,6 +7575,11 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
         }
         continue;
       }
+      // A partial reduction is very differently costed compared to its
+      // underlying add instruction that the legacy cost model sees, so consider
+      // it an additional simplification.
+      if (dyn_cast<VPPartialReductionRecipe>(&R))
+        continue;
----------------
fhahn wrote:

```suggestion
      // The VPlan-based cost model is more accurate for partial reduction and comparing against the legacy cost isn't desirable.
      if (dyn_cast<VPPartialReductionRecipe>(&R))
        return true;
```

Can directly return true I think when we encounter a partial reduction?

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


More information about the llvm-commits mailing list