Skip to content

Commit 3fc277f

Browse files
authored
[SLPVectorizer] Make the insert/extractvector PHICompare a strict-weak ordering (#83571)
This was tripping off STL implementations that check for it (like libc++ with debug checking). The goal of this sort is to cluster operations on the same values so preserve that property but sort everything else based on the existing numbering.
1 parent 5bafb8d commit 3fc277f

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4395,24 +4395,16 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
43954395
if (!areTwoInsertFromSameBuildVector(
43964396
IE1, IE2,
43974397
[](InsertElementInst *II) { return II->getOperand(0); }))
4398-
return false;
4399-
std::optional<unsigned> Idx1 = getInsertIndex(IE1);
4400-
std::optional<unsigned> Idx2 = getInsertIndex(IE2);
4401-
if (Idx1 == std::nullopt || Idx2 == std::nullopt)
4402-
return false;
4403-
return *Idx1 < *Idx2;
4398+
return I1 < I2;
4399+
return getInsertIndex(IE1) < getInsertIndex(IE2);
44044400
}
44054401
if (auto *EE1 = dyn_cast<ExtractElementInst>(FirstUserOfPhi1))
44064402
if (auto *EE2 = dyn_cast<ExtractElementInst>(FirstUserOfPhi2)) {
44074403
if (EE1->getOperand(0) != EE2->getOperand(0))
4408-
return false;
4409-
std::optional<unsigned> Idx1 = getExtractIndex(EE1);
4410-
std::optional<unsigned> Idx2 = getExtractIndex(EE2);
4411-
if (Idx1 == std::nullopt || Idx2 == std::nullopt)
4412-
return false;
4413-
return *Idx1 < *Idx2;
4404+
return I1 < I2;
4405+
return getInsertIndex(EE1) < getInsertIndex(EE2);
44144406
}
4415-
return false;
4407+
return I1 < I2;
44164408
};
44174409
auto IsIdentityOrder = [](const OrdersType &Order) {
44184410
for (unsigned Idx : seq<unsigned>(0, Order.size()))

0 commit comments

Comments
 (0)