Patchwork [x32] PATCH: PR target/47369: [x32] internal compiler error: in extract_insn, at recog.c:2109

login
register
mail settings
Submitter H.J. Lu
Date Jan. 20, 2011, 2:26 a.m.
Message ID <20110120022612.GA19624@intel.com>
Download mbox | patch
Permalink /patch/79634/
State New
Headers show

Comments

H.J. Lu - Jan. 20, 2011, 2:26 a.m.
Hi,

I checkecd in this patch to allow ptr_mode for symbolic operand with
PIC.

H.J.
---
commit 528d930544c6819f58267dda5ec54b051585caa1
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jan 19 18:23:34 2011 -0800

    Allow ptr_mode for symbolic operand with PIC.

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 36ac432..0bb8e16 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,5 +1,11 @@ 
 2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>
 
+	PR target/47369
+	* config/i386/i386.c (ix86_expand_move): Allow ptr_mode for
+	symbolic operand with PIC.
+
+2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>
+
 	PR target/47364
 	* builtins.c (expand_builtin_strlen): Convert to Pmode if PAT
 	isn't in Pmode.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 55732de..c3642e4 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -15323,7 +15323,8 @@  ix86_expand_move (enum machine_mode mode, rtx operands[])
     }
 
   if ((flag_pic || MACHOPIC_INDIRECT) 
-       && mode == Pmode && symbolic_operand (op1, Pmode))
+       && (mode == Pmode || mode == ptr_mode)
+       && symbolic_operand (op1, mode))
     {
       if (TARGET_MACHO && !TARGET_64BIT)
 	{
@@ -15364,13 +15365,15 @@  ix86_expand_move (enum machine_mode mode, rtx operands[])
       else
 	{
 	  if (MEM_P (op0))
-	    op1 = force_reg (Pmode, op1);
-	  else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, Pmode))
+	    op1 = force_reg (mode, op1);
+	  else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, mode))
 	    {
 	      rtx reg = can_create_pseudo_p () ? NULL_RTX : op0;
 	      op1 = legitimize_pic_address (op1, reg);
 	      if (op0 == op1)
 		return;
+	      if (GET_MODE (op1) != mode)
+		op1 = convert_to_mode (mode, op1, 1);
 	    }
 	}
     }
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index 4b1e5f8..79ac672 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,5 +1,10 @@ 
 2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>
 
+	PR target/47369
+	* gcc.target/i386/pr47369-1.c: New.
+
+2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>
+
 	PR target/47364
 	* gcc.target/i386/pr47364-2.c: New.
 
diff --git a/gcc/testsuite/gcc.target/i386/pr47369-1.c b/gcc/testsuite/gcc.target/i386/pr47369-1.c
new file mode 100644
index 0000000..117b03b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr47369-1.c
@@ -0,0 +1,13 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-O2 -fPIC" } */
+
+struct FILE
+{
+  int x;
+};
+extern struct FILE __sF[];
+extern void bar (struct FILE *);
+void dlmalloc_stats() {
+   bar ((&__sF[2]));
+}