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/34791] [avr] optimisation of 8-bit logic sometimes fails


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|avr-*-*                     |avr
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-10-09 20:40:51 UTC ---
Compiled the following code from commant #0 and commant #1 with avr-gcc 4.7
(SVN 179594)

#define uint8_t unsigned char
#define PORTC (*((uint8_t volatile*) 0x28))

extern uint8_t data[64];

uint8_t bar(uint8_t x, uint8_t y) {
    return data[y ^ (x & 0x0f)];
}

uint8_t bar2(uint8_t x, uint8_t y) {
    return data[(y ^ x) & 0x0f];
}

void foo(void) {
    static unsigned char count;

    if (++count & 0x3f) {
        PORTC &= ~0x01;
    } else {
        PORTC |= 0x01;
    }
}

With -Os -dp yields the following result:

bar:
    andi r24,lo8(15)
    eor r24,r22
    mov r30,r24
    ldi r31,lo8(0)
    subi r30,lo8(-(data))
    sbci r31,hi8(-(data))
    ld r24,Z
    ret

bar2:
    eor r22,r24
    andi r22,lo8(15)
    mov r30,r22
    ldi r31,lo8(0)
    subi r30,lo8(-(data))
    sbci r31,hi8(-(data))
    ld r24,Z
    ret

foo:
    lds r24,count.1232
    subi r24,lo8(-(1))
    sts count.1232,r24
    andi r24,lo8(63)
    breq .L4
    cbi 40-0x20,0
    ret
.L4:
    sbi 40-0x20,0
    ret

Thus, closing this PR as FIXED because the code is optimal and nothing remains
to be improved.


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