summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-16 10:16:15 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-16 10:16:15 +0000
commit8a72adf497f11f1a7c8c49583699d1339f59b8c7 (patch)
tree24148aafcfc6b92104799dde10993008c3662278 /gcc
parenta86a1d8bc148960f6534efd6f4920551ada443b6 (diff)
downloadgcc-8a72adf497f11f1a7c8c49583699d1339f59b8c7.tar.gz
gcc/
PR middle-end/32897 * reload.c (find_reloads): Check that the memory returned by find_reloads_toplev was not the result of forcing a constant to memory. (find_reloads_toplev): Always use simplify_gen_subreg to get the subreg of a constant. If the result is also a constant, but not a legitimate one, force it into the constant pool and reload its address. gcc/testsuite/ * gcc.dg/torture/pr32897.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127536 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/reload.c20
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr32897.c27
4 files changed, 53 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0629abd9302..2a5d7f5c922 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2007-08-16 Richard Sandiford <richard@codesourcery.com>
+
+ PR middle-end/32897
+ * reload.c (find_reloads): Check that the memory returned by
+ find_reloads_toplev was not the result of forcing a constant
+ to memory.
+ (find_reloads_toplev): Always use simplify_gen_subreg to get
+ the subreg of a constant. If the result is also a constant,
+ but not a legitimate one, force it into the constant pool
+ and reload its address.
+
2007-08-15 David Edelsohn <edelsohn@gnu.org>
* config/rs6000/rs6000.c (rs6000_rtx_costs): Add CLZ, CTZ, and
diff --git a/gcc/reload.c b/gcc/reload.c
index ae913bf094f..06ce96bfd38 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -2794,7 +2794,8 @@ find_reloads (rtx insn, int replace, int ind_levels, int live_known,
&& MEM_P (op)
&& REG_P (reg)
&& (GET_MODE_SIZE (GET_MODE (reg))
- >= GET_MODE_SIZE (GET_MODE (op))))
+ >= GET_MODE_SIZE (GET_MODE (op)))
+ && reg_equiv_constant[REGNO (reg)] == 0)
set_unique_reg_note (emit_insn_before (gen_rtx_USE (VOIDmode, reg),
insn),
REG_EQUAL, reg_equiv_memory_loc[REGNO (reg)]);
@@ -4600,14 +4601,6 @@ find_reloads_toplev (rtx x, int opnum, enum reload_type type,
int regno = REGNO (SUBREG_REG (x));
rtx tem;
- if (subreg_lowpart_p (x)
- && regno >= FIRST_PSEUDO_REGISTER
- && reg_renumber[regno] < 0
- && reg_equiv_constant[regno] != 0
- && (tem = gen_lowpart_common (GET_MODE (x),
- reg_equiv_constant[regno])) != 0)
- return tem;
-
if (regno >= FIRST_PSEUDO_REGISTER
&& reg_renumber[regno] < 0
&& reg_equiv_constant[regno] != 0)
@@ -4616,6 +4609,15 @@ find_reloads_toplev (rtx x, int opnum, enum reload_type type,
simplify_gen_subreg (GET_MODE (x), reg_equiv_constant[regno],
GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x));
gcc_assert (tem);
+ if (CONSTANT_P (tem) && !LEGITIMATE_CONSTANT_P (tem))
+ {
+ tem = force_const_mem (GET_MODE (x), tem);
+ i = find_reloads_address (GET_MODE (tem), &tem, XEXP (tem, 0),
+ &XEXP (tem, 0), opnum, type,
+ ind_levels, insn);
+ if (address_reloaded)
+ *address_reloaded = i;
+ }
return tem;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 14e58c9b42a..0b79ae97313 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2007-08-16 Richard Sandiford <richard@codesourcery.com>
+
+ * gcc.dg/torture/pr32897.c: New test.
+
2007-08-16 Paolo Carlini <pcarlini@suse.de>
PR c++/31132
diff --git a/gcc/testsuite/gcc.dg/torture/pr32897.c b/gcc/testsuite/gcc.dg/torture/pr32897.c
new file mode 100644
index 00000000000..3dc43ece058
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr32897.c
@@ -0,0 +1,27 @@
+/* { dg-options "-G0" { target mips*-*-* } } */
+
+volatile int g[32];
+long long gll;
+double gd;
+
+#define MULTI(X) \
+ X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), X(10), \
+ X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19), X(20), \
+ X(21), X(22), X(23), X(24), X(25), X(26), X(27), X(28), X(29), X(30)
+
+#define DECLARE(INDEX) x##INDEX
+#define COPY_IN(INDEX) x##INDEX = g[INDEX]
+#define COPY_OUT(INDEX) g[INDEX] = x##INDEX
+
+void
+test (int n)
+{
+ union { long long l; double d; } u = { 0x12345678 };
+ gll = u.l;
+ int MULTI (DECLARE);
+ MULTI (COPY_IN);
+ MULTI (COPY_OUT);
+ MULTI (COPY_OUT);
+ MULTI (COPY_OUT);
+ gd = u.d;
+}