[Top][All Lists]

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

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

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Generating code using sbis, sbic
Date: Thu, 18 Aug 2005 23:28:06 +0200 (MET DST)

"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. ;-)

reply via email to

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