[SLP][NFC]Make isFirstInsertElement a weak strict ordering comparator.
authorAlexey Bataev <a.bataev@outlook.com>
Tue, 24 May 2022 13:01:17 +0000 (06:01 -0700)
committerAlexey Bataev <a.bataev@outlook.com>
Tue, 24 May 2022 13:02:42 +0000 (06:02 -0700)
To be used correctly in a sort-like function, isFirstInsertElement
function must follow weak strict ordering rule, i.e.
isFirstInsertElement(IE1, IE1) should return false.

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

index beb54dc..a8de0bf 100644 (file)
@@ -6659,6 +6659,8 @@ static bool areTwoInsertFromSameBuildVector(InsertElementInst *VU,
 /// buildvector sequence.
 static bool isFirstInsertElement(const InsertElementInst *IE1,
                                  const InsertElementInst *IE2) {
+  if (IE1 == IE2)
+    return false;
   const auto *I1 = IE1;
   const auto *I2 = IE2;
   const InsertElementInst *PrevI1;