diff mbox

[x32] PATCH: PR target/47364: [x32] internal compiler error: in emit_move_insn, at expr.c:3355

Message ID 20110119205501.GA1094@intel.com
State New
Headers show

Commit Message

H.J. Lu Jan. 19, 2011, 8:55 p.m. UTC
ix86_legitimize_address needs to convert address to Pmode if needed.
Checked into x32 branch.


H.J.
---
commit 1a67c864beb4a9d0c43092e235ccaf32a6c4a7cc
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jan 19 12:51:08 2011 -0800

    Convert to Pmode if needed in ix86_legitimize_address.
diff mbox

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 2a164b2..65694af 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/47364
+	* config/i386/i386.c (ix86_legitimize_address): Convert to
+	Pmode if needed.
+
+2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* config/i386/i386.md (*addsi_1_zext): Replace general_operand
 	with x32_general_operand.  Replace "i"/"g" with "Ye"/"rmYe".
 	(*addsi_2_zext): Likewise.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6e14e59..e18fcb6 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -12949,7 +12949,11 @@  ix86_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
 	  rtx temp = gen_reg_rtx (Pmode);
 	  rtx val  = force_operand (XEXP (x, 1), temp);
 	  if (val != temp)
-	    emit_move_insn (temp, val);
+	    {
+	      if (GET_MODE (val) != Pmode)
+		val = convert_to_mode (Pmode, val, 1);
+	      emit_move_insn (temp, val);
+	    }
 
 	  XEXP (x, 1) = temp;
 	  return x;
@@ -12960,7 +12964,11 @@  ix86_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
 	  rtx temp = gen_reg_rtx (Pmode);
 	  rtx val  = force_operand (XEXP (x, 0), temp);
 	  if (val != temp)
-	    emit_move_insn (temp, val);
+	    {
+	      if (GET_MODE (val) != Pmode)
+		val = convert_to_mode (Pmode, val, 1);
+	      emit_move_insn (temp, val);
+	    }
 
 	  XEXP (x, 0) = temp;
 	  return x;
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
new file mode 100644
index 0000000..ab8b2bc
--- /dev/null
+++ b/gcc/testsuite/ChangeLog.x32
@@ -0,0 +1,4 @@ 
+2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/47364
+	* gcc.target/i386/pr47364.c: New.
diff --git a/gcc/testsuite/gcc.target/i386/pr47364.c b/gcc/testsuite/gcc.target/i386/pr47364.c
new file mode 100644
index 0000000..49ee6f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr47364.c
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+static unsigned char foo[256];
+
+arc4_init(void)
+{
+  int n;
+
+  for (n = 0; n < 256; n++)
+    foo[n] = n;
+}