Test gcc.c-torture/execute/memcpy-bi.c (-O2) failed for attiny40 device.
Cause seems to be in "load from memory" as it is not restoring base
register after load instructions generated.

Function avr_out_load_psi_reg_no_disp_tiny in avr.c:
It returns just after emitting instructions to load from memory to 
registers. It is important to restore the base register if it is 
not marked dead/unused after that insn.

Code to restore base register is present already. Below patch let 
the function do the restore before return.

If OK, could someone commit? I do not have commit access.

diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 4e83de8..b653858 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -4365,9 +4365,9 @@ avr_out_load_psi_reg_no_disp_tiny (rtx insn, rtx *op, int 
*plen)
     }
   else
     {
-      return avr_asm_len ("ld %A0,%1+"  CR_TAB
-                          "ld %B0,%1+"  CR_TAB
-                          "ld %C0,%1", op, plen, -3);
+      avr_asm_len ("ld %A0,%1+"  CR_TAB
+                   "ld %B0,%1+"  CR_TAB
+                   "ld %C0,%1", op, plen, -3);
 
       if (reg_dest != reg_base - 2 &&
           !reg_unused_after (insn, base))

Regards,
Pitchumani

gcc/ChangeLog
2015-05-19  Pitchumani Sivanupandi  <pitchuman...@atmel.com>

    * config/avr/avr.c (avr_out_load_psi_reg_no_disp_tiny): Restore base
        register if not marked dead/unused, before return.

Reply via email to