Skip to content

Commit 23245a9

Browse files
committed
[LV] Simplify code given isPredicatedInst doesn't dependent on VF any more [nfc]
1 parent 190cdf5 commit 23245a9

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,9 +1443,8 @@ class LoopVectorizationCostModel {
14431443

14441444
/// Returns true if \p I is an instruction that needs to be predicated
14451445
/// at runtime. The result is independent of the predication mechanism.
1446-
/// \p VF is the vectorization factor that will be used to vectorize \p I.
14471446
/// Superset of instructions that return true for isScalarWithPredication.
1448-
bool isPredicatedInst(Instruction *I, ElementCount VF) const;
1447+
bool isPredicatedInst(Instruction *I) const;
14491448

14501449
/// Returns true if \p I is a memory instruction with consecutive memory
14511450
/// access that can be widened.
@@ -4412,7 +4411,7 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) {
44124411

44134412
bool LoopVectorizationCostModel::isScalarWithPredication(
44144413
Instruction *I, ElementCount VF) const {
4415-
if (!isPredicatedInst(I, VF))
4414+
if (!isPredicatedInst(I))
44164415
return false;
44174416

44184417
// Do we have a non-scalar lowering for this predicated
@@ -4445,8 +4444,7 @@ bool LoopVectorizationCostModel::isScalarWithPredication(
44454444
}
44464445
}
44474446

4448-
bool LoopVectorizationCostModel::isPredicatedInst(Instruction *I,
4449-
ElementCount VF) const {
4447+
bool LoopVectorizationCostModel::isPredicatedInst(Instruction *I) const {
44504448
if (!blockNeedsPredicationForAnyReason(I->getParent()))
44514449
return false;
44524450

@@ -6087,7 +6085,7 @@ bool LoopVectorizationCostModel::useEmulatedMaskMemRefHack(Instruction *I,
60876085
// from moving "masked load/store" check from legality to cost model.
60886086
// Masked Load/Gather emulation was previously never allowed.
60896087
// Limited number of Masked Store/Scatter emulation was allowed.
6090-
assert((isPredicatedInst(I, VF)) &&
6088+
assert((isPredicatedInst(I)) &&
60916089
"Expecting a scalar emulated instruction");
60926090
return isa<LoadInst>(I) ||
60936091
(isa<StoreInst>(I) &&
@@ -6369,7 +6367,7 @@ LoopVectorizationCostModel::getMemInstScalarizationCost(Instruction *I,
63696367
// If we have a predicated load/store, it will need extra i1 extracts and
63706368
// conditional branches, but may not be executed for each vector lane. Scale
63716369
// the cost by the probability of executing the predicated block.
6372-
if (isPredicatedInst(I, VF)) {
6370+
if (isPredicatedInst(I)) {
63736371
Cost /= getReciprocalPredBlockProb();
63746372

63756373
// Add the cost of an i1 extract and a branch
@@ -7068,8 +7066,7 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, ElementCount VF,
70687066
case Instruction::SDiv:
70697067
case Instruction::URem:
70707068
case Instruction::SRem:
7071-
if (VF.isVector() && blockNeedsPredicationForAnyReason(I->getParent()) &&
7072-
!isSafeToSpeculativelyExecute(I)) {
7069+
if (VF.isVector() && isPredicatedInst(I)) {
70737070
// If we're speculating lanes, we have two options - scalarization and
70747071
// guarded widening.
70757072
if (isScalarWithPredication(I, VF)) {
@@ -8371,8 +8368,7 @@ VPRecipeBase *VPRecipeBuilder::tryToWiden(Instruction *I,
83718368
case Instruction::URem: {
83728369
// If not provably safe, use a select to form a safe divisor before widening the
83738370
// div/rem operation itself. Otherwise fall through to general handling below.
8374-
if (CM.blockNeedsPredicationForAnyReason(I->getParent()) &&
8375-
!isSafeToSpeculativelyExecute(I)) {
8371+
if (CM.isPredicatedInst(I)) {
83768372
SmallVector<VPValue *> Ops(Operands.begin(), Operands.end());
83778373
VPValue *Mask = createBlockInMask(I->getParent(), Plan);
83788374
VPValue *One =
@@ -8438,9 +8434,7 @@ VPBasicBlock *VPRecipeBuilder::handleReplication(
84388434
[&](ElementCount VF) { return CM.isUniformAfterVectorization(I, VF); },
84398435
Range);
84408436

8441-
bool IsPredicated = LoopVectorizationPlanner::getDecisionAndClampRange(
8442-
[&](ElementCount VF) { return CM.isPredicatedInst(I, VF); },
8443-
Range);
8437+
bool IsPredicated = CM.isPredicatedInst(I);
84448438

84458439
// Even if the instruction is not marked as uniform, there are certain
84468440
// intrinsic calls that can be effectively treated as such, so we check for

0 commit comments

Comments
 (0)