This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch committed] SH: Fix PR target/31701
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 28 Apr 2007 09:08:14 +0900 (JST)
- Subject: [patch committed] SH: Fix PR target/31701
Hi,
I've applied the attached patch for SH on trunk.
PR target/31701 is a wrong-code problem which is a 4.1/4.2/4.3
regression. sh.c:output_stack_adjust tries to find a register
for a constant to unwind the frame and wrongly finds a frame
register itself in the problematic case. This patch is to
avoid it. When looking into this issue, I've also found that
a fallback code in output_stack_adjust may cause an ICE with
a check in flow.c. The second hunk of the patch is to fix it.
The patch is tested with bootstrap and regtested with the top
level "make -k check" on sh4-unknown-linux-gnu.
Regards,
kaz
--
2007-04-27 Kaz Kojima <kkojima@gcc.gnu.org>
PR target/31701
* config/sh/sh.c (output_stack_adjust): Avoid using the frame
register itself to hold the offset constant. Tell flow the use
of r4 and r5 when they are used.
diff -uprN ORIG/trunk/gcc/config/sh/sh.c LOCAL/trunk/gcc/config/sh/sh.c
--- ORIG/trunk/gcc/config/sh/sh.c 2007-03-22 09:50:40.000000000 +0900
+++ LOCAL/trunk/gcc/config/sh/sh.c 2007-04-26 08:06:16.000000000 +0900
@@ -5619,7 +5619,13 @@ output_stack_adjust (int size, rtx reg,
temp = scavenge_reg (&temps);
}
if (temp < 0 && live_regs_mask)
- temp = scavenge_reg (live_regs_mask);
+ {
+ HARD_REG_SET temps;
+
+ COPY_HARD_REG_SET (temps, *live_regs_mask);
+ CLEAR_HARD_REG_BIT (temps, REGNO (reg));
+ temp = scavenge_reg (&temps);
+ }
if (temp < 0)
{
rtx adj_reg, tmp_reg, mem;
@@ -5668,6 +5674,9 @@ output_stack_adjust (int size, rtx reg,
emit_move_insn (adj_reg, mem);
mem = gen_tmp_stack_mem (Pmode, gen_rtx_POST_INC (Pmode, reg));
emit_move_insn (tmp_reg, mem);
+ /* Tell flow the insns that pop r4/r5 aren't dead. */
+ emit_insn (gen_rtx_USE (VOIDmode, tmp_reg));
+ emit_insn (gen_rtx_USE (VOIDmode, adj_reg));
return;
}
const_reg = gen_rtx_REG (GET_MODE (reg), temp);