Skip to content

Commit 0d6cb0a

Browse files
committed
[SLP]Fix strict weak ordering criterion in comparators
Fixes #121019
1 parent 8dbb337 commit 0d6cb0a

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -5635,8 +5635,11 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
56355635
auto PHICompare = [&](unsigned I1, unsigned I2) {
56365636
Value *V1 = TE.Scalars[I1];
56375637
Value *V2 = TE.Scalars[I2];
5638-
if (V1 == V2 || (V1->getNumUses() == 0 && V2->getNumUses() == 0) ||
5639-
isa<PoisonValue>(V1) || isa<PoisonValue>(V2))
5638+
if (V1 == V2 || (V1->getNumUses() == 0 && V2->getNumUses() == 0))
5639+
return false;
5640+
if (isa<PoisonValue>(V1))
5641+
return true;
5642+
if (isa<PoisonValue>(V2))
56405643
return false;
56415644
if (V1->getNumUses() < V2->getNumUses())
56425645
return true;
@@ -21733,9 +21736,6 @@ bool SLPVectorizerPass::vectorizeStoreChains(BoUpSLP &R) {
2173321736
V2->getValueOperand()->getType()->getScalarSizeInBits())
2173421737
return false;
2173521738
// UndefValues are compatible with all other values.
21736-
if (isa<UndefValue>(V->getValueOperand()) ||
21737-
isa<UndefValue>(V2->getValueOperand()))
21738-
return false;
2173921739
if (auto *I1 = dyn_cast<Instruction>(V->getValueOperand()))
2174021740
if (auto *I2 = dyn_cast<Instruction>(V2->getValueOperand())) {
2174121741
DomTreeNodeBase<llvm::BasicBlock> *NodeI1 =
@@ -21749,14 +21749,8 @@ bool SLPVectorizerPass::vectorizeStoreChains(BoUpSLP &R) {
2174921749
"Different nodes should have different DFS numbers");
2175021750
if (NodeI1 != NodeI2)
2175121751
return NodeI1->getDFSNumIn() < NodeI2->getDFSNumIn();
21752-
InstructionsState S = getSameOpcode({I1, I2}, *TLI);
21753-
if (S.getOpcode())
21754-
return false;
2175521752
return I1->getOpcode() < I2->getOpcode();
2175621753
}
21757-
if (isa<Constant>(V->getValueOperand()) &&
21758-
isa<Constant>(V2->getValueOperand()))
21759-
return false;
2176021754
return V->getValueOperand()->getValueID() <
2176121755
V2->getValueOperand()->getValueID();
2176221756
};

0 commit comments

Comments
 (0)