This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/11259] [avr] gcc Double 'andi' missed optimization



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]