Paul Stoffregen <p...@pjrc.com> wrote:

> Indeed it works great with -O2.  But with -Os, __builtin_constant_p
> never returns 1.

It appears to me GCC simply thinks inlining the function would not be
feasible with -Os -- well, partially at least.  If you declare your
function as

static inline void __attribute__((always_inline))
digitalWrite(uint8_t pin, uint8_t val)

(thus overriding GCC's heuristics about inlining), it yields your
desired result:

main:
/* prologue: function */
/* frame size = 0 */
        sbi 43-32,2
        lds r24,num
        ldi r22,lo8(1)
        call _digitalWrite
        sbi 43-32,2
..L2:
        rjmp .L2

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to