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 rtl-optimization/3507] appalling optimisation with sub/cmp on multiple targets



------- Comment #7 from eweddington at cso dot atmel dot com  2007-08-23 20:10 -------
Confirmed for AVR. GCC 4.2.1 for avr generates this:

foo:
/* prologue: frame size=0 */
        push r14
        push r15
        push r16
        push r17
/* prologue end (size=4) */
        movw r14,r22
        movw r16,r24
        sub r14,r18
        sbc r15,r19
        sbc r16,r20
        sbc r17,r21
        cp r22,r18
        cpc r23,r19
        cpc r24,r20
        cpc r25,r21
        brsh .L2
        ldi r24,lo8(100)
        ldi r25,hi8(100)
        ldi r26,hlo8(100)
        ldi r27,hhi8(100)
        add r14,r24
        adc r15,r25
        adc r16,r26
        adc r17,r27
.L2:
        movw r24,r16
        movw r22,r14
/* epilogue: frame size=0 */
        pop r17
        pop r16
        pop r15
        pop r14
        ret

Ideally it should be something like:

foo:
/* prologue: frame size=0 */
        sub r22,r18
        sbc r23,r19
        sbc r24,r20
        sbc r25,r21
        brcc .L2
        ldi r18,lo8(100)
        ldi r19,hi8(100)
        ldi r20,hlo8(100)
        ldi r21,hhi8(100)
        add r22,r18
        adc r23,r19
        adc r24,r20
        adc r25,r21
.L2:
/* epilogue: frame size=0 */
        ret

Which is less than half the number of instructions.

Changing summary and target fields


-- 

eweddington at cso dot atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|i386-linux, powerpc-*-*     |i386-linux, powerpc-*-*,
                   |                            |avr-*-*
   Last reconfirmed|2006-03-05 03:13:08         |2007-08-23 20:10:25
               date|                            |
            Summary|appalling optimisation with |appalling optimisation with
                   |sub/cmp on i386             |sub/cmp on multiple targets


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


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