diff mbox

[avr] Restore base register if not marked dead/unused

Message ID CAC140656783604CABA6AE60C2A6D5A4A265C7A6@penmbx01
State New
Headers show

Commit Message

Sivanupandi, Pitchumani May 19, 2015, 1:04 p.m. UTC
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.


Regards,
Pitchumani

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

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

Comments

Denis Chertykov May 25, 2015, 4:43 p.m. UTC | #1
2015-05-19 16:04 GMT+03:00 Sivanupandi, Pitchumani
<Pitchumani.Sivanupandi@atmel.com>:
> 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  <pitchumani.s@atmel.com>
>
>     * config/avr/avr.c (avr_out_load_psi_reg_no_disp_tiny): Restore base
>         register if not marked dead/unused, before return.
>

Committed.
diff mbox

Patch

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))