[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Why doesn't gcc optimize this better?

From: Tvrtko A. Ursulin
Subject: [avr-gcc-list] Why doesn't gcc optimize this better?
Date: Sat, 8 Feb 2003 09:02:04 +0100
User-agent: KMail/1.4.3


GCC 3.2 makes the following code:

        if ( system.timer_active )
 766:   c0 90 90 00     lds     r12, 0x0090             // CASE1
 76a:   cc 20           and     r12, r12
 76c:   81 f1           breq    .+96            ; 0x7ce
                uint8_t active = 0;
 76e:   cc 24           eor     r12, r12
                uint8_t idx = MAX_TIMERS;
 770:   b2 e0           ldi     r27, 0x02       ; 2
 772:   db 2e           mov     r13, r27
                struct timer    *p = (struct timer *)&system.timer[0]; //CASE2
 774:   ab e7           ldi     r26, 0x7B       ; 123
 776:   ea 2e           mov     r14, r26
 778:   a0 e0           ldi     r26, 0x00       ; 0
 77a:   fa 2e           mov     r15, r26
 77c:   26 e1           ldi     r18, 0x16       ; 22
 77e:   30 e0           ldi     r19, 0x00       ; 0
 780:   e2 0e           add     r14, r18
 782:   f3 1e           adc     r15, r19

Why can't it optimize CASE2 to a address that is known at compile time? 
Because I think it is known at compile time just like CASE1.

The "system" is like this

struct system
        uint8_t         blah;
        uint8_t         foo_active;
        struct foo      foo[3[;
        uint8_t         timer_active;
        struct timer    timer[2];

reply via email to

[Prev in Thread] Current Thread [Next in Thread]