Skip to content

Commit 5075623

Browse files
fhahnmahesh-attarde
authored andcommitted
[LV] Set extend kinds together with ExtOpTypes (NFC).
Set extend kinds together with ExtOpTypes. This will make it easier to adjust the extend kind handling.
1 parent 36d3d1d commit 5075623

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8046,11 +8046,11 @@ bool VPRecipeBuilder::getScaledReductions(
80468046
BinaryOperator *ExtendUser = dyn_cast<BinaryOperator>(Op);
80478047
std::optional<unsigned> BinOpc;
80488048
Type *ExtOpTypes[2] = {nullptr};
8049+
TTI::PartialReductionExtendKind ExtKinds[2] = {TTI::PR_None};
80498050

8050-
auto CollectExtInfo = [this, &Exts,
8051-
&ExtOpTypes](SmallVectorImpl<Value *> &Ops) -> bool {
8052-
unsigned I = 0;
8053-
for (Value *OpI : Ops) {
8051+
auto CollectExtInfo = [this, &Exts, &ExtOpTypes,
8052+
&ExtKinds](SmallVectorImpl<Value *> &Ops) -> bool {
8053+
for (const auto &[I, OpI] : enumerate(Ops)) {
80548054
Value *ExtOp;
80558055
if (!match(OpI, m_ZExtOrSExt(m_Value(ExtOp))))
80568056
return false;
@@ -8061,7 +8061,7 @@ bool VPRecipeBuilder::getScaledReductions(
80618061
return false;
80628062

80638063
ExtOpTypes[I] = ExtOp->getType();
8064-
I++;
8064+
ExtKinds[I] = TTI::getPartialReductionExtendKind(Exts[I]);
80658065
}
80668066
return true;
80678067
};
@@ -8090,10 +8090,6 @@ bool VPRecipeBuilder::getScaledReductions(
80908090
} else
80918091
return false;
80928092

8093-
TTI::PartialReductionExtendKind OpAExtend =
8094-
TTI::getPartialReductionExtendKind(Exts[0]);
8095-
TTI::PartialReductionExtendKind OpBExtend =
8096-
Exts[1] ? TTI::getPartialReductionExtendKind(Exts[1]) : TTI::PR_None;
80978093
PartialReductionChain Chain(RdxExitInstr, Exts[0], Exts[1], ExtendUser);
80988094

80998095
TypeSize PHISize = PHI->getType()->getPrimitiveSizeInBits();
@@ -8106,7 +8102,8 @@ bool VPRecipeBuilder::getScaledReductions(
81068102
[&](ElementCount VF) {
81078103
InstructionCost Cost = TTI->getPartialReductionCost(
81088104
Update->getOpcode(), ExtOpTypes[0], ExtOpTypes[1],
8109-
PHI->getType(), VF, OpAExtend, OpBExtend, BinOpc, CM.CostKind);
8105+
PHI->getType(), VF, ExtKinds[0], ExtKinds[1], BinOpc,
8106+
CM.CostKind);
81108107
return Cost.isValid();
81118108
},
81128109
Range)) {

0 commit comments

Comments
 (0)