[llvm] [SDPatternMatch] Remove MatchContext (PR #218372)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 03:49:18 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Luke Lau (lukel97)

<details>
<summary>Changes</summary>

This removes the match context templating now that trivial VP nodes are gone.

For the KnownBits and TLI based matchers which previously looked up the DAG in the match context, they've been changed to have the DAG explicitly passed through. This should prevent users from forgetting to pass in the DAG, and some places in X86ISelLowering.cpp were updated to now take in the DAG. So this patch isn't strictly NFC, but I couldn't find a way to exercise any codegen change in practice.


---

Patch is 63.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/218372.diff


4 Files Affected:

- (modified) llvm/include/llvm/CodeGen/SDPatternMatch.h (+172-301) 
- (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+8-8) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+3-3) 
- (modified) llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp (+169-190) 


``````````diff
diff --git a/llvm/include/llvm/CodeGen/SDPatternMatch.h b/llvm/include/llvm/CodeGen/SDPatternMatch.h
index 18fa8ef12e730..89508c31b809c 100644
--- a/llvm/include/llvm/CodeGen/SDPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/SDPatternMatch.h
@@ -28,67 +28,14 @@
 namespace llvm {
 namespace SDPatternMatch {
 
-/// MatchContext can repurpose existing patterns to behave differently under
-/// a certain context. For instance, `m_SpecificOpc(ISD::ADD)` matches plain ADD
-/// nodes in normal circumstances, but matches VP_ADD nodes under a custom
-/// VPMatchContext. This design is meant to facilitate code / pattern reusing.
-/// TODO: Remove now that we don't need to match over VP nodes.
-
-class BasicMatchContext {
-  const SelectionDAG *DAG;
-  const TargetLowering *TLI;
-
-public:
-  explicit BasicMatchContext(const SelectionDAG *DAG)
-      : DAG(DAG), TLI(DAG ? &DAG->getTargetLoweringInfo() : nullptr) {}
-
-  explicit BasicMatchContext(const TargetLowering *TLI)
-      : DAG(nullptr), TLI(TLI) {}
-
-  // A valid MatchContext has to implement the following functions.
-
-  const SelectionDAG *getDAG() const { return DAG; }
-
-  const TargetLowering *getTLI() const { return TLI; }
-
-  /// Return true if N effectively has opcode Opcode.
-  bool match(SDValue N, unsigned Opcode) const {
-    return N->getOpcode() == Opcode;
-  }
-
-  unsigned getNumOperands(SDValue N) const { return N->getNumOperands(); }
-};
-
-template <typename Pattern, typename MatchContext>
-[[nodiscard]] bool sd_context_match(SDValue N, const MatchContext &Ctx,
-                                    Pattern &&P) {
-  return P.match(Ctx, N);
-}
-
-template <typename Pattern, typename MatchContext>
-[[nodiscard]] bool sd_context_match(SDNode *N, const MatchContext &Ctx,
-                                    Pattern &&P) {
-  return sd_context_match(SDValue(N, 0), Ctx, P);
-}
-
 template <typename Pattern>
-[[nodiscard]] bool sd_match(SDNode *N, const SelectionDAG *DAG, Pattern &&P) {
-  return sd_context_match(N, BasicMatchContext(DAG), P);
-}
-
-template <typename Pattern>
-[[nodiscard]] bool sd_match(SDValue N, const SelectionDAG *DAG, Pattern &&P) {
-  return sd_context_match(N, BasicMatchContext(DAG), P);
+[[nodiscard]] bool sd_match(SDValue N, Pattern &&P) {
+  return P.match(N);
 }
 
 template <typename Pattern>
 [[nodiscard]] bool sd_match(SDNode *N, Pattern &&P) {
-  return sd_match(N, nullptr, P);
-}
-
-template <typename Pattern>
-[[nodiscard]] bool sd_match(SDValue N, Pattern &&P) {
-  return sd_match(N, nullptr, P);
+  return sd_match(SDValue(N, 0), P);
 }
 
 // === Utilities ===
@@ -99,7 +46,7 @@ struct Value_match {
 
   explicit Value_match(SDValue Match) : MatchVal(Match) {}
 
-  template <typename MatchContext> bool match(const MatchContext &, SDValue N) {
+  bool match(SDValue N) {
     if (MatchVal)
       return MatchVal == N;
     return N.getNode();
@@ -119,10 +66,7 @@ template <unsigned ResNo, typename Pattern> struct Result_match {
 
   explicit Result_match(const Pattern &P) : P(P) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    return N.getResNo() == ResNo && P.match(Ctx, N);
-  }
+  bool match(SDValue N) { return N.getResNo() == ResNo && P.match(N); }
 };
 
 /// Match only if the SDValue is a certain result at ResNo.
@@ -136,9 +80,7 @@ struct DeferredValue_match {
 
   explicit DeferredValue_match(SDValue &Match) : MatchVal(Match) {}
 
-  template <typename MatchContext> bool match(const MatchContext &, SDValue N) {
-    return N == MatchVal;
-  }
+  bool match(SDValue N) { return N == MatchVal; }
 };
 
 /// Similar to m_Specific, but the specific value to match is determined by
@@ -155,17 +97,12 @@ struct Opcode_match {
 
   explicit Opcode_match(unsigned Opc) : Opcode(Opc) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    return Ctx.match(N, Opcode);
-  }
+  bool match(SDValue N) { return N->getOpcode() == Opcode; }
 };
 
 // === Patterns combinators ===
 template <typename... Preds> struct And {
-  template <typename MatchContext> bool match(const MatchContext &, SDValue N) {
-    return true;
-  }
+  bool match(SDValue N) { return true; }
 };
 
 template <typename Pred, typename... Preds>
@@ -173,16 +110,11 @@ struct And<Pred, Preds...> : And<Preds...> {
   Pred P;
   And(const Pred &p, const Preds &...preds) : And<Preds...>(preds...), P(p) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    return P.match(Ctx, N) && And<Preds...>::match(Ctx, N);
-  }
+  bool match(SDValue N) { return P.match(N) && And<Preds...>::match(N); }
 };
 
 template <typename... Preds> struct Or {
-  template <typename MatchContext> bool match(const MatchContext &, SDValue N) {
-    return false;
-  }
+  bool match(SDValue N) { return false; }
 };
 
 template <typename Pred, typename... Preds>
@@ -190,10 +122,7 @@ struct Or<Pred, Preds...> : Or<Preds...> {
   Pred P;
   Or(const Pred &p, const Preds &...preds) : Or<Preds...>(preds...), P(p) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    return P.match(Ctx, N) || Or<Preds...>::match(Ctx, N);
-  }
+  bool match(SDValue N) { return P.match(N) || Or<Preds...>::match(N); }
 };
 
 template <typename Pred> struct Not {
@@ -201,10 +130,7 @@ template <typename Pred> struct Not {
 
   explicit Not(const Pred &P) : P(P) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    return !P.match(Ctx, N);
-  }
+  bool match(SDValue N) { return !P.match(N); }
 };
 // Explicit deduction guide.
 template <typename Pred> Not(const Pred &P) -> Not<Pred>;
@@ -241,12 +167,11 @@ template <unsigned NumUses, typename Pattern> struct NUses_match {
 
   explicit NUses_match(const Pattern &P) : P(P) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
+  bool match(SDValue N) {
     // SDNode::hasNUsesOfValue is pretty expensive when the SDNode produces
     // multiple results, hence we check the subsequent pattern here before
     // checking the number of value users.
-    return P.match(Ctx, N) && N->hasNUsesOfValue(NumUses, N.getResNo());
+    return P.match(N) && N->hasNUsesOfValue(NumUses, N.getResNo());
   }
 };
 
@@ -272,9 +197,8 @@ template <typename PredPattern> struct Value_bind {
 
   Value_bind(SDValue &N, const PredPattern &P) : BindVal(N), Pred(P) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    if (!Pred.match(Ctx, N))
+  bool match(SDValue N) {
+    if (!Pred.match(N))
       return false;
 
     BindVal = N;
@@ -298,11 +222,7 @@ template <typename Pattern, typename PredFuncT> struct TLI_pred_match {
   TLI_pred_match(const PredFuncT &Pred, const Pattern &P)
       : P(P), PredFunc(Pred) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    assert(Ctx.getTLI() && "TargetLowering is required for this pattern.");
-    return PredFunc(*Ctx.getTLI(), N) && P.match(Ctx, N);
-  }
+  bool match(SDValue N) { return PredFunc(N) && P.match(N); }
 };
 
 // Explicit deduction guide.
@@ -311,31 +231,15 @@ TLI_pred_match(const PredFuncT &Pred, const Pattern &P)
     -> TLI_pred_match<Pattern, PredFuncT>;
 
 /// Match legal SDNodes based on the information provided by TargetLowering.
-template <typename Pattern> inline auto m_LegalOp(const Pattern &P) {
-  return TLI_pred_match{[](const TargetLowering &TLI, SDValue N) {
-                          return TLI.isOperationLegal(N->getOpcode(),
-                                                      N.getValueType());
+template <typename Pattern>
+inline auto m_LegalOp(const SelectionDAG &DAG, const Pattern &P) {
+  return TLI_pred_match{[&DAG](SDValue N) {
+                          return DAG.getTargetLoweringInfo().isOperationLegal(
+                              N->getOpcode(), N.getValueType());
                         },
                         P};
 }
 
-/// Switch to a different MatchContext for subsequent patterns.
-template <typename NewMatchContext, typename Pattern> struct SwitchContext {
-  const NewMatchContext &Ctx;
-  Pattern P;
-
-  template <typename OrigMatchContext>
-  bool match(const OrigMatchContext &, SDValue N) {
-    return P.match(Ctx, N);
-  }
-};
-
-template <typename MatchContext, typename Pattern>
-inline SwitchContext<MatchContext, Pattern> m_Context(const MatchContext &Ctx,
-                                                      Pattern &&P) {
-  return SwitchContext<MatchContext, Pattern>{Ctx, std::move(P)};
-}
-
 // === Value type ===
 
 template <typename Pattern> struct ValueType_bind {
@@ -344,10 +248,9 @@ template <typename Pattern> struct ValueType_bind {
 
   explicit ValueType_bind(EVT &Bind, const Pattern &P) : BindVT(Bind), P(P) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
+  bool match(SDValue N) {
     BindVT = N.getValueType();
-    return P.match(Ctx, N);
+    return P.match(N);
   }
 };
 
@@ -368,10 +271,7 @@ template <typename Pattern, typename PredFuncT> struct ValueType_match {
   ValueType_match(const PredFuncT &Pred, const Pattern &P)
       : PredFunc(Pred), P(P) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    return PredFunc(N.getValueType()) && P.match(Ctx, N);
-  }
+  bool match(SDValue N) { return PredFunc(N.getValueType()) && P.match(N); }
 };
 
 // Explicit deduction guide.
@@ -463,20 +363,20 @@ inline auto m_ScalableVectorVT() {
 }
 
 /// Match legal ValueTypes based on the information provided by TargetLowering.
-template <typename Pattern> inline auto m_LegalType(const Pattern &P) {
-  return TLI_pred_match{[](const TargetLowering &TLI, SDValue N) {
-                          return TLI.isTypeLegal(N.getValueType());
+template <typename Pattern>
+inline auto m_LegalType(const SelectionDAG &DAG, const Pattern &P) {
+  return TLI_pred_match{[&DAG](SDValue N) {
+                          return DAG.getTargetLoweringInfo().isTypeLegal(
+                              N.getValueType());
                         },
                         P};
 }
 
 // === Generic node matching ===
 template <unsigned OpIdx, typename... OpndPreds> struct Operands_match {
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
+  bool match(SDValue N) {
     // Returns false if there are more operands than predicates;
-    // Ignores the last two operands if both the Context and the Node are VP
-    return Ctx.getNumOperands(N) == OpIdx;
+    return N->getNumOperands() == OpIdx;
   }
 };
 
@@ -488,11 +388,10 @@ struct Operands_match<OpIdx, OpndPred, OpndPreds...>
   Operands_match(const OpndPred &p, const OpndPreds &...preds)
       : Operands_match<OpIdx + 1, OpndPreds...>(preds...), P(p) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
+  bool match(SDValue N) {
     if (OpIdx < N->getNumOperands())
-      return P.match(Ctx, N->getOperand(OpIdx)) &&
-             Operands_match<OpIdx + 1, OpndPreds...>::match(Ctx, N);
+      return P.match(N->getOperand(OpIdx)) &&
+             Operands_match<OpIdx + 1, OpndPreds...>::match(N);
 
     // This is the case where there are more predicates than operands.
     return false;
@@ -511,9 +410,8 @@ template <bool ExcludeChain> struct EffectiveOperands {
   unsigned Size = 0;
   unsigned FirstIndex = 0;
 
-  template <typename MatchContext>
-  explicit EffectiveOperands(SDValue N, const MatchContext &Ctx) {
-    const unsigned TotalNumOps = Ctx.getNumOperands(N);
+  explicit EffectiveOperands(SDValue N) {
+    const unsigned TotalNumOps = N->getNumOperands();
     FirstIndex = TotalNumOps;
     for (unsigned I = 0; I < TotalNumOps; ++I) {
       // Count the number of non-chain and non-glue nodes (we ignore chain
@@ -532,9 +430,7 @@ template <> struct EffectiveOperands<false> {
   unsigned Size = 0;
   unsigned FirstIndex = 0;
 
-  template <typename MatchContext>
-  explicit EffectiveOperands(SDValue N, const MatchContext &Ctx)
-      : Size(Ctx.getNumOperands(N)) {}
+  explicit EffectiveOperands(SDValue N) : Size(N->getNumOperands()) {}
 };
 
 // === Ternary operations ===
@@ -550,16 +446,15 @@ struct TernaryOpc_match {
                    const T2_P &Op2)
       : Opcode(Opc), Op0(Op0), Op1(Op1), Op2(Op2) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    if (sd_context_match(N, Ctx, m_SpecificOpc(Opcode))) {
-      EffectiveOperands<ExcludeChain> EO(N, Ctx);
+  bool match(SDValue N) {
+    if (sd_match(N, m_SpecificOpc(Opcode))) {
+      EffectiveOperands<ExcludeChain> EO(N);
       assert(EO.Size == 3);
-      return ((Op0.match(Ctx, N->getOperand(EO.FirstIndex)) &&
-               Op1.match(Ctx, N->getOperand(EO.FirstIndex + 1))) ||
-              (Commutable && Op0.match(Ctx, N->getOperand(EO.FirstIndex + 1)) &&
-               Op1.match(Ctx, N->getOperand(EO.FirstIndex)))) &&
-             Op2.match(Ctx, N->getOperand(EO.FirstIndex + 2));
+      return ((Op0.match(N->getOperand(EO.FirstIndex)) &&
+               Op1.match(N->getOperand(EO.FirstIndex + 1))) ||
+              (Commutable && Op0.match(N->getOperand(EO.FirstIndex + 1)) &&
+               Op1.match(N->getOperand(EO.FirstIndex)))) &&
+             Op2.match(N->getOperand(EO.FirstIndex + 2));
     }
 
     return false;
@@ -659,15 +554,14 @@ struct BinaryOpc_match {
                   SDNodeFlags Flgs = SDNodeFlags())
       : Opcode(Opc), LHS(L), RHS(R), Flags(Flgs) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
-    if (sd_context_match(N, Ctx, m_SpecificOpc(Opcode))) {
-      EffectiveOperands<ExcludeChain> EO(N, Ctx);
+  bool match(SDValue N) {
+    if (sd_match(N, m_SpecificOpc(Opcode))) {
+      EffectiveOperands<ExcludeChain> EO(N);
       assert(EO.Size == 2);
-      if (!((LHS.match(Ctx, N->getOperand(EO.FirstIndex)) &&
-             RHS.match(Ctx, N->getOperand(EO.FirstIndex + 1))) ||
-            (Commutable && LHS.match(Ctx, N->getOperand(EO.FirstIndex + 1)) &&
-             RHS.match(Ctx, N->getOperand(EO.FirstIndex)))))
+      if (!((LHS.match(N->getOperand(EO.FirstIndex)) &&
+             RHS.match(N->getOperand(EO.FirstIndex + 1))) ||
+            (Commutable && LHS.match(N->getOperand(EO.FirstIndex + 1)) &&
+             RHS.match(N->getOperand(EO.FirstIndex)))))
         return false;
 
       return (Flags & N->getFlags()) == Flags;
@@ -686,11 +580,10 @@ template <typename T0, typename T1, typename T2> struct SDShuffle_match {
   SDShuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)
       : Op1(Op1), Op2(Op2), Mask(Mask) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
+  bool match(SDValue N) {
     if (auto *I = dyn_cast<ShuffleVectorSDNode>(N)) {
-      return Op1.match(Ctx, I->getOperand(0)) &&
-             Op2.match(Ctx, I->getOperand(1)) && Mask.match(I->getMask());
+      return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1)) &&
+             Mask.match(I->getMask());
     }
     return false;
   }
@@ -719,8 +612,7 @@ struct MaxMin_match {
 
   MaxMin_match(const LHS_P &L, const RHS_P &R) : LHS(L), RHS(R) {}
 
-  template <typename MatchContext>
-  bool match(const MatchContext &Ctx, SDValue N) {
+  bool match(SDValue N) {
     auto MatchMinMax = [&](SDValue L, SDValue R, SDValue TrueValue,
                            SDValue FalseValue, ISD::CondCode CC) {
       if ((TrueValue != L || FalseValue != R) &&
@@ -732,20 +624,20 @@ struct MaxMin_match {
       if (!Pred_t::match(Cond))
         return false;
 
-      return (LHS.match(Ctx, L) && RHS.match(Ctx, R)) ||
-             (Commutable && LHS.match(Ctx, R) && RHS.match(Ctx, L));
+      return (LHS.match(L) && RHS.match(R)) ||
+             (Commutable && LHS.match(R) && RHS.match(L));
     };
 
-    if (sd_context_match(N, Ctx, m_SpecificOpc(ISD::SELECT)) ||
-        sd_context_match(N, Ctx, m_SpecificOpc(ISD::VSELECT))) {
-      EffectiveOperands<ExcludeChain> EO_SELECT(N, Ctx);
+    if (sd_match(N, m_SpecificOpc(ISD::SELECT)) ||
+        sd_match(N, m_SpecificOpc(ISD::VSELECT))) {
+      EffectiveOperands<ExcludeChain> EO_SELECT(N);
       assert(EO_SELECT.Size == 3);
       SDValue Cond = N->getOperand(EO_SELECT.FirstIndex);
       SDValue TrueValue = N->getOperand(EO_SELECT.FirstIndex + 1);
       SDValue FalseValue = N->getOperand(EO_SELECT.FirstIndex + 2);
 
-      if (sd_context_match(Cond, Ctx, m_SpecificOpc(ISD::SETCC))) {
-        EffectiveOperands<ExcludeChain> EO_SETCC(Cond, Ctx);
+      if (sd_match(Cond, m_SpecificOpc(ISD::SETCC))) {
+        EffectiveOperands<ExcludeChain> EO_SETCC(Cond);
         assert(EO_SETCC.Size == 3);
         SDValue L = Cond->getOperand(EO_SETCC.FirstIndex);
         SDValue R = Cond->getOperand(EO_SETCC.FirstIndex + 1);
@@ -755,8 +647,8 @@ struct MaxMin_match {
       }
     }
 
-    if (sd_context_match(N, Ctx, m_SpecificOpc(ISD::SELECT_CC))) {
-      EffectiveOperands<ExcludeChain> EO_SELECT(N, Ctx);
+    if (sd_match(N, m_SpecificOpc(ISD::SELECT_CC))) {
+      EffectiveOperands<ExcludeChain> EO_SELECT(N);
       assert(EO_SELECT.Size == 5);
       SDValue L = N->getOperand(EO_SELECT.FirstIndex);
       SDValue R = N->getOperand(EO_SELECT.FirstIndex + 1);
@@ -904,11 +796,12 @@ inline BinaryOpc_match<LHS, RHS, true> m_SMin(const LHS &L, const RHS &R) {
 }
 
 template <typename LHS, typename RHS>
-inline auto m_SMinLike(const LHS &L, const RHS &R) {
-  return m_AnyOf(
-      m_MaxMinLike<ISD::SMIN, smin_pred_ty>(L, R),
-      m_MaxMinLike<ISD::UMIN, umin_pred_ty>(m_NonNegative(L), m_NonNegative(R)),
-      m_MaxMinLike<ISD::UMIN, umin_pred_ty>(m_Negative(L), m_Negative(R)));
+inline auto m_SMinLike(const SelectionDAG &DAG, const LHS &L, const RHS &R) {
+  return m_AnyOf(m_MaxMinLike<ISD::SMIN, smin_pred_ty>(L, R),
+                 m_MaxMinLike<ISD::UMIN, umin_pred_ty>(m_NonNegative(DAG, L),
+                                                       m_NonNegative(DAG, R)),
+                 m_MaxMinLike<ISD::UMIN, umin_pred_ty>(m_Negative(DAG, L),
+                                                       m_Negative(DAG, R)));
 }
 
 template <typename LHS, typename RHS>
@@ -917,11 +810,12 @@ inline BinaryOpc_match<LHS, RHS, true> m_SMax(const LHS &L, const RHS &R) {
 }
 
 template <typename LHS, typename RHS>
-inline auto m_SMaxLike(const LHS &L, const RHS &R) {
-  return m_AnyOf(
-      m_MaxMinLike<ISD::SMAX, smax_pred_ty>(L, R),
-      m_MaxMinLike<ISD::UMAX, umax_pred_ty>(m_NonNegative(L), m_NonNegative(R)),
-      m_MaxMinLike<ISD::UMAX, umax_pred_ty>(m_Negative(L), m_Negative(R)));
+inline auto m_SMaxLike(const SelectionDAG &DAG, const LHS &L, const RHS &R) {
+  return m_AnyOf(m_MaxMinLike<ISD::SMAX, smax_pred_ty>(L, R),
+                 m_MaxMinLike<ISD::UMAX, umax_pred_ty>(m_NonNegative(DAG, L),
+                                                       m_NonNegative(DAG, R)),
+                 m_MaxMinLike<ISD::UMAX, umax_pred_ty>(m_Negative(DAG, L),
+                                                       m_Negative(DAG, R)));
 }
 
 template <typename LHS, typename RHS>
@@ -930,11 +824,12 @@ inline BinaryOpc_match<LHS, RHS, true> m_UMin(const LHS &L, const RHS &R) {
 }
 
 template <typename LHS, typename RHS>
-inline auto m_UMinLike(const LHS &L, const RHS &R) {
-  return m_AnyOf(
-      m_MaxMinLike<ISD::UMIN, umin_pred_ty>(L, R),
-      m_MaxMinLike<ISD::SMIN, smin_pred_ty>(m_NonNegative(L), m_NonNegative(R)),
-      m_MaxMinLike<ISD::SMIN, smin_pred_ty>(m_Negative(L), m_Negative(R)));
+inline auto m_UMinLike(const SelectionDAG &DAG, const LHS &L, const RHS &R) {
+  return m_AnyOf(m_MaxMinLike<ISD::UMIN, umin_pred_ty>(L, R),
+                 m_MaxMinLike<ISD::SMIN, smin_pred_ty>(m_NonNegative(DAG, L),
+                                                       m_NonNegative(DAG, R)),
+                 m_MaxMinLike<ISD::SMIN, smin_pred_ty>(m_Negative(DAG, L),
+                                                       m_Negative(DAG, R)));
 }
 
 template <typename LHS, typename RHS>
@@ -943,11 +838,12 @@ inline BinaryOpc_match<LHS, RHS, true> m_UMax(const LHS &L, const RHS &R) {
 }
 
 template <typename LHS, typename RHS>
-inline auto m_UMaxLike(const LHS &L, const RHS &R) {
-  return m_AnyOf(
-      m_MaxMinLike<ISD::UMAX, umax_pred_ty>(L, R),
-      m_MaxMinLike<ISD::SMAX, smax_pred_ty>(m_NonNega...
[truncated]

``````````

</details>


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


More information about the llvm-commits mailing list