Skip to content

Commit 00edad1

Browse files
committed
[SLP][NFC]Check for equal opcode preliminary to meet weak strict order
requirement, NFC. This change does not affect functionality, just fixes the assertions in some standard c++ library implementations.
1 parent 137f785 commit 00edad1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15730,6 +15730,8 @@ static bool compareCmp(Value *V, Value *V2, TargetLibraryInfo &TLI,
1573015730
assert(isValidElementType(V->getType()) &&
1573115731
isValidElementType(V2->getType()) &&
1573215732
"Expected valid element types only.");
15733+
if (V == V2)
15734+
return IsCompatibility;
1573315735
auto *CI1 = cast<CmpInst>(V);
1573415736
auto *CI2 = cast<CmpInst>(V2);
1573515737
if (CI1->getOperand(0)->getType()->getTypeID() <
@@ -15754,6 +15756,8 @@ static bool compareCmp(Value *V, Value *V2, TargetLibraryInfo &TLI,
1575415756
for (int I = 0, E = CI1->getNumOperands(); I < E; ++I) {
1575515757
auto *Op1 = CI1->getOperand(CI1Preds ? I : E - I - 1);
1575615758
auto *Op2 = CI2->getOperand(CI2Preds ? I : E - I - 1);
15759+
if (Op1 == Op2)
15760+
continue;
1575715761
if (Op1->getValueID() < Op2->getValueID())
1575815762
return !IsCompatibility;
1575915763
if (Op1->getValueID() > Op2->getValueID())
@@ -15780,7 +15784,10 @@ static bool compareCmp(Value *V, Value *V2, TargetLibraryInfo &TLI,
1578015784
InstructionsState S = getSameOpcode({I1, I2}, TLI);
1578115785
if (S.getOpcode() && (IsCompatibility || !S.isAltShuffle()))
1578215786
continue;
15783-
return !IsCompatibility && I1->getOpcode() < I2->getOpcode();
15787+
if (IsCompatibility)
15788+
return false;
15789+
if (I1->getOpcode() != I2->getOpcode())
15790+
return I1->getOpcode() < I2->getOpcode();
1578415791
}
1578515792
}
1578615793
return IsCompatibility;

0 commit comments

Comments
 (0)