[llvm] [LoopVectorizer] Allow partial reductions to be made in predicated loops (PR #124268)
James Chesterman via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 06:27:47 PST 2025
================
@@ -8904,6 +8897,12 @@ VPRecipeBuilder::tryToCreatePartialReduction(Instruction *Reduction,
isa<VPPartialReductionRecipe>(BinOpRecipe))
std::swap(BinOp, Accumulator);
+ VPValue *Mask = getBlockInMask(Reduction->getParent());
+ if (Mask) {
+ VPValue *Zero =
+ Plan.getOrAddLiveIn(ConstantInt::get(Reduction->getType(), 0));
+ BinOp = Builder.createSelect(Mask, BinOp, Zero, Reduction->getDebugLoc());
+ }
----------------
JamesChesterman wrote:
Done.
The assert wasn't getting hit for the non-predicated tests, as they would return a mask of 0 rather than no mask at all. But I've added the extra condition for more safety. It needed to be a slightly different function inside the condition as this one was not working as required.
https://github.com/llvm/llvm-project/pull/124268
More information about the llvm-commits
mailing list