@@ -2309,6 +2309,22 @@ m_UnordFMin(const LHS &L, const RHS &R) {
23092309 return MaxMin_match<FCmpInst, LHS, RHS, ufmin_pred_ty>(L, R);
23102310}
23112311
2312+ // / Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
2313+ // / NOTE: we first match the 'Not' (by matching '-1'),
2314+ // / and only then match the inner matcher!
2315+ template <typename ValTy>
2316+ inline BinaryOp_match<cst_pred_ty<is_all_ones>, ValTy, Instruction::Xor, true >
2317+ m_Not (const ValTy &V) {
2318+ return m_c_Xor (m_AllOnes (), V);
2319+ }
2320+
2321+ template <typename ValTy>
2322+ inline BinaryOp_match<cst_pred_ty<is_all_ones, false >, ValTy, Instruction::Xor,
2323+ true >
2324+ m_NotForbidPoison (const ValTy &V) {
2325+ return m_c_Xor (m_AllOnesForbidPoison (), V);
2326+ }
2327+
23122328// ===----------------------------------------------------------------------===//
23132329// Matchers for overflow check patterns: e.g. (a + b) u< a, (a ^ -1) <u b
23142330// Note that S might be matched to other instructions than AddInst.
@@ -2343,13 +2359,13 @@ struct UAddWithOverflow_match {
23432359 return L.match (AddLHS) && R.match (AddRHS) && S.match (ICmpRHS);
23442360
23452361 Value *Op1;
2346- auto XorExpr = m_OneUse (m_Xor (m_Value (Op1), m_AllOnes ( )));
2347- // (a ^ -1 ) <u b
2362+ auto XorExpr = m_OneUse (m_Not (m_Value (Op1)));
2363+ // (~a ) <u b
23482364 if (Pred == ICmpInst::ICMP_ULT) {
23492365 if (XorExpr.match (ICmpLHS))
23502366 return L.match (Op1) && R.match (ICmpRHS) && S.match (ICmpLHS);
23512367 }
2352- // b > u (a ^ -1 )
2368+ // b > u (~a )
23532369 if (Pred == ICmpInst::ICMP_UGT) {
23542370 if (XorExpr.match (ICmpRHS))
23552371 return L.match (Op1) && R.match (ICmpLHS) && S.match (ICmpRHS);
@@ -2659,22 +2675,6 @@ m_NSWNeg(const ValTy &V) {
26592675 return m_NSWSub (m_ZeroInt (), V);
26602676}
26612677
2662- // / Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
2663- // / NOTE: we first match the 'Not' (by matching '-1'),
2664- // / and only then match the inner matcher!
2665- template <typename ValTy>
2666- inline BinaryOp_match<cst_pred_ty<is_all_ones>, ValTy, Instruction::Xor, true >
2667- m_Not (const ValTy &V) {
2668- return m_c_Xor (m_AllOnes (), V);
2669- }
2670-
2671- template <typename ValTy>
2672- inline BinaryOp_match<cst_pred_ty<is_all_ones, false >, ValTy, Instruction::Xor,
2673- true >
2674- m_NotForbidPoison (const ValTy &V) {
2675- return m_c_Xor (m_AllOnesForbidPoison (), V);
2676- }
2677-
26782678// / Matches an SMin with LHS and RHS in either order.
26792679template <typename LHS, typename RHS>
26802680inline MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty, true >
0 commit comments