-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[Mips] Optimize (shift x (and y, BitWidth - 1)) to (shift x, y) #73889
Conversation
a7782e8
to
75b3dd9
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
||
const APInt &RHS = cast<ConstantSDNode>(N->getOperand(1))->getAPIntValue(); | ||
if (RHS.countr_one() >= ShAmtBits) { | ||
LLVM_DEBUG(dbgs() << DEBUG_TYPE << " Need optimize 'and & shl/srl/sra' and operand value bits is " << RHS.countr_one() << "\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
80 columns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
75b3dd9
to
ed08253
Compare
Do optimization to turn x >> (shift & 31/63) into a single srlv instead of andi + srlv, since the mips variable shift instruction already implicitly masks the shift, like x86, wasm and AMDGPU. Copy the X86DAGToDAGISel::isUnneededShiftMask() function to MIPS for checking whether need combine two instructions to one.
ed08253
to
9513230
Compare
Hi @topperc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@xgupta Thanks! |
Do optimization to turn x >> (shift & 31/63) into a single srlv instead of andi + srlv, since the mips variable shift instruction already implicitly masks the shift, like x86, wasm and AMDGPU. Copy the X86DAGToDAGISel::isUnneededShiftMask() function to MIPS for checking whether need combine two instructions to one.