This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/11259] [avr] gcc Double 'andi' missed optimization
- From: "rask at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Nov 2007 22:07:39 -0000
- Subject: [Bug target/11259] [avr] gcc Double 'andi' missed optimization
- References: <bug-11259-6346@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from rask at gcc dot gnu dot org 2007-11-28 22:07 -------
Created an attachment (id=14658)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14658&action=view)
example patch
This patch is an example of the suggestion in comment #6. When compiling with
-S -dp, it is clear why the code isn't optimized: "swap+andi" is one
instruction.
test:
/* prologue: function */
/* frame size = 0 */
in r24,50-0x20 ; 6 *movqi/4 [length = 1]
swap r24 ; 7 lshrqi3/5 [length = 2]
andi r24,0x0f
andi r24,lo8(12) ; 13 andqi3/2 [length = 1]
/* epilogue start */
ret ; 26 return [length = 1]
The patch makes two instructions out of "swap"+"andi" of which "andi" is
optimized away:
test:
/* prologue: function */
/* frame size = 0 */
in r24,50-0x20 ; 6 *movqi/4 [length = 1]
swap r24 ; 7 _rotlqi3_const4 [length = 1]
andi r24,lo8(12) ; 14 andqi3/2 [length = 1]
/* epilogue start */
ret ; 27 return [length = 1]
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11259