[llvm] [PatternMatch] Add `m_c_XorLike` matcher; NFC (PR #122642)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 12 08:50:25 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff b91d5af1ac3ad2c18b1dfde2061a6ac1d638e6e4 d3aacf78ba3d1eba88a298b9c7e15ddd662c2069 --extensions cpp,h -- llvm/include/llvm/IR/PatternMatch.h llvm/unittests/IR/PatternMatch.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index e50459716f..977d22e2f6 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -1430,8 +1430,7 @@ 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 {
+template <typename LHS, typename RHS> struct XorLike_match {
LHS L;
RHS R;
@@ -1441,7 +1440,7 @@ struct XorLike_match {
if (auto *Op = dyn_cast<BinaryOperator>(V)) {
if (Op->getOpcode() == Instruction::Sub && Op->hasNoUnsignedWrap() &&
PatternMatch::match(Op->getOperand(0), m_LowBitMask()))
- ; // Pass
+ ; // Pass
else if (Op->getOpcode() != Instruction::Xor)
return false;
return (L.match(Op->getOperand(0)) && R.match(Op->getOperand(1))) ||
diff --git a/llvm/unittests/IR/PatternMatch.cpp b/llvm/unittests/IR/PatternMatch.cpp
index da2c09ea19..d06ada5953 100644
--- a/llvm/unittests/IR/PatternMatch.cpp
+++ b/llvm/unittests/IR/PatternMatch.cpp
@@ -557,7 +557,7 @@ TEST_F(PatternMatchTest, XorLike) {
Value *Xor = IRB.CreateXor(X, MaskC);
Value *Sub = IRB.CreateNUWSub(MaskC, X);
OpA = nullptr;
- OpB = nullptr;
+ OpB = nullptr;
EXPECT_TRUE(m_c_XorLike(m_Value(OpA), m_Value(OpB)).match(Xor));
EXPECT_TRUE(OpA != OpB && (OpA == X || OpB == X) &&
(OpA == MaskC || OpB == MaskC));
@@ -571,7 +571,7 @@ TEST_F(PatternMatchTest, XorLike) {
Value *Xor = IRB.CreateXor(X, MaskC);
Value *Sub = IRB.CreateNSWSub(MaskC, X);
OpA = nullptr;
- OpB = nullptr;
+ OpB = nullptr;
EXPECT_TRUE(m_c_XorLike(m_Value(OpA), m_Value(OpB)).match(Xor));
EXPECT_TRUE(OpA != OpB && (OpA == X || OpB == X) &&
(OpA == MaskC || OpB == MaskC));
@@ -589,14 +589,14 @@ TEST_F(PatternMatchTest, XorLike) {
Value *Xor = IRB.CreateXor(X, NonMaskC);
Value *Sub = IRB.CreateNUWSub(NonMaskC, X);
OpA = nullptr;
- OpB = nullptr;
+ OpB = nullptr;
EXPECT_TRUE(m_c_XorLike(m_Value(OpA), m_Value(OpB)).match(Xor));
EXPECT_TRUE(OpA != OpB && (OpA == X || OpB == X) &&
(OpA == NonMaskC || OpB == NonMaskC));
OpA = nullptr;
OpB = nullptr;
EXPECT_FALSE(m_c_XorLike(m_Value(OpA), m_Value(OpB)).match(Sub));
- }
+ }
}
TEST_F(PatternMatchTest, ZExtSExtSelf) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/122642
More information about the llvm-commits
mailing list