Code:
#include <avr/io.h>
register uint8_t test asm("r2");
int main(void)
{
test = TCNT0;
}
Compiled with -Os results in the following instruction sequence:
00000092 <main>:
92: 82 b7 in r24, 0x32 ; 50
94: 28 2e mov r2, r24
96: 08 95 ret
This is particularly nasty for naked interrupts, where one would expect the
compiler to generate just a single instruction:
in r2, 0x32
Apparently the compiler behaves correctly when opposite transfer is requested,
generating single OUT opcode.
--
Summary: [avr] missed optimisation with IO read and register
variables
Product: gcc
Version: 4.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: k dot kosciuszkiewicz+gcc at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39510