[llvm] [IR] Add icmp like matcher (NFC) (PR #192746)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 18 00:20:42 PDT 2026
================
@@ -2314,6 +2314,35 @@ template <typename OpTy> inline auto m_ZExtOrTruncOrSelf(const OpTy &Op) {
return m_CombineOr(m_ZExt(Op), m_Trunc(Op), Op);
}
+template <typename LHS_t, typename RHS_t> struct IcmpLike_match {
+ CmpPredicate &Pred;
+ LHS_t L;
+ RHS_t R;
+
+ IcmpLike_match(CmpPredicate &P, const LHS_t &Left, const RHS_t &Right)
+ : Pred(P), L(Left), R(Right) {}
+
+ template <typename OpTy> bool match(OpTy *V) const {
+ if (PatternMatch::match(V, m_ICmp(Pred, L, R)))
+ return true;
+ Value *A;
+ // trunc nuw x to i1 is equivalent to icmp ne x, 0
+ if (V->getType()->isIntOrIntVectorTy(1) &&
----------------
dtcxzyw wrote:
I'd prefer inserting an assertion on the result type here. Accepting a non-boolean value for `m_ICmp[Like]` is meaningless.
https://github.com/llvm/llvm-project/pull/192746
More information about the llvm-commits
mailing list