Skip to content

Commit cf78995

Browse files
[NFC][LoopVectorizer] Remove VF.isScalable() assertion from collectInstsToScalarize and getInstructionCost
This patch removes the assertion when VF is scalable and replaces getKnownMinValue() by getFixedValue(), so it still guards the code against scalable vector types. The assertions were used to guarantee that getknownMinValue were not used for scalable vectors. Differential Revision: https://reviews.llvm.org/D106359
1 parent 0977f31 commit cf78995

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6824,20 +6824,18 @@ int LoopVectorizationCostModel::computePredInstDiscount(
68246824
// the instruction as if it wasn't if-converted and instead remained in the
68256825
// predicated block. We will scale this cost by block probability after
68266826
// computing the scalarization overhead.
6827-
assert(!VF.isScalable() && "scalable vectors not yet supported.");
68286827
InstructionCost ScalarCost =
6829-
VF.getKnownMinValue() *
6828+
VF.getFixedValue() *
68306829
getInstructionCost(I, ElementCount::getFixed(1)).first;
68316830

68326831
// Compute the scalarization overhead of needed insertelement instructions
68336832
// and phi nodes.
68346833
if (isScalarWithPredication(I) && !I->getType()->isVoidTy()) {
68356834
ScalarCost += TTI.getScalarizationOverhead(
68366835
cast<VectorType>(ToVectorTy(I->getType(), VF)),
6837-
APInt::getAllOnesValue(VF.getKnownMinValue()), true, false);
6838-
assert(!VF.isScalable() && "scalable vectors not yet supported.");
6836+
APInt::getAllOnesValue(VF.getFixedValue()), true, false);
68396837
ScalarCost +=
6840-
VF.getKnownMinValue() *
6838+
VF.getFixedValue() *
68416839
TTI.getCFInstrCost(Instruction::PHI, TTI::TCK_RecipThroughput);
68426840
}
68436841

@@ -6852,10 +6850,9 @@ int LoopVectorizationCostModel::computePredInstDiscount(
68526850
if (canBeScalarized(J))
68536851
Worklist.push_back(J);
68546852
else if (needsExtract(J, VF)) {
6855-
assert(!VF.isScalable() && "scalable vectors not yet supported.");
68566853
ScalarCost += TTI.getScalarizationOverhead(
68576854
cast<VectorType>(ToVectorTy(J->getType(), VF)),
6858-
APInt::getAllOnesValue(VF.getKnownMinValue()), false, true);
6855+
APInt::getAllOnesValue(VF.getFixedValue()), false, true);
68596856
}
68606857
}
68616858

@@ -7550,14 +7547,13 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, ElementCount VF,
75507547

75517548
if (ScalarPredicatedBB) {
75527549
// Return cost for branches around scalarized and predicated blocks.
7553-
assert(!VF.isScalable() && "scalable vectors not yet supported.");
75547550
auto *Vec_i1Ty =
75557551
VectorType::get(IntegerType::getInt1Ty(RetTy->getContext()), VF);
7556-
return (TTI.getScalarizationOverhead(
7557-
Vec_i1Ty, APInt::getAllOnesValue(VF.getKnownMinValue()),
7558-
false, true) +
7559-
(TTI.getCFInstrCost(Instruction::Br, CostKind) *
7560-
VF.getKnownMinValue()));
7552+
return (
7553+
TTI.getScalarizationOverhead(
7554+
Vec_i1Ty, APInt::getAllOnesValue(VF.getFixedValue()), false,
7555+
true) +
7556+
(TTI.getCFInstrCost(Instruction::Br, CostKind) * VF.getFixedValue()));
75617557
} else if (I->getParent() == TheLoop->getLoopLatch() || VF.isScalar())
75627558
// The back-edge branch will remain, as will all scalar branches.
75637559
return TTI.getCFInstrCost(Instruction::Br, CostKind);

0 commit comments

Comments
 (0)