@@ -2309,6 +2309,22 @@ m_UnordFMin(const LHS &L, const RHS &R) {
2309
2309
return MaxMin_match<FCmpInst, LHS, RHS, ufmin_pred_ty>(L, R);
2310
2310
}
2311
2311
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
+
2312
2328
// ===----------------------------------------------------------------------===//
2313
2329
// Matchers for overflow check patterns: e.g. (a + b) u< a, (a ^ -1) <u b
2314
2330
// Note that S might be matched to other instructions than AddInst.
@@ -2343,13 +2359,13 @@ struct UAddWithOverflow_match {
2343
2359
return L.match (AddLHS) && R.match (AddRHS) && S.match (ICmpRHS);
2344
2360
2345
2361
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
2348
2364
if (Pred == ICmpInst::ICMP_ULT) {
2349
2365
if (XorExpr.match (ICmpLHS))
2350
2366
return L.match (Op1) && R.match (ICmpRHS) && S.match (ICmpLHS);
2351
2367
}
2352
- // b > u (a ^ -1 )
2368
+ // b > u (~a )
2353
2369
if (Pred == ICmpInst::ICMP_UGT) {
2354
2370
if (XorExpr.match (ICmpRHS))
2355
2371
return L.match (Op1) && R.match (ICmpLHS) && S.match (ICmpRHS);
@@ -2659,22 +2675,6 @@ m_NSWNeg(const ValTy &V) {
2659
2675
return m_NSWSub (m_ZeroInt (), V);
2660
2676
}
2661
2677
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
-
2678
2678
// / Matches an SMin with LHS and RHS in either order.
2679
2679
template <typename LHS, typename RHS>
2680
2680
inline MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty, true >
0 commit comments