Patchwork [x32] PATCH: [x32] internal compiler error: in simplify_subreg, at simplify-rtx.c:5222

login
register
mail settings
Submitter H.J. Lu
Date Jan. 20, 2011, 1:47 p.m.
Message ID <20110120134722.GA24378@intel.com>
Download mbox | patch
Permalink /patch/79695/
State New
Headers show

Comments

H.J. Lu - Jan. 20, 2011, 1:47 p.m.
Hi,

I checked in this patch to fix ix86_delegitimize_address for x32 PIC.

H.J.
---
commit f22fcddbd05fccd7233e499bc32837427deb429d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 20 05:43:51 2011 -0800

    Fix ix86_delegitimize_address for x32 PIC
    
    Call simplify_gen_subreg for PIC with ptr_mode only if modes of x
    and orig_x are different.

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 0bb8e16..e41f4f5 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,10 @@ 
+2011-01-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/47372
+	* config/i386/i386.c (ix86_delegitimize_address): Call
+	simplify_gen_subreg for PIC with ptr_mode only if modes of
+	x and orig_x are different.
+
 2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47369
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index c3642e4..b57b4c6 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13269,9 +13269,10 @@  ix86_delegitimize_address (rtx x)
 	  || !MEM_P (orig_x))
 	return ix86_delegitimize_tls_address (orig_x);
       x = XVECEXP (XEXP (x, 0), 0, 0);
-      if (GET_MODE (orig_x) != Pmode)
+      if (GET_MODE (orig_x) != GET_MODE (x) 
+	  && GET_MODE (orig_x) != ptr_mode)
 	{
-	  x = simplify_gen_subreg (GET_MODE (orig_x), x, Pmode, 0);
+	  x = simplify_gen_subreg (GET_MODE (orig_x), x, ptr_mode, 0);
 	  if (x == NULL_RTX)
 	    return orig_x;
 	}
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index 79ac672..9184dbe 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,9 @@ 
+2011-01-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/47372
+	* gcc.target/i386/pr47372-1.c: New.
+	* gcc.target/i386/pr47372-2.c: Likewise.
+
 2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47369
diff --git a/gcc/testsuite/gcc.target/i386/pr47372-1.c b/gcc/testsuite/gcc.target/i386/pr47372-1.c
new file mode 100644
index 0000000..a2e5c5b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr47372-1.c
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-O2 -fPIC -g" } */
+
+typedef struct FILE FILE;
+int _fwalk(int (*)(FILE *));
+int __sflush(FILE *);
+int
+fflush(FILE *fp)
+{
+  return (_fwalk(__sflush));
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr47372-2.c b/gcc/testsuite/gcc.target/i386/pr47372-2.c
new file mode 100644
index 0000000..8addcdc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr47372-2.c
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-O2 -fPIC -g" } */
+
+typedef unsigned short ush;
+typedef ush Pos;
+extern ush prev[];
+void fill_window( unsigned more, unsigned m)
+{
+    unsigned n;
+    for (n = 0; n < (unsigned)(1<<15); n++) {
+      (prev+0x8000)[n] = (Pos)(m >= 0x8000 ? m-0x8000 : 0);
+    }
+    for (n = 0; n < 0x8000; n++) {
+      prev[n] = (Pos)(m >= 0x8000 ? m-0x8000 : 0);
+    }
+}