Skip to content

Commit aa7f820

Browse files
committed
[IR] Add helpers for NUWAddLike and NSWAddLike to also match or disjoint; NFC
`or disjoint` implies `add nuw nsw`: https://alive2.llvm.org/ce/z/VABhDA
1 parent 3218570 commit aa7f820

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

llvm/include/llvm/IR/PatternMatch.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,26 @@ m_AddLike(const LHS &L, const RHS &R) {
13191319
return m_CombineOr(m_Add(L, R), m_DisjointOr(L, R));
13201320
}
13211321

1322+
/// Match either "add nsw" or "or disjoint"
1323+
template <typename LHS, typename RHS>
1324+
inline match_combine_or<
1325+
OverflowingBinaryOp_match<LHS, RHS, Instruction::Add,
1326+
OverflowingBinaryOperator::NoSignedWrap>,
1327+
DisjointOr_match<LHS, RHS>>
1328+
m_NSWAddLike(const LHS &L, const RHS &R) {
1329+
return m_CombineOr(m_NSWAdd(L, R), m_DisjointOr(L, R));
1330+
}
1331+
1332+
/// Match either "add nuw" or "or disjoint"
1333+
template <typename LHS, typename RHS>
1334+
inline match_combine_or<
1335+
OverflowingBinaryOp_match<LHS, RHS, Instruction::Add,
1336+
OverflowingBinaryOperator::NoUnsignedWrap>,
1337+
DisjointOr_match<LHS, RHS>>
1338+
m_NUWAddLike(const LHS &L, const RHS &R) {
1339+
return m_CombineOr(m_NUWAdd(L, R), m_DisjointOr(L, R));
1340+
}
1341+
13221342
//===----------------------------------------------------------------------===//
13231343
// Class that matches a group of binary opcodes.
13241344
//

0 commit comments

Comments
 (0)