Skip to content

[InstCombine] Simplify matchers (NFC) #96665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2024
Merged

[InstCombine] Simplify matchers (NFC) #96665

merged 1 commit into from
Jun 26, 2024

Conversation

AZero13
Copy link
Contributor

@AZero13 AZero13 commented Jun 25, 2024

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Jun 25, 2024

@llvm/pr-subscribers-llvm-transforms

Author: AtariDreams (AtariDreams)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/96665.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+1-2)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 19a12343748df..b8664089c36ce 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3655,8 +3655,7 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
 
     // (A & B) | (A ^ B) --> A | B
     // (B & A) | (A ^ B) --> A | B
-    if (match(Op0, m_And(m_Specific(A), m_Specific(B))) ||
-        match(Op0, m_And(m_Specific(B), m_Specific(A))))
+    if (match(Op0, m_c_And(m_Specific(A), m_Specific(B))))
       return BinaryOperator::CreateOr(A, B);
 
     // ~A | (A ^ B) --> ~(A & B)

@AZero13 AZero13 changed the title [InstCombine] Simplify matcher in InstCombineAndOrXor (NFC) [InstCombine] Simplify matchers (NFC) Jun 25, 2024
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some of these are non-canonical, but I guess we can keep them in the interest of keeping this change NFC.

@AZero13
Copy link
Contributor Author

AZero13 commented Jun 26, 2024

LGTM. Some of these are non-canonical, but I guess we can keep them in the interest of keeping this change NFC.

Tell me which ones so I can cut down on them

@goldsteinn
Copy link
Contributor

LGTM. Some of these are non-canonical, but I guess we can keep them in the interest of keeping this change NFC.

Tell me which ones so I can cut down on them

All the ones where the constant is on the LHS i.e

  if (!match(C, m_And(m_Value(X), m_One())) &&
      !match(C, m_And(m_One(), m_Value(X))))

but probably just get this in as is then follow up patch to remove the m_c from the non-canonical cases.

@nikic nikic merged commit 515e048 into llvm:main Jun 26, 2024
7 checks passed
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
@AZero13 AZero13 deleted the matcher branch July 29, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants