This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch,avr] PR70677: Use -fno-caller-saves for avr
- From: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- To: Denis Chertykov <chertykov at gmail dot com>
- Cc: Georg-Johann Lay <avr at gjlay dot de>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Vladimir Makarov <vmakarov at redhat dot com>
- Date: Tue, 2 Aug 2016 10:20:10 +0530
- Subject: Re: [patch,avr] PR70677: Use -fno-caller-saves for avr
- Authentication-results: sourceware.org; auth=none
- References: <7ab58607-7e60-b4ba-1a76-88f2cc26b41c@gjlay.de> <CADOs=zYfvA1h-J85UjJhnQW=Y7XQkOXuYyhY2RfqxtFxKWju1g@mail.gmail.com>
Denis Chertykov writes:
> 2016-08-01 15:17 GMT+03:00 Georg-Johann Lay <avr@gjlay.de>:
>> Problem with -fcaller-saves is that there are situations where it triggers
>> an expensive frame just to store a variable around a function call even
>> though there are plenty of call-saved registers.
>>
>> Example:
>>
>> typedef __UINT8_TYPE__ uint8_t;
>>
>> extern uint8_t uart0_getc (void);
>>
>> void foo (uint8_t *buffer, uint8_t cnt)
>> {
>> while (--cnt)
>> {
>> *buffer++ = uart0_getc();
>> }
>> }
>>
>> $ avr-gcc -Os -S -dp -mmcu=atmega8 loop-buf.c
>>
>> $ avr-gcc gcc -B$TV -Os -c -save-temps -dp -mmcu=atmega8 loop-buf.c &&
>> avr-size loop-buf.o
>> text data bss dec hex filename
>> 50 0 0 50 32 loop-buf.o
>>
>> $ avr-gcc -Os -c -save-temps -dp -mmcu=atmega8 loop-buf.c -fno-caller-saves
>> && avr-size loop-buf.o
>> text data bss dec hex filename
>> 32 0 0 32 20 loop-buf.o
>>
>> I actually came never across a situation where -fcaller-saves improved the
>> code performance, hence this patch proposes to switch off -fcaller-saved per
>> default.
Like you mentioned in the bug report, would fixing the costs be a better
way to fix this rather than a blanket disabling of the option?
Regards
Senthil