Small frame sizes are realized by a sequence of RCALL . + PUSH tmp_reg
like:
push r28
push r29
;; SP -= 4
rcall .
push __tmp_reg__
in r28, __SP_L__
in r29, __SP_H__
This patch tightens the prologue_saves condition such that it is
only used when its invokation is shorter than the sequence above.
Ok for trunk?
Johann
--
gcc/
* config/avr/avr.cc (avr_prologue_setup_frame): Tighten
condition for when prologue_saves is used.
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 58cd25b60a7..f6aef849bd3 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -1544,8 +1544,14 @@ avr_prologue_setup_frame (HOST_WIDE_INT size,
HARD_REG_SET set)
&& !isr_p
&& !AVR_TINY);
+ // Small frame sizes can be realized by RCALL . + PUSH tmp_reg. Get the
+ // respective insn count, and only use prologue_saves when it is
profitable.
+ const int pc_size = AVR_2_BYTE_PC ? 2 : 3;
+ const int n_insns = 2 + live_seq + size / pc_size + size % pc_size;
+ const int n_mini_insns = 5 + AVR_HAVE_JMP_CALL;
+
if (minimize
- && (frame_pointer_needed
+ && ((frame_pointer_needed && n_mini_insns < n_insns)
|| avr_outgoing_args_size () > 8
|| (AVR_2_BYTE_PC && live_seq > 6)
|| live_seq > 7))