@@ -1550,23 +1550,27 @@ 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) {}
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) {}
1561
1563
1562
1564
template <typename OpTy> bool match (OpTy *V) {
1563
1565
if (auto *I = dyn_cast<Class>(V)) {
1564
1566
if (L.match (I->getOperand (0 )) && R.match (I->getOperand (1 ))) {
1565
- Predicate = I->getPredicate ();
1567
+ if (Predicate)
1568
+ *Predicate = I->getPredicate ();
1566
1569
return true ;
1567
1570
} else if (Commutable && L.match (I->getOperand (1 )) &&
1568
1571
R.match (I->getOperand (0 ))) {
1569
- Predicate = I->getSwappedPredicate ();
1572
+ if (Predicate)
1573
+ *Predicate = I->getSwappedPredicate ();
1570
1574
return true ;
1571
1575
}
1572
1576
}
@@ -1595,22 +1599,19 @@ m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1595
1599
template <typename LHS, typename RHS>
1596
1600
inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1597
1601
m_Cmp (const LHS &L, const RHS &R) {
1598
- CmpInst::Predicate Unused;
1599
- return CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>(Unused, L, R);
1602
+ return CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>(L, R);
1600
1603
}
1601
1604
1602
1605
template <typename LHS, typename RHS>
1603
1606
inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1604
1607
m_ICmp (const LHS &L, const RHS &R) {
1605
- ICmpInst::Predicate Unused;
1606
- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>(Unused, L, R);
1608
+ return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>(L, R);
1607
1609
}
1608
1610
1609
1611
template <typename LHS, typename RHS>
1610
1612
inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1611
1613
m_FCmp (const LHS &L, const RHS &R) {
1612
- FCmpInst::Predicate Unused;
1613
- return CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>(Unused, L, R);
1614
+ return CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>(L, R);
1614
1615
}
1615
1616
1616
1617
// Same as CmpClass, but instead of saving Pred as out output variable, match a
@@ -2681,9 +2682,7 @@ m_c_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
2681
2682
template <typename LHS, typename RHS>
2682
2683
inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >
2683
2684
m_c_ICmp (const LHS &L, const RHS &R) {
2684
- ICmpInst::Predicate Unused;
2685
- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >(Unused,
2686
- L, R);
2685
+ return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >(L, R);
2687
2686
}
2688
2687
2689
2688
// / Matches a specific opcode with LHS and RHS in either order.
0 commit comments