[llvm] [PatternMatch] Add `m_c_XorLike` matcher; NFC (PR #122642)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 06:22:34 PST 2025
================
@@ -1430,6 +1430,34 @@ m_NUWAddLike(const LHS &L, const RHS &R) {
return m_CombineOr(m_NUWAdd(L, R), m_DisjointOr(L, R));
}
+template <typename LHS, typename RHS>
+struct XorLike_match {
+ LHS L;
+ RHS R;
+
+ XorLike_match(const LHS &L, const RHS &R) : L(L), R(R) {}
+
+ template <typename OpTy> bool match(OpTy *V) {
+ if (auto *Op = dyn_cast<BinaryOperator>(V)) {
+ if (Op->getOpcode() == Instruction::Sub && Op->hasNoUnsignedWrap() &&
+ PatternMatch::match(Op->getOperand(0), m_LowBitMask()))
+ ; // Pass
----------------
dtcxzyw wrote:
In this case, only `L.match(Op->getOperand(1)) && R.match(Op->getOperand(0))` is needed.
https://github.com/llvm/llvm-project/pull/122642
More information about the llvm-commits
mailing list