[llvm] [LV] Create block in mask up-front if needed. (PR #76635)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 1 14:00:59 PST 2024
================
@@ -8758,13 +8762,20 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
DFS.perform(LI);
VPBasicBlock *VPBB = HeaderVPBB;
+ bool NeedsMasks = CM.foldTailByMasking() ||
+ any_of(OrigLoop->blocks(), [this](BasicBlock *BB) {
+ return Legal->blockNeedsPredication(BB);
+ });
for (BasicBlock *BB : make_range(DFS.beginRPO(), DFS.endRPO())) {
// Relevant instructions from basic block BB will be grouped into VPRecipe
// ingredients and fill a new VPBasicBlock.
if (VPBB != HeaderVPBB)
VPBB->setName(BB->getName());
Builder.setInsertPoint(VPBB);
+ if (VPBB != HeaderVPBB && NeedsMasks)
+ RecipeBuilder.createBlockInMask(BB, *Plan);
+
----------------
ayalz wrote:
Fold createHeaderMask() and remove its comment above
```suggestion
if (NeedsMasks) {
if (VPBB == HeaderVPBB)
RecipeBuilder.createHeaderMask(*Plan);
else
RecipeBuilder.createBlockInMask(BB, *Plan);
}
```
https://github.com/llvm/llvm-project/pull/76635
More information about the llvm-commits
mailing list