[avr,applied] Take into account -mtiny-stack in frame pointer adjustments

Message ID 4aabc854-dacc-4c24-adae-96e03d850713@gjlay.de
State Corrupt patch
Headers
Series [avr,applied] Take into account -mtiny-stack in frame pointer adjustments |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Georg-Johann Lay March 2, 2024, 9:18 a.m. UTC
  Applied this addendum to avr PR114100:

When the frame pointer is adjusted and -mtiny-stack is set,
then it is enough to adjust the low part of the frame pointer.

Johann

--

AVR: target/114100 - Factor in -mtiny-stack in frame pointer adjustments

gcc/
         PR target/114100
         * config/avr/avr.cc (avr_out_plus_1) [-mtiny-stack]: Only adjust
         the low part of the frame pointer with 8-bit stack pointer.
  

Patch

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 94ef7c591a9..d39d6707c97 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -8983,14 +8983,17 @@  avr_out_plus_1 (rtx *xop, int *plen, enum 
rtx_code code, int *pcc,
           && frame_pointer_needed
           && REGNO (xop[0]) == FRAME_POINTER_REGNUM)
         {
-         rtx xval16 = simplify_gen_subreg (HImode, xval, imode, i);
-         if (xval16 == const1_rtx || xval16 == constm1_rtx)
+         if (AVR_HAVE_8BIT_SP)
+           {
+             avr_asm_len ("subi %A0,%n2", xop, plen, 1);
+             return;
+           }
+         else if (xop[2] == const1_rtx || xop[2] == constm1_rtx)
             {
-             avr_asm_len ((code == PLUS) == (xval16 == const1_rtx)
+             avr_asm_len (xop[2] == const1_rtx
                            ? "ld __tmp_reg__,%a0+"
                            : "ld __tmp_reg__,-%a0", xop, plen, 1);
-             i++;
-             continue;
+             return;
             }
         }