diff mbox

[committed,SH] Fix PR target/65249

Message ID 20150716.095001.362239688.kkojima@rr.iij4u.or.jp
State New
Headers show

Commit Message

Kaz Kojima July 16, 2015, 12:50 a.m. UTC
I've committed the attached patch to fix PR target/65249.  The patch
reduces R0-register pressure for the problematic situation and fixes
the ICE reported in PR65249 with -mno-lra.  It gives a bit better code
for the test case of that PR with -mlra too.
Tested with sh4-unknown-linux-gnu.  I'll backport it to 4.9 later and
to 5 when it reopens.

Regards,
	kaz
--
2015-07-16  Kaz Kojima  <kkojima@gcc.gnu.org>

	PR target/65249
	* config/sh/sh.md (movdi): Split simple reg move to two movsi
	when the destination is R0.
diff mbox

Patch

diff --git a/config/sh/sh.md b/config/sh/sh.md
index f0cb3cf..61f6637 100644
--- a/config/sh/sh.md
+++ b/config/sh/sh.md
@@ -7892,6 +7892,24 @@  label:
   ""
 {
   prepare_move_operands (operands, DImode);
+  if (TARGET_SH1)
+    {
+      /* When the dest operand is (R0, R1) register pair, split it to
+	 two movsi of which dest is R1 and R0 so as to lower R0-register
+	 pressure on the first movsi.  Apply only for simple source not
+	 to make complex rtl here.  */
+      if (REG_P (operands[0])
+	  && REGNO (operands[0]) == R0_REG
+	  && REG_P (operands[1])
+	  && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
+	{
+	  emit_insn (gen_movsi (gen_rtx_REG (SImode, R1_REG),
+			        gen_rtx_SUBREG (SImode, operands[1], 4)));
+	  emit_insn (gen_movsi (gen_rtx_REG (SImode, R0_REG),
+			        gen_rtx_SUBREG (SImode, operands[1], 0)));
+	  DONE;
+	}
+    }
 })
 
 (define_insn "movdf_media"