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

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 17 04:38:48 PST 2025


================
@@ -1085,6 +1294,29 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
     return InstructionsState::invalid();
   }
 
+  if (IsBinOp) {
+    auto FindOp =
+        [&](ArrayRef<std::unique_ptr<InterchangeableInstruction>> Candidate) {
+          for (const std::unique_ptr<InterchangeableInstruction> &I :
+               Candidate) {
+            unsigned InterchangeableInstructionOpcode =
+                I->getInterchangeableInstructionOpcode();
+            for (Value *V : VL) {
+              if (isa<PoisonValue>(V))
+                continue;
+              if (cast<Instruction>(V)->getOpcode() ==
+                  InterchangeableInstructionOpcode)
+                return cast<Instruction>(V);
----------------
alexey-bataev wrote:

Avoid double cast

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


More information about the llvm-commits mailing list