As Ian Lance Taylor wrote: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31528
> The relevant code is in opts.c: > if (optimize_size) > { > /* Inlining of very small functions usually reduces total size. */ > set_param_value ("max-inline-insns-single", 5); > set_param_value ("max-inline-insns-auto", 5); > flag_inline_functions = 1; > Inlining has changed considerably since then, and it is possible > that these parameter values are no longer appropriate. The reports > at the time indicate space savings. Thanks for telling me where to look for it, Ian! It's really appreciated. I made a first attempt on lowering max-inline-insns-auto from 5 to 3. I did some initial testing (using the C program and shell script in the attachment), on a recent GCC tree built for both, the AVR target as well as my host's native i386 target. This appears to be at a break-even to me: Conditions -Os -Os -fno-inline target=avr, N=1, GETX= CONST_ARG: 22 26 target=i386, N=1, GETX= CONST_ARG: 38 54 target=avr, N=1, GETX= function: 40 42 target=i386, N=1, GETX= function: 53 69 target=avr, N=2, GETX= CONST_ARG: 30 30 target=i386, N=2, GETX= CONST_ARG: 64 64 target=avr, N=2, GETX= function: 50 48 target=i386, N=2, GETX= function: 79 80 target=avr, N=3, GETX= CONST_ARG: 34 34 target=i386, N=3, GETX= CONST_ARG: 74 74 target=avr, N=3, GETX= function: 54 52 target=i386, N=3, GETX= function: 86 87 target=avr, N=4, GETX= CONST_ARG: 38 38 target=i386, N=4, GETX= CONST_ARG: 84 84 target=avr, N=4, GETX= function: 58 56 target=i386, N=4, GETX= function: 93 94 target=avr, N=5, GETX= CONST_ARG: 42 42 target=i386, N=5, GETX= CONST_ARG: 94 94 target=avr, N=5, GETX= function: 62 60 target=i386, N=5, GETX= function: 100 101 For only a single invocation, obviously, running with -fno-inline will always yield larger code (albeit the difference is much less on the AVR than on the i386). For multiple invocations, both architectures are neutral to the -fno-inline option when invocation the function to be inlined with a constant argument. If instead the argument is another function (possibly to be inlined), both architectures behave differently: the AVR wins one instruction (two bytes) when not inlining, the i386 wins one instruction when inlining. The "getx()" function was a silly attempt to mimic the typical C++ access methods mentioned without really using C++. This indicates using 3 instead of 5 might be a much more sane default. What's that test suite that has been mentioned here, and how to run it? -- cheers, J"org .-.-. --... ...-- -.. . DL8DTL http://www.sax.de/~joerg/ NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)
#define UCSRA (*(volatile unsigned char *)0x2B) #define UDRE 5 #define UDR (*(volatile unsigned char *)0x2C) static void putch(char ch); void putch(char ch) { while (!(UCSRA & (1<<UDRE))); UDR = ch; } #if CONST_ARG # define GETX() 42 #else static char x; char getx(void) { return x; } #define GETX() getx() #endif int main(void) { putch(GETX()); #if N > 1 putch(GETX()); # if N > 2 putch(GETX()); # if N > 3 putch(GETX()); # if N > 4 putch(GETX()); # endif # endif # endif #endif return 0; }
run.sh
Description: Bourne shell script