Skip to content

Commit 36e4a7e

Browse files
committed
[SLP]Fix PR79321: SLPVectorizer's PHICompare doesn't provide a strict
weak ordering. Try to make PHICompare to meat strict weak ordering criteria.
1 parent 62a384c commit 36e4a7e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15953,6 +15953,8 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
1595315953
for (int I = 0, E = Opcodes1.size(); I < E; ++I) {
1595415954
// Undefs are compatible with any other value.
1595515955
if (isa<UndefValue>(Opcodes1[I]) || isa<UndefValue>(Opcodes2[I])) {
15956+
if (isa<UndefValue>(Opcodes1[I]) && isa<UndefValue>(Opcodes2[I]))
15957+
continue;
1595615958
if (isa<Instruction>(Opcodes1[I]))
1595715959
return true;
1595815960
if (isa<Instruction>(Opcodes2[I]))
@@ -15961,9 +15963,11 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
1596115963
return true;
1596215964
if (isa<Constant>(Opcodes2[I]) && !isa<UndefValue>(Opcodes2[I]))
1596315965
return false;
15964-
if (isa<UndefValue>(Opcodes1[I]) && isa<UndefValue>(Opcodes2[I]))
15965-
continue;
15966-
return isa<UndefValue>(Opcodes2[I]);
15966+
if (isa<UndefValue>(Opcodes1[I]) && !isa<UndefValue>(Opcodes2[I]))
15967+
return false;
15968+
if (!isa<UndefValue>(Opcodes1[I]) && isa<UndefValue>(Opcodes2[I]))
15969+
return true;
15970+
continue;
1596715971
}
1596815972
if (auto *I1 = dyn_cast<Instruction>(Opcodes1[I]))
1596915973
if (auto *I2 = dyn_cast<Instruction>(Opcodes2[I])) {
@@ -15984,14 +15988,14 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
1598415988
return I1->getOpcode() < I2->getOpcode();
1598515989
}
1598615990
if (isa<Constant>(Opcodes1[I]) && isa<Constant>(Opcodes2[I]))
15987-
return Opcodes1[I]->getValueID() < Opcodes2[I]->getValueID();
15988-
if (isa<Instruction>(Opcodes1[I]))
15991+
continue;
15992+
if (isa<Instruction>(Opcodes1[I]) && !isa<Instruction>(Opcodes2[I]))
1598915993
return true;
15990-
if (isa<Instruction>(Opcodes2[I]))
15994+
if (!isa<Instruction>(Opcodes1[I]) && isa<Instruction>(Opcodes2[I]))
1599115995
return false;
15992-
if (isa<Constant>(Opcodes1[I]))
15996+
if (isa<Constant>(Opcodes1[I]) && !isa<Constant>(Opcodes2[I]))
1599315997
return true;
15994-
if (isa<Constant>(Opcodes2[I]))
15998+
if (!isa<Constant>(Opcodes1[I]) && isa<Constant>(Opcodes2[I]))
1599515999
return false;
1599616000
if (Opcodes1[I]->getValueID() < Opcodes2[I]->getValueID())
1599716001
return true;

0 commit comments

Comments
 (0)