https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115817

--- Comment #5 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to Dmytro Bagrii from comment #4)
> gcc is smart enough not to initialize R1 when it is not used.
Actually not.  The decision whether __zero_reg__ is required in an ISR is
worked out by the assembler, provided -mgas-isr-prologues is on (which is the
default except for -O0 and -Og).  Without help from the assembler, e.g.
-mno-gas-isr-prologues, avr-gcc will assume that __zero_reg__ as always used
(and that __tmp_reg__ is always clobbered) in a non-naked ISR, see PR20296 /
PR81268.

> I'm curious whether optimizer can make a branch for ISR
> (i.e. __signal__) and check both variants: using EOR R1,R1 and using LDI Rd,0
LDI cannot be used since it only allows R16...R31.

> I guess the decision to use __tmp_reg__ > instead of LDI for zero value
> is made on a stage other than prologue/epilogue generation.
Yes.  That part of prologue / epilogue generation has been implemented in the
assembler, see https://sourceware.org/bugzilla/show_bug.cgi?id=21683. 
Advantage is that it sees though inline asm.

Reply via email to