Skip to content

Commit 6aeea12

Browse files
authored
[SLP][NFC] Simplify population of ReducedVals (#156292)
1 parent 4dbfde6 commit 6aeea12

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23833,21 +23833,20 @@ class HorizontalReduction {
2383323833
stable_sort(PossibleRedValsVect, [](const auto &P1, const auto &P2) {
2383423834
return P1.size() > P2.size();
2383523835
});
23836-
int NewIdx = -1;
23836+
bool First = true;
2383723837
for (ArrayRef<Value *> Data : PossibleRedValsVect) {
23838-
if (NewIdx < 0 ||
23839-
(!isGoodForReduction(Data) &&
23840-
(!isa<LoadInst>(Data.front()) ||
23841-
!isa<LoadInst>(ReducedVals[NewIdx].front()) ||
23842-
getUnderlyingObject(
23843-
cast<LoadInst>(Data.front())->getPointerOperand()) !=
23844-
getUnderlyingObject(
23845-
cast<LoadInst>(ReducedVals[NewIdx].front())
23846-
->getPointerOperand())))) {
23847-
NewIdx = ReducedVals.size();
23838+
if (First) {
23839+
First = false;
2384823840
ReducedVals.emplace_back();
23849-
}
23850-
ReducedVals[NewIdx].append(Data.rbegin(), Data.rend());
23841+
} else if (!isGoodForReduction(Data)) {
23842+
auto *LI = dyn_cast<LoadInst>(Data.front());
23843+
auto *LastLI = dyn_cast<LoadInst>(ReducedVals.back().front());
23844+
if (!LI || !LastLI ||
23845+
getUnderlyingObject(LI->getPointerOperand()) !=
23846+
getUnderlyingObject(LastLI->getPointerOperand()))
23847+
ReducedVals.emplace_back();
23848+
}
23849+
ReducedVals.back().append(Data.rbegin(), Data.rend());
2385123850
}
2385223851
}
2385323852
// Sort the reduced values by number of same/alternate opcode and/or pointer

0 commit comments

Comments
 (0)