Skip to content

Commit 6a42fb8

Browse files
authored
[LV] Clarify code in isPredicatedInst (NFC) (#134251)
1 parent 6f93c06 commit 6a42fb8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,11 +3236,9 @@ bool LoopVectorizationCostModel::isScalarWithPredication(
32363236

32373237
// TODO: Fold into LoopVectorizationLegality::isMaskRequired.
32383238
bool LoopVectorizationCostModel::isPredicatedInst(Instruction *I) const {
3239-
// If predication is not needed, avoid it.
32403239
// TODO: We can use the loop-preheader as context point here and get
32413240
// context sensitive reasoning for isSafeToSpeculativelyExecute.
3242-
if (!blockNeedsPredicationForAnyReason(I->getParent()) ||
3243-
isSafeToSpeculativelyExecute(I) ||
3241+
if (isSafeToSpeculativelyExecute(I) ||
32443242
(isa<LoadInst, StoreInst, CallInst>(I) && !Legal->isMaskRequired(I)) ||
32453243
isa<BranchInst, SwitchInst, PHINode, AllocaInst>(I))
32463244
return false;
@@ -3250,6 +3248,10 @@ bool LoopVectorizationCostModel::isPredicatedInst(Instruction *I) const {
32503248
if (Legal->blockNeedsPredication(I->getParent()))
32513249
return true;
32523250

3251+
// If we're not folding the tail by masking, predication is unnecessary.
3252+
if (!foldTailByMasking())
3253+
return false;
3254+
32533255
// All that remain are instructions with side-effects originally executed in
32543256
// the loop unconditionally, but now execute under a tail-fold mask (only)
32553257
// having at least one active lane (the first). If the side-effects of the

0 commit comments

Comments
 (0)