[llvm] [LoopVectorizer] Allow partial reductions to be made in predicated loops (PR #124268)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 02:26:05 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.
----------------
SamTebbs33 wrote:
This could probably be more concise, as something like "The output of a partial reductions has fewer lanes than the VF so don't emit a select, as its operands would have differing numbers of lanes. A partial reduction masks its input instead."
https://github.com/llvm/llvm-project/pull/124268
More information about the llvm-commits
mailing list