[llvm] [MacroFusion] Support commutable instructions (PR #82751)
Wang Pengcheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 18:51:44 PST 2024
================
@@ -208,8 +208,19 @@ void MacroFusionPredicatorEmitter::emitBothPredicate(Record *Predicate,
<< ").isReg() &&\n";
OS.indent(2) << " FirstMI->getOperand(" << FirstOpIdx
<< ").getReg() == SecondMI.getOperand(" << SecondOpIdx
- << ").getReg()))\n";
- OS.indent(2) << " return false;\n";
+ << ").getReg())) {\n";
+
+ OS.indent(4) << "if (!SecondMI.getDesc().isCommutable())\n";
+ OS.indent(4) << " return false;\n";
+
+ OS.indent(4) << "unsigned SrcOpIdx1 = " << SecondOpIdx
+ << ", SrcOpIdx2 = TargetInstrInfo::CommuteAnyOperandIndex;\n";
+ OS.indent(4)
+ << "if (TII.findCommutedOpIndices(SecondMI, SrcOpIdx1, SrcOpIdx2))\n";
+ OS.indent(4) << " if (!(FirstMI->getOperand(0).getReg() ==\n";
----------------
wangpc-pp wrote:
Oops, it should be a typo. It should be `FirstMI->getOperand(FirstOpIdx).getReg()`。
https://github.com/llvm/llvm-project/pull/82751
More information about the llvm-commits
mailing list