[llvm] aa7f820 - [IR] Add helpers for `NUWAddLike` and `NSWAddLike` to also match `or disjoint`; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 11:03:51 PDT 2024
Author: Noah Goldstein
Date: 2024-03-21T13:03:38-05:00
New Revision: aa7f8200ac29823e6c662d1f41763c2509514161
URL: https://github.com/llvm/llvm-project/commit/aa7f8200ac29823e6c662d1f41763c2509514161
DIFF: https://github.com/llvm/llvm-project/commit/aa7f8200ac29823e6c662d1f41763c2509514161.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/IR/PatternMatch.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index 382009d9df785d..04feb1fd17fd62 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -1319,6 +1319,26 @@ m_AddLike(const LHS &L, const RHS &R) {
return m_CombineOr(m_Add(L, R), m_DisjointOr(L, R));
}
+/// Match either "add nsw" or "or disjoint"
+template <typename LHS, typename RHS>
+inline match_combine_or<
+ OverflowingBinaryOp_match<LHS, RHS, Instruction::Add,
+ OverflowingBinaryOperator::NoSignedWrap>,
+ DisjointOr_match<LHS, RHS>>
+m_NSWAddLike(const LHS &L, const RHS &R) {
+ return m_CombineOr(m_NSWAdd(L, R), m_DisjointOr(L, R));
+}
+
+/// Match either "add nuw" or "or disjoint"
+template <typename LHS, typename RHS>
+inline match_combine_or<
+ OverflowingBinaryOp_match<LHS, RHS, Instruction::Add,
+ OverflowingBinaryOperator::NoUnsignedWrap>,
+ DisjointOr_match<LHS, RHS>>
+m_NUWAddLike(const LHS &L, const RHS &R) {
+ return m_CombineOr(m_NUWAdd(L, R), m_DisjointOr(L, R));
+}
+
//===----------------------------------------------------------------------===//
// Class that matches a group of binary opcodes.
//
More information about the llvm-commits
mailing list