avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] useless use of temporary register?


From: Lars Noschinski
Subject: [avr-gcc-list] useless use of temporary register?
Date: Fri, 7 Oct 2005 19:39:10 +0200
User-agent: mutt-ng devel (Linux)

Hello!

I've an register variable declared as follows:

register uint8_t status asm("r16");      /* status register */

so I would expect gcc using this register directly if possible. But this
is often not the case. Is there some optimizaton option or code
trick to get always the latter result?:

status |= 0x10;

is sometimes translated to
mov     r24, r16
ori     r24, 0x10
mov     r16, r24

and sometimes to the more sensible
ori    r16, 0x10

e.g. in:

void useless(void) {
   if (0x10 & status)
       return;
   status |= 0x10;

   if (0x04 & status))
       return;
   asm ("nop");
}

versus

void useless(void) {
   if (0x10 & status)
       return;
   status |= 0x10;
}

(Using gcc 3.4.3 and options as in

avr-gcc -c -mmcu=atmega8 -I. -gstabs+ -DF_CPU=4000000UL  -Os
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall
-Wstrict-prototypes)




reply via email to

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