diff mbox

RFC: PR rtl-optimization/47958: [x32] reload generates invalid address reference

Message ID 20110302195830.GA27769@intel.com
State New
Headers show

Commit Message

H.J. Lu March 2, 2011, 7:58 p.m. UTC
On Wed, Mar 02, 2011 at 09:29:21AM -0800, H.J. Lu wrote:
> Hi,
> 
> When we force a symbol reference in the constant pool, it should be
> in ptr_mode even if symbol is in Pmode.  This patch does it.  Does
> it make any senses?
> 

Reload should put symbol reference in the constant pool in proper
mode.  I am testing this patch instead.


H.J.
---
diff mbox

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 497866d..a3b7364 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,9 @@ 
+2011-03-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR rtl-optimization/47958
+	* reload.c (find_reloads): Put symbol reference in memory
+	in ptr_mode.
+
 2011-03-01  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47744
diff --git a/gcc/reload.c b/gcc/reload.c
index 714355c3..bf6101f 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -3918,7 +3918,18 @@  find_reloads (rtx insn, int replace, int ind_levels, int live_known,
 	    && mode != VOIDmode)
 	  {
 	    int this_address_reloaded;
-	    rtx tem = force_const_mem (mode, op);
+	    rtx tem;
+	    
+	    /* Symbol reference in the constant pool must be in
+	       ptr_mode.  */
+	    if (subreg != NULL_RTX
+		&& plus == NULL_RTX
+		&& Pmode != ptr_mode
+		&& GET_MODE (subreg) == ptr_mode
+		&& GET_CODE (op) == SYMBOL_REF)
+	      tem = force_const_mem (ptr_mode, op);
+	    else
+	      tem = force_const_mem (mode, op);
 
 	    /* If we stripped a SUBREG or a PLUS above add it back.  */
 	    if (plus != NULL_RTX)
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index c57f5ca..22345df 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,8 @@ 
+2011-03-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR rtl-optimization/47958
+	* gcc.dg/torture/pr47958-1.c: New.
+
 2011-03-01  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47744
diff --git a/gcc/testsuite/gcc.dg/torture/pr47958-1.c b/gcc/testsuite/gcc.dg/torture/pr47958-1.c
new file mode 100644
index 0000000..9fdf142
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47958-1.c
@@ -0,0 +1,13 @@ 
+/* { dg-do assemble } */
+
+void (*foo[6][6]) (int);
+void bar (hdR)
+    int hdR;
+{ }
+void xxx ()
+{
+    unsigned int i, j;
+    for (i = 0; i < 6; ++i)
+	for (j = 0; j < 6; ++j)
+            foo [i][j] = bar;
+}