[llvm] [SLP] Make getSameOpcode support interchangeable instructions. (PR #127450)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 5 11:10:01 PST 2025


================
@@ -977,14 +1248,16 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
       return InstructionsState::invalid();
     unsigned InstOpcode = I->getOpcode();
     if (IsBinOp && isa<BinaryOperator>(I)) {
-      if (InstOpcode == Opcode || InstOpcode == AltOpcode)
-        continue;
-      if (Opcode == AltOpcode && isValidForAlternation(InstOpcode) &&
-          isValidForAlternation(Opcode)) {
-        AltOpcode = InstOpcode;
-        AltOp = I;
+      if (InterchangeableConverter.add(I))
         continue;
+      if (!AlternateInterchangeableConverter) {
+        if (!isValidForAlternation(Opcode) ||
+            !isValidForAlternation(InstOpcode))
+          return InstructionsState::invalid();
+        AlternateInterchangeableConverter = InterchangeableBinOp(I);
       }
+      if (AlternateInterchangeableConverter->add(I))
+        continue;
----------------
alexey-bataev wrote:

Maybe move it to a separate analysis function?

https://github.com/llvm/llvm-project/pull/127450


More information about the llvm-commits mailing list