[llvm] [LoopVectorizer] Allow partial reductions to be made in predicated loops (PR #124268)

James Chesterman via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 05:13:07 PST 2025


================
@@ -9698,6 +9698,11 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
     // beginning of the dedicated latch block.
     auto *OrigExitingVPV = PhiR->getBackedgeValue();
     auto *NewExitingVPV = PhiR->getBackedgeValue();
+    // Don't add selects here for partial reductions because the phi and partial
+    // reduction values have less vector elements than Cond. But, each operand
+    // in a select instruction needs to have the same number of vector elements,
+    // so the compiler would crash. Instead, a select, with the active lane
+    // mask, is applied to the inputs to the partial reduction.
----------------
JamesChesterman wrote:

Done

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


More information about the llvm-commits mailing list