-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[InstCombine] Extend #125676 to handle variable power of 2 #125855
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4200,14 +4200,14 @@ Value *InstCombinerImpl::foldXorOfICmps(ICmpInst *LHS, ICmpInst *RHS, | |
|
|
||
| // Fold (icmp eq/ne (X & Pow2), 0) ^ (icmp eq/ne (Y & Pow2), 0) into | ||
| // (icmp eq/ne ((X ^ Y) & Pow2), 0) | ||
| Value *X, *Y; | ||
| const APInt *Mask; | ||
| Value *X, *Y, *Mask; | ||
| if (ICmpInst::isEquality(PredL) && ICmpInst::isEquality(PredR) && | ||
| LC->isZero() && RC->isZero() && LHS->hasOneUse() && RHS->hasOneUse() && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can it not be beneficial to make the fold if either LHS or RHS have one use? it will result in the same amount of instructions but the other argument will have one less use.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cmp that has one use would also need its op to have one use i.e |
||
| match(LHS0, m_And(m_Value(X), m_Power2(Mask))) && | ||
| match(RHS0, m_And(m_Value(Y), m_SpecificInt(*Mask)))) { | ||
| match(LHS0, m_And(m_Value(X), m_Value(Mask))) && | ||
| match(RHS0, m_And(m_Value(Y), m_Specific(Mask))) && | ||
| isKnownToBeAPowerOfTwo(Mask, /*OrZero=*/true, /*Depth=*/0, &I)) { | ||
| Value *Xor = Builder.CreateXor(X, Y); | ||
| Value *And = Builder.CreateAnd(Xor, *Mask); | ||
| Value *And = Builder.CreateAnd(Xor, Mask); | ||
| return Builder.CreateICmp(PredL == PredR ? ICmpInst::ICMP_NE | ||
| : ICmpInst::ICMP_EQ, | ||
| And, ConstantInt::getNullValue(Xor->getType())); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.