@@ -1550,27 +1550,23 @@ template <typename T> inline Exact_match<T> m_Exact(const T &SubPattern) {
1550
1550
template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy,
1551
1551
bool Commutable = false >
1552
1552
struct CmpClass_match {
1553
- PredicateTy * Predicate;
1553
+ PredicateTy & Predicate;
1554
1554
LHS_t L;
1555
1555
RHS_t R;
1556
1556
1557
1557
// The evaluation order is always stable, regardless of Commutability.
1558
1558
// The LHS is always matched first.
1559
1559
CmpClass_match (PredicateTy &Pred, const LHS_t &LHS, const RHS_t &RHS)
1560
- : Predicate(&Pred), L(LHS), R(RHS) {}
1561
- CmpClass_match (const LHS_t &LHS, const RHS_t &RHS)
1562
- : Predicate(nullptr ), L(LHS), R(RHS) {}
1560
+ : Predicate(Pred), L(LHS), R(RHS) {}
1563
1561
1564
1562
template <typename OpTy> bool match (OpTy *V) {
1565
1563
if (auto *I = dyn_cast<Class>(V)) {
1566
1564
if (L.match (I->getOperand (0 )) && R.match (I->getOperand (1 ))) {
1567
- if (Predicate)
1568
- *Predicate = I->getPredicate ();
1565
+ Predicate = I->getPredicate ();
1569
1566
return true ;
1570
1567
} else if (Commutable && L.match (I->getOperand (1 )) &&
1571
1568
R.match (I->getOperand (0 ))) {
1572
- if (Predicate)
1573
- *Predicate = I->getSwappedPredicate ();
1569
+ Predicate = I->getSwappedPredicate ();
1574
1570
return true ;
1575
1571
}
1576
1572
}
@@ -1599,19 +1595,22 @@ m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1599
1595
template <typename LHS, typename RHS>
1600
1596
inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1601
1597
m_Cmp (const LHS &L, const RHS &R) {
1602
- return CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>(L, R);
1598
+ CmpInst::Predicate Unused;
1599
+ return CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>(Unused, L, R);
1603
1600
}
1604
1601
1605
1602
template <typename LHS, typename RHS>
1606
1603
inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1607
1604
m_ICmp (const LHS &L, const RHS &R) {
1608
- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>(L, R);
1605
+ ICmpInst::Predicate Unused;
1606
+ return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>(Unused, L, R);
1609
1607
}
1610
1608
1611
1609
template <typename LHS, typename RHS>
1612
1610
inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1613
1611
m_FCmp (const LHS &L, const RHS &R) {
1614
- return CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>(L, R);
1612
+ FCmpInst::Predicate Unused;
1613
+ return CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>(Unused, L, R);
1615
1614
}
1616
1615
1617
1616
// Same as CmpClass, but instead of saving Pred as out output variable, match a
0 commit comments