From cebc182b78fd3be5396fb772f3b12a9096fc73ab Mon Sep 17 00:00:00 2001
From: Oleg Endo <oleg.endo@t-online.de>
Date: Tue, 29 Nov 2011 22:52:55 +0000
Subject: [PATCH] re PR target/51337 (SH Target: Various testsuite ICEs for
 -m2a -O0)

	PR target/51337
	* config/sh/sh.c (sh_secondary_reload): Add case when FPUL
	register is being loaded from a pseudo in memory.

From-SVN: r181823
---
 gcc/ChangeLog      | 6 ++++++
 gcc/config/sh/sh.c | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6ac5db9183f8..587a627ce061 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2011-11-29  Oleg Endo  <oleg.endo@t-online.de>
+
+	PR target/51337
+	* config/sh/sh.c (sh_secondary_reload): Add case when FPUL
+	register is being loaded from a pseudo in memory.
+
 2011-11-29  DJ Delorie  <dj@redhat.com>
 
 	* config.gcc (rl78-*-elf): New case.
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 2545a63e7244..870c39f2602b 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -12432,6 +12432,14 @@ sh_secondary_reload (bool in_p, rtx x, reg_class_t rclass_i,
   if (rclass != GENERAL_REGS && REG_P (x)
       && TARGET_REGISTER_P (REGNO (x)))
     return GENERAL_REGS;
+
+ /* If here fall back to loading FPUL register through general registers.
+    This case can happen when movsi_ie insn is picked initially to
+    load/store the FPUL register from/to another register, and then the
+    other register is allocated on the stack.  */
+  if (rclass == FPUL_REGS && true_regnum (x) == -1)
+    return GENERAL_REGS;
+
   return NO_REGS;
 }
 
-- 
GitLab