[llvm] Add m_SelectCCLike matcher to match SELECT_CC or SELECT with SETCC (PR #149646)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 22 00:23:31 PDT 2025


================
@@ -578,6 +578,43 @@ m_InsertSubvector(const LHS &Base, const RHS &Sub, const IDX &Idx) {
   return TernaryOpc_match<LHS, RHS, IDX>(ISD::INSERT_SUBVECTOR, Base, Sub, Idx);
 }
 
+template <typename LTy, typename RTy, typename TTy, typename FTy, typename CCTy>
+struct SelectCC_match {
+  LTy L;
+  RTy R;
+  TTy T;
+  FTy F;
+  CCTy CC;
+
+  SelectCC_match(LTy L, RTy R, TTy T, FTy F, CCTy CC)
+      : L(std::move(L)), R(std::move(R)), T(std::move(T)), F(std::move(F)),
+        CC(std::move(CC)) {}
+
+  template <typename MatchContext>
+  bool match(MatchContext &Ctx, SDValue V) {
+    return V.getOpcode() == ISD::SELECT_CC && L.match(Ctx, V.getOperand(0)) &&
+           R.match(Ctx, V.getOperand(1)) && T.match(Ctx, V.getOperand(2)) &&
+           F.match(Ctx, V.getOperand(3)) && CC.match(Ctx, V.getOperand(4));
+  }
+};
----------------
RKSimon wrote:

Why did you have to use this instead of just `m_Node(ISD::SELECT_CC,L, R, T, F, CC)`?

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


More information about the llvm-commits mailing list