[Bug target/41076] [avr] pessimal code for logical OR of 8-bit fields

gjl at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 22 22:31:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41076

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |
   Target Milestone|4.7.1                       |---
           Severity|enhancement                 |normal

--- Comment #6 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2013-01-22 22:31:11 UTC ---
(In reply to comment #5)
> Fixed I suppose.

Unfortunately, not

extern unsigned char read8 (void);

unsigned short read16 (void)
{
    unsigned char lo, hi;

    hi = read8();
    lo = read8();
    return lo | hi << 8;
}


with 4.8.0 -S -Os the compiler needs 5 instructions (29, 37, 30, 38) for an
operation that is basically a no-op:


read16:
    push r28     ;  31    pushqi1/1    [length = 1]
/* prologue: function */
/* frame size = 0 */
/* stack size = 1 */
.L__stack_usage = 1
    call read8     ;  5    call_value_insn/2    [length = 2]
    mov r28,r24     ;  6    movqi_insn/1    [length = 1]
    call read8     ;  7    call_value_insn/2    [length = 2]
    mov r18,r28     ;  28    movqi_insn/1    [length = 1]
    ldi r19,0     ;  29    movqi_insn/1    [length = 1]
    mov r19,r18     ;  37    *ashlhi3_const/3    [length = 2]
    clr r18
    or r18,r24     ;  30    iorqi3/1    [length = 1]
    movw r24,r18     ;  38    *movhi/1    [length = 1]
/* epilogue start */
    pop r28     ;  34    popqi    [length = 1]
    ret     ;  35    return_from_epilogue    [length = 1]



More information about the Gcc-bugs mailing list