[PATCH] D99736: [MIPatternMatch]: Add matchers for binary instructions

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 1 15:34:08 PDT 2021


paquette added a comment.

Testcase?



================
Comment at: llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h:259
 
+// Helper for (commutable) binary generic MI. Doesn't check opcode.
+template <typename LHS_P, typename RHS_P, bool Commutable = false>
----------------
Commutative?


================
Comment at: llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h:269
+    MachineInstr *TmpMI;
+    if (mi_match(Op, MRI, m_MInstr(TmpMI))) {
+      if (TmpMI->getNumOperands() == 3) {
----------------
Maybe a bit simpler to change this to the negative case?

Also may want to check that there is only one def.


================
Comment at: llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h:280
+    return (L.match(MRI, Op0) && R.match(MRI, Op1)) ||
+           (Commutable && R.match(MRI, Op0) && L.match(MRI, Op1));
+  }
----------------



================
Comment at: llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h:323
+inline BinaryOpWithOpcode_match<LHS, RHS, true>
+m_CommutableBinOp(unsigned Opcode, const LHS &L, const RHS &R) {
+  return BinaryOpWithOpcode_match<LHS, RHS, true>(Opcode, L, R);
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99736/new/

https://reviews.llvm.org/D99736



More information about the llvm-commits mailing list