-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
[AVR] Optimize 16-bit comparisions with zero #30923
Comments
That last snippet is missing a 'breq LBB0_4' at the bottom. |
I have a few further suggestions:
|
Proposed patch Original generated code: Updated Code: The patch uses an immediate compare using 'cpi' followed by a 'sbci' which takes into account the Kindly review this patch and let me know if I have missed anything. Regression tested for targets which I built (avr, x86 and arm) on SVR revision 343839. I did observe a failure in todays build in testcase : CodeGen/AVR/call.ll Regards, |
Great work Kaushik, thanks! I will get onto reviewing the patch |
An alternative way is
The zero_reg is R17 on avrtiny or R1 on others. |
fixed by https://reviews.llvm.org/D142281 |
fixed by f37d7c9 |
Fixes llvm/llvm-project#30923 Reviewed By: jacquesguan, aykevl Differential Revision: https://reviews.llvm.org/D142281
Fixes llvm/llvm-project#30923 Reviewed By: jacquesguan, aykevl Differential Revision: https://reviews.llvm.org/D142281
Fixes llvm/llvm-project#30923 Reviewed By: jacquesguan, aykevl Differential Revision: https://reviews.llvm.org/D142281
Extended Description
Currently when we try and perform a 16-bit comparision with zero, we generate the following code:
ldi r24, 0
ldi r25, 0
cp r26, r24
cpc r27, r25
breq LBB0_4
We can simplify this to
ldi r24, 0
cp r26, r24
cpc r27, r24
And save a register
The text was updated successfully, but these errors were encountered: