[Top][All Lists]

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

Re: [avr-gcc-list] __builtin_constant_p for inline func args with -Os

From: Paul Stoffregen
Subject: Re: [avr-gcc-list] __builtin_constant_p for inline func args with -Os
Date: Sun, 08 Nov 2009 13:04:48 -0800
User-agent: Thunderbird (X11/20090817)

Thanks!  That works perfectly.  :-)

I was totally misunderstanding the problem. Just one little attribute, but it's a huge help.

Thanks again.


Joerg Wunsch wrote:
Paul Stoffregen <address@hidden> 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:

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

reply via email to

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