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:
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