@@ -1342,7 +1342,8 @@ m_NUWAddLike(const LHS &L, const RHS &R) {
1342
1342
// ===----------------------------------------------------------------------===//
1343
1343
// Class that matches a group of binary opcodes.
1344
1344
//
1345
- template <typename LHS_t, typename RHS_t, typename Predicate>
1345
+ template <typename LHS_t, typename RHS_t, typename Predicate,
1346
+ bool Commutable = false >
1346
1347
struct BinOpPred_match : Predicate {
1347
1348
LHS_t L;
1348
1349
RHS_t R;
@@ -1351,8 +1352,10 @@ struct BinOpPred_match : Predicate {
1351
1352
1352
1353
template <typename OpTy> bool match (OpTy *V) {
1353
1354
if (auto *I = dyn_cast<Instruction>(V))
1354
- return this ->isOpType (I->getOpcode ()) && L.match (I->getOperand (0 )) &&
1355
- R.match (I->getOperand (1 ));
1355
+ return this ->isOpType (I->getOpcode ()) &&
1356
+ ((L.match (I->getOperand (0 )) && R.match (I->getOperand (1 ))) ||
1357
+ (Commutable && L.match (I->getOperand (1 )) &&
1358
+ R.match (I->getOperand (0 ))));
1356
1359
return false ;
1357
1360
}
1358
1361
};
@@ -1419,6 +1422,13 @@ m_BitwiseLogic(const LHS &L, const RHS &R) {
1419
1422
return BinOpPred_match<LHS, RHS, is_bitwiselogic_op>(L, R);
1420
1423
}
1421
1424
1425
+ // / Matches bitwise logic operations in either order.
1426
+ template <typename LHS, typename RHS>
1427
+ inline BinOpPred_match<LHS, RHS, is_bitwiselogic_op>
1428
+ m_c_BitwiseLogic (const LHS &L, const RHS &R) {
1429
+ return BinOpPred_match<LHS, RHS, is_bitwiselogic_op, true >(L, R);
1430
+ }
1431
+
1422
1432
// / Matches integer division operations.
1423
1433
template <typename LHS, typename RHS>
1424
1434
inline BinOpPred_match<LHS, RHS, is_idiv_op> m_IDiv (const LHS &L,
0 commit comments