From 193273638fffd7a53434e11b28f817015aac9cc4 Mon Sep 17 00:00:00 2001 From: Georg-Johann Lay Date: Mon, 28 Nov 2016 09:28:45 +0000 Subject: [PATCH] avr.c (out_movhi_r_mr): Only SBIW if X is not unused after. * config/avr/avr.c (out_movhi_r_mr) [REG_X + PLUS]: Only SBIW if X is not unused after. From-SVN: r242909 --- gcc/ChangeLog | 5 +++++ gcc/config/avr/avr.c | 26 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5b8913f811d..0c09fb0d19b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-11-28 Georg-Johann Lay + + * config/avr/avr.c (out_movhi_r_mr) [REG_X + PLUS]: Only SBIW if + X is not unused after. + 2016-11-28 Bernd Schmidt PR rtl-optimization/78120 diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index ba00147c5fd..d0c54c2458c 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -4028,16 +4028,22 @@ out_movhi_r_mr (rtx_insn *insn, rtx op[], int *plen) optimization options. */ if (reg_base == REG_X) - return reg_base == reg_dest - ? avr_asm_len ("adiw r26,%o1" CR_TAB - "ld __tmp_reg__,X+" CR_TAB - "ld %B0,X" CR_TAB - "mov %A0,__tmp_reg__", op, plen, -4) - - : avr_asm_len ("adiw r26,%o1" CR_TAB - "ld %A0,X+" CR_TAB - "ld %B0,X" CR_TAB - "sbiw r26,%o1+1", op, plen, -4); + { + if (reg_base == reg_dest) + return avr_asm_len ("adiw r26,%o1" CR_TAB + "ld __tmp_reg__,X+" CR_TAB + "ld %B0,X" CR_TAB + "mov %A0,__tmp_reg__", op, plen, -4); + + avr_asm_len ("adiw r26,%o1" CR_TAB + "ld %A0,X+" CR_TAB + "ld %B0,X", op, plen, -3); + + if (!reg_unused_after (insn, XEXP (base, 0))) + avr_asm_len ("sbiw r26,%o1+1", op, plen, 1); + + return ""; + } return reg_base == reg_dest ? avr_asm_len ("ldd __tmp_reg__,%A1" CR_TAB -- 2.30.2