Skip to content
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

[InstCombine] Use disjoint flag instead of calling haveNoCommonBitsSet. #74222

Merged
merged 2 commits into from
Dec 3, 2023

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Dec 3, 2023

No description provided.

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 3, 2023

@llvm/pr-subscribers-llvm-transforms

Author: Craig Topper (topperc)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (+1-1)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 7379bdf93169e..481fcdf181946 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3395,7 +3395,7 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
   // or (mul X, Y), X --> add (mul X, Y), X --> mul X, (Y + 1)
   if (match(&I,
             m_c_Or(m_OneUse(m_Mul(m_Value(X), m_Value(Y))), m_Deferred(X))) &&
-      haveNoCommonBitsSet(Op0, Op1, DL)) {
+      cast<PossiblyDisjointInst>(I).isDisjoint()) {
     Value *IncrementY = Builder.CreateAdd(Y, ConstantInt::get(Ty, 1));
     return BinaryOperator::CreateMul(X, IncrementY);
   }

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

We'll probably want to have m_DisjointOr() if there are more cases like this.

@nikic
Copy link
Contributor

nikic commented Dec 3, 2023

Actually, can you please add an extra test that explicitly uses or disjoint with this transform? (Without haveNoCommonBitsSet being able to derive it.)

@topperc topperc merged commit 3e7ca05 into llvm:main Dec 3, 2023
3 checks passed
@topperc topperc deleted the pr/or-mul-disjoint branch December 3, 2023 20:34
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.

None yet

3 participants