[Top][All Lists]

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

AW: [avr-gcc-list] Generating code using sbis, sbic

From: Haase Bjoern (PT-BEU/EMT) *
Subject: AW: [avr-gcc-list] Generating code using sbis, sbic
Date: Fri, 19 Aug 2005 09:36:54 +0200

IIUC 4.x.x does very much the same as 3.x.x . There is one single place pointed 
out by Paul Schlie some time ago where you could switch of the promotion rules, 



-----Ursprüngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im Auftrag von Joerg Wunsch
Gesendet: Donnerstag, 18. August 2005 23:28
An: address@hidden
Betreff: Re: [avr-gcc-list] Generating code using sbis, sbic

"David Brown" <address@hidden> wrote:

> Hardly optimal (does the result really have to be promoted to an
> integer?), but not bad.

That integer promotion is a feature, I remember an explanation from
Marek (long ago).  It has been added so the caller could more easily
use word operations when needed, as he can rely on the callee to
16-bit expand the result.  For that reason, it's much more efficient
to declare a function returning an 8-bit value as `unsigned char'
instead of `char' (which is signed by default in AVR-GCC), as
otherwise the 16-bit promotion would even include a sign extension,
instead of just zeroing r25.

>  The generated code for test1 is extraordinary:

This has recently been discussed and analyzed, I don't remember
exactly where, perhaps it wasn't here but on avrfreaks.net.  Someone
could track it down to a point where any literal 0 returned by a
function triggers this poor optimization behaviour.  This seems to be
the case in your situation as well.  Likewise, if you inline the
function, this disappears immediately, as no real function return
value is needed but instead the compiler can perform the actual
operation that was intented by your function return value immediately

It would be interesting (Björn?) whether GCC 4.x compiled better code
for this.

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

reply via email to

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