@@ -688,7 +688,7 @@ inline api_pred_ty<is_lowbit_mask_or_zero> m_LowBitMaskOrZero(const APInt *&V) {
688688}
689689
690690struct icmp_pred_with_threshold {
691- ICmpInst::Predicate Pred;
691+ CmpPredicate Pred;
692692 const APInt *Thr;
693693 bool isValue (const APInt &C) { return ICmpInst::compare (C, *Thr, Pred); }
694694};
@@ -1557,16 +1557,16 @@ template <typename T> inline Exact_match<T> m_Exact(const T &SubPattern) {
15571557// Matchers for CmpInst classes
15581558//
15591559
1560- template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy,
1560+ template <typename LHS_t, typename RHS_t, typename Class,
15611561 bool Commutable = false >
15621562struct CmpClass_match {
1563- PredicateTy *Predicate;
1563+ CmpPredicate *Predicate;
15641564 LHS_t L;
15651565 RHS_t R;
15661566
15671567 // The evaluation order is always stable, regardless of Commutability.
15681568 // The LHS is always matched first.
1569- CmpClass_match (PredicateTy &Pred, const LHS_t &LHS, const RHS_t &RHS)
1569+ CmpClass_match (CmpPredicate &Pred, const LHS_t &LHS, const RHS_t &RHS)
15701570 : Predicate(&Pred), L(LHS), R(RHS) {}
15711571 CmpClass_match (const LHS_t &LHS, const RHS_t &RHS)
15721572 : Predicate(nullptr ), L(LHS), R(RHS) {}
@@ -1575,12 +1575,13 @@ struct CmpClass_match {
15751575 if (auto *I = dyn_cast<Class>(V)) {
15761576 if (L.match (I->getOperand (0 )) && R.match (I->getOperand (1 ))) {
15771577 if (Predicate)
1578- *Predicate = I-> getPredicate ( );
1578+ *Predicate = CmpPredicate::get (I );
15791579 return true ;
1580- } else if (Commutable && L.match (I->getOperand (1 )) &&
1581- R.match (I->getOperand (0 ))) {
1580+ }
1581+ if (Commutable && L.match (I->getOperand (1 )) &&
1582+ R.match (I->getOperand (0 ))) {
15821583 if (Predicate)
1583- *Predicate = I-> getSwappedPredicate ( );
1584+ *Predicate = CmpPredicate::getSwapped (I );
15841585 return true ;
15851586 }
15861587 }
@@ -1589,60 +1590,58 @@ struct CmpClass_match {
15891590};
15901591
15911592template <typename LHS, typename RHS>
1592- inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1593- m_Cmp (CmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1594- return CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate >(Pred, L, R);
1593+ inline CmpClass_match<LHS, RHS, CmpInst> m_Cmp (CmpPredicate &Pred, const LHS &L,
1594+ const RHS &R) {
1595+ return CmpClass_match<LHS, RHS, CmpInst>(Pred, L, R);
15951596}
15961597
15971598template <typename LHS, typename RHS>
1598- inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1599- m_ICmp (ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1600- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate >(Pred, L, R);
1599+ inline CmpClass_match<LHS, RHS, ICmpInst> m_ICmp (CmpPredicate &Pred,
1600+ const LHS &L, const RHS &R) {
1601+ return CmpClass_match<LHS, RHS, ICmpInst>(Pred, L, R);
16011602}
16021603
16031604template <typename LHS, typename RHS>
1604- inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1605- m_FCmp (FCmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1606- return CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate >(Pred, L, R);
1605+ inline CmpClass_match<LHS, RHS, FCmpInst> m_FCmp (CmpPredicate &Pred,
1606+ const LHS &L, const RHS &R) {
1607+ return CmpClass_match<LHS, RHS, FCmpInst>(Pred, L, R);
16071608}
16081609
16091610template <typename LHS, typename RHS>
1610- inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1611- m_Cmp (const LHS &L, const RHS &R) {
1612- return CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>(L, R);
1611+ inline CmpClass_match<LHS, RHS, CmpInst> m_Cmp (const LHS &L, const RHS &R) {
1612+ return CmpClass_match<LHS, RHS, CmpInst>(L, R);
16131613}
16141614
16151615template <typename LHS, typename RHS>
1616- inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1617- m_ICmp (const LHS &L, const RHS &R) {
1618- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>(L, R);
1616+ inline CmpClass_match<LHS, RHS, ICmpInst> m_ICmp (const LHS &L, const RHS &R) {
1617+ return CmpClass_match<LHS, RHS, ICmpInst>(L, R);
16191618}
16201619
16211620template <typename LHS, typename RHS>
1622- inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1623- m_FCmp (const LHS &L, const RHS &R) {
1624- return CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>(L, R);
1621+ inline CmpClass_match<LHS, RHS, FCmpInst> m_FCmp (const LHS &L, const RHS &R) {
1622+ return CmpClass_match<LHS, RHS, FCmpInst>(L, R);
16251623}
16261624
16271625// Same as CmpClass, but instead of saving Pred as out output variable, match a
16281626// specific input pred for equality.
1629- template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy,
1627+ template <typename LHS_t, typename RHS_t, typename Class,
16301628 bool Commutable = false >
16311629struct SpecificCmpClass_match {
1632- const PredicateTy Predicate;
1630+ const CmpPredicate Predicate;
16331631 LHS_t L;
16341632 RHS_t R;
16351633
1636- SpecificCmpClass_match (PredicateTy Pred, const LHS_t &LHS, const RHS_t &RHS)
1634+ SpecificCmpClass_match (CmpPredicate Pred, const LHS_t &LHS, const RHS_t &RHS)
16371635 : Predicate(Pred), L(LHS), R(RHS) {}
16381636
16391637 template <typename OpTy> bool match (OpTy *V) {
16401638 if (auto *I = dyn_cast<Class>(V)) {
1641- if (I-> getPredicate () == Predicate && L. match (I-> getOperand ( 0 ) ) &&
1642- R.match (I->getOperand (1 )))
1639+ if (CmpPredicate::getMatching ( CmpPredicate::get (I), Predicate ) &&
1640+ L. match (I-> getOperand ( 0 )) && R.match (I->getOperand (1 )))
16431641 return true ;
16441642 if constexpr (Commutable) {
1645- if (I->getPredicate () == Class::getSwappedPredicate (Predicate) &&
1643+ if (CmpPredicate::getMatching (CmpPredicate::get (I),
1644+ CmpPredicate::getSwapped (Predicate)) &&
16461645 L.match (I->getOperand (1 )) && R.match (I->getOperand (0 )))
16471646 return true ;
16481647 }
@@ -1653,31 +1652,27 @@ struct SpecificCmpClass_match {
16531652};
16541653
16551654template <typename LHS, typename RHS>
1656- inline SpecificCmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1657- m_SpecificCmp (CmpInst::Predicate MatchPred, const LHS &L, const RHS &R) {
1658- return SpecificCmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>(
1659- MatchPred, L, R);
1655+ inline SpecificCmpClass_match<LHS, RHS, CmpInst>
1656+ m_SpecificCmp (CmpPredicate MatchPred, const LHS &L, const RHS &R) {
1657+ return SpecificCmpClass_match<LHS, RHS, CmpInst>(MatchPred, L, R);
16601658}
16611659
16621660template <typename LHS, typename RHS>
1663- inline SpecificCmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1664- m_SpecificICmp (ICmpInst::Predicate MatchPred, const LHS &L, const RHS &R) {
1665- return SpecificCmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>(
1666- MatchPred, L, R);
1661+ inline SpecificCmpClass_match<LHS, RHS, ICmpInst>
1662+ m_SpecificICmp (CmpPredicate MatchPred, const LHS &L, const RHS &R) {
1663+ return SpecificCmpClass_match<LHS, RHS, ICmpInst>(MatchPred, L, R);
16671664}
16681665
16691666template <typename LHS, typename RHS>
1670- inline SpecificCmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >
1671- m_c_SpecificICmp (ICmpInst::Predicate MatchPred, const LHS &L, const RHS &R) {
1672- return SpecificCmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >(
1673- MatchPred, L, R);
1667+ inline SpecificCmpClass_match<LHS, RHS, ICmpInst, true >
1668+ m_c_SpecificICmp (CmpPredicate MatchPred, const LHS &L, const RHS &R) {
1669+ return SpecificCmpClass_match<LHS, RHS, ICmpInst, true >(MatchPred, L, R);
16741670}
16751671
16761672template <typename LHS, typename RHS>
1677- inline SpecificCmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1678- m_SpecificFCmp (FCmpInst::Predicate MatchPred, const LHS &L, const RHS &R) {
1679- return SpecificCmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>(
1680- MatchPred, L, R);
1673+ inline SpecificCmpClass_match<LHS, RHS, FCmpInst>
1674+ m_SpecificFCmp (CmpPredicate MatchPred, const LHS &L, const RHS &R) {
1675+ return SpecificCmpClass_match<LHS, RHS, FCmpInst>(MatchPred, L, R);
16811676}
16821677
16831678// ===----------------------------------------------------------------------===//
@@ -2468,7 +2463,7 @@ struct UAddWithOverflow_match {
24682463
24692464 template <typename OpTy> bool match (OpTy *V) {
24702465 Value *ICmpLHS, *ICmpRHS;
2471- ICmpInst::Predicate Pred;
2466+ CmpPredicate Pred;
24722467 if (!m_ICmp (Pred, m_Value (ICmpLHS), m_Value (ICmpRHS)).match (V))
24732468 return false ;
24742469
@@ -2738,16 +2733,15 @@ inline AnyBinaryOp_match<LHS, RHS, true> m_c_BinOp(const LHS &L, const RHS &R) {
27382733// / Matches an ICmp with a predicate over LHS and RHS in either order.
27392734// / Swaps the predicate if operands are commuted.
27402735template <typename LHS, typename RHS>
2741- inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >
2742- m_c_ICmp (ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
2743- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >(Pred, L,
2744- R);
2736+ inline CmpClass_match<LHS, RHS, ICmpInst, true >
2737+ m_c_ICmp (CmpPredicate &Pred, const LHS &L, const RHS &R) {
2738+ return CmpClass_match<LHS, RHS, ICmpInst, true >(Pred, L, R);
27452739}
27462740
27472741template <typename LHS, typename RHS>
2748- inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >
2749- m_c_ICmp ( const LHS &L, const RHS &R) {
2750- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >(L, R);
2742+ inline CmpClass_match<LHS, RHS, ICmpInst, true > m_c_ICmp ( const LHS &L,
2743+ const RHS &R) {
2744+ return CmpClass_match<LHS, RHS, ICmpInst, true >(L, R);
27512745}
27522746
27532747// / Matches a specific opcode with LHS and RHS in either order.
0 commit comments