Skip to content

Commit 50f35ae

Browse files
committed
[LV] Improve code using [[maybe_unused]]
1 parent 8639b36 commit 50f35ae

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6675,24 +6675,23 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
66756675
RetTy = IntegerType::get(RetTy->getContext(), MinBWs[I]);
66766676
auto *SE = PSE.getSE();
66776677

6678-
auto HasSingleCopyAfterVectorization = [this](Instruction *I,
6679-
ElementCount VF) -> bool {
6680-
if (VF.isScalar())
6681-
return true;
6682-
6683-
auto Scalarized = InstsToScalarize.find(VF);
6684-
assert(Scalarized != InstsToScalarize.end() &&
6685-
"VF not yet analyzed for scalarization profitability");
6686-
return !Scalarized->second.count(I) &&
6687-
llvm::all_of(I->users(), [&](User *U) {
6688-
auto *UI = cast<Instruction>(U);
6689-
return !Scalarized->second.count(UI);
6690-
});
6691-
};
6692-
(void)HasSingleCopyAfterVectorization;
6693-
66946678
Type *VectorTy;
66956679
if (isScalarAfterVectorization(I, VF)) {
6680+
[[maybe_unused]] auto HasSingleCopyAfterVectorization =
6681+
[this](Instruction *I, ElementCount VF) -> bool {
6682+
if (VF.isScalar())
6683+
return true;
6684+
6685+
auto Scalarized = InstsToScalarize.find(VF);
6686+
assert(Scalarized != InstsToScalarize.end() &&
6687+
"VF not yet analyzed for scalarization profitability");
6688+
return !Scalarized->second.count(I) &&
6689+
llvm::all_of(I->users(), [&](User *U) {
6690+
auto *UI = cast<Instruction>(U);
6691+
return !Scalarized->second.count(UI);
6692+
});
6693+
};
6694+
66966695
// With the exception of GEPs and PHIs, after scalarization there should
66976696
// only be one copy of the instruction generated in the loop. This is
66986697
// because the VF is either 1, or any instructions that need scalarizing
@@ -6956,8 +6955,8 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
69566955
Type *ValTy = I->getOperand(0)->getType();
69576956

69586957
if (canTruncateToMinimalBitwidth(I, VF)) {
6959-
Instruction *Op0AsInstruction = dyn_cast<Instruction>(I->getOperand(0));
6960-
(void)Op0AsInstruction;
6958+
[[maybe_unused]] Instruction *Op0AsInstruction =
6959+
dyn_cast<Instruction>(I->getOperand(0));
69616960
assert((!canTruncateToMinimalBitwidth(Op0AsInstruction, VF) ||
69626961
MinBWs[I] == MinBWs[Op0AsInstruction]) &&
69636962
"if both the operand and the compare are marked for "
@@ -7895,7 +7894,7 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
78957894
RdxDesc.getRecurrenceKind())) {
78967895
using namespace llvm::PatternMatch;
78977896
Value *Cmp, *OrigResumeV, *CmpOp;
7898-
bool IsExpectedPattern =
7897+
[[maybe_unused]] bool IsExpectedPattern =
78997898
match(MainResumeValue, m_Select(m_OneUse(m_Value(Cmp)),
79007899
m_Specific(RdxDesc.getSentinelValue()),
79017900
m_Value(OrigResumeV))) &&
@@ -7906,7 +7905,6 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
79067905
(CmpOp == RdxDesc.getRecurrenceStartValue() &&
79077906
isGuaranteedNotToBeUndefOrPoison(CmpOp))));
79087907
assert(IsExpectedPattern && "Unexpected reduction resume pattern");
7909-
(void)IsExpectedPattern;
79107908
MainResumeValue = OrigResumeV;
79117909
}
79127910
PHINode *MainResumePhi = cast<PHINode>(MainResumeValue);

0 commit comments

Comments
 (0)