[llvm] [DAG] Added m_AnyBinOp and m_c_AnyBinOp in SDPatternMatch.h (PR #86435)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 1 09:45:29 PDT 2024


================
@@ -457,6 +457,54 @@ struct BinaryOpc_match {
   }
 };
 
+template <typename LHS_t, typename RHS_t, bool Commutable = false>
+struct AnyBinaryOp_match {
+  LHS_t LHS;
+  RHS_t RHS;
+  unsigned Opcode;
+
+  AnyBinaryOp_match(const LHS_t &L, const RHS_t &R) : LHS(L), RHS(R) {}
+
+  AnyBinaryOp_match(unsigned Opc, const LHS_t &L, const RHS_t &R)
+      : LHS(L), RHS(R), Opcode(Opc) {}
+
+  template <typename MatchContext>
+  bool match(const MatchContext &Ctx, SDValue N) {
+    assert(Ctx.getTLI() && "TargetLowering is required for this pattern");
+    if ((Ctx.getTLI()->isBinOp(N->getOpcode()) ||
+         (Commutable && Ctx.getTLI()->isCommutativeBinOp(N->getOpcode())))) {
----------------
mshockwave wrote:

```suggestion
    if (Ctx.getTLI()->isBinOp(N->getOpcode()) ||
         (Commutable && Ctx.getTLI()->isCommutativeBinOp(N->getOpcode()))) {
```
Redundant paren

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


More information about the llvm-commits mailing list