diff mbox

[x32] PATCH: PR middle-end/47727: [x32] Many passes can't handle const symbol when Pmode != ptr_mode

Message ID 20110214190430.GA13093@intel.com
State New
Headers show

Commit Message

H.J. Lu Feb. 14, 2011, 7:04 p.m. UTC
Hi,

simplify-rtx emits new instuctions when Pmode != ptr_mode.  This patch
avoids it by permuting the conversion and addition when one operand is a
constant.  Does it make any senses?

Thanks.


H.J.
---
diff mbox

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index d3c2ac7..c8ead38 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,5 +1,11 @@ 
 2011-02-14  H.J. Lu  <hongjiu.lu@intel.com>
 
+	PR middle-end/47727
+	* explow.c (convert_memory_address_addr_space): Permute the
+	conversion and addition if one operand is a constant.
+
+2011-02-14  H.J. Lu  <hongjiu.lu@intel.com>
+
 	PR middle-end/47725
 	* function.c (assign_parm_setup_reg): Copy the hard register
 	first before extending it.
diff --git a/gcc/explow.c b/gcc/explow.c
index 2a18206..593aae3 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -383,18 +383,13 @@  convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
 
     case PLUS:
     case MULT:
-      /* For addition we can safely permute the conversion and addition
-	 operation if one operand is a constant and converting the constant
-	 does not change it or if one operand is a constant and we are
-	 using a ptr_extend instruction  (POINTERS_EXTEND_UNSIGNED < 0).
-	 We can always safely permute them if we are making the address
-	 narrower.  */
+      /* For addition we safely permute the conversion and addition
+	 operation if one operand is a constant since we can't generate
+	 new instructions.  We can always safely permute them if we are
+	 making the address narrower.  */
       if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
 	  || (GET_CODE (x) == PLUS
-	      && CONST_INT_P (XEXP (x, 1))
-	      && (XEXP (x, 1) == convert_memory_address_addr_space
-				   (to_mode, XEXP (x, 1), as)
-                 || POINTERS_EXTEND_UNSIGNED < 0)))
+	      && CONST_INT_P (XEXP (x, 1))))
 	return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
 			       convert_memory_address_addr_space
 				 (to_mode, XEXP (x, 0), as),
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index 0085662..27543f8 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,8 @@ 
+2011-02-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR middle-end/47727
+	* gcc.dg/pr47727.c: New.
+
 2011-02-13  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR middle-end/47725
diff --git a/gcc/testsuite/gcc.dg/pr47727.c b/gcc/testsuite/gcc.dg/pr47727.c
new file mode 100644
index 0000000..1ce7c36
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr47727.c
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef void (*func_ptr) (void);
+static func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
+static void __attribute__((used))
+__do_global_ctors_aux (void)
+{
+  func_ptr *p;
+  for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
+    (*p) ();
+}