[patch] i386.c: Fix PR target/27696.

Kazu Hirata kazu@codesourcery.com
Tue May 23 08:59:00 GMT 2006


Hi,

Attached is a patch to fix PR target/27696.

The attached testcase ICEs in copy_to_mode_reg.  The reason is because
op0 is of DImode on x86_64-pc-linux-gnu, but we try to copy it to an
SImode reg.

The patch fixes this problem by using Pmode for op0 and
gen_sse3_monitor64 for TARGET_64BIT.

This patch also fixes gcc.dg/other/i386-2.C.  In fact, the attached
testcase was drived from i386-2.C.  Interestingly,
gcc.target/i386/monitor.c doesn't fail with or without this patch.
The use of "-O2" in it seems to make a difference.

Tested on x86_64-pc-linux-gnu.  OK to apply?

Kazu Hirata

2006-05-23  Kazu Hirata  <kazu@codesourcery.com>

	PR target/27696
	* config/i386/i386.c (ix86_expand_builtin): Use
	gen_sse3_monitor64 for TARGET_64BIT.

2006-05-23  Kazu Hirata  <kazu@codesourcery.com>

	PR target/27696
	* gcc.target/i386/pr27696.c: New.

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 113961)
+++ config/i386/i386.c	(working copy)
@@ -16232,12 +16232,15 @@ ix86_expand_builtin (tree exp, rtx targe
       op1 = expand_normal (arg1);
       op2 = expand_normal (arg2);
       if (!REG_P (op0))
-	op0 = copy_to_mode_reg (SImode, op0);
+	op0 = copy_to_mode_reg (Pmode, op0);
       if (!REG_P (op1))
 	op1 = copy_to_mode_reg (SImode, op1);
       if (!REG_P (op2))
 	op2 = copy_to_mode_reg (SImode, op2);
-      emit_insn (gen_sse3_monitor (op0, op1, op2));
+      if (!TARGET_64BIT)
+	emit_insn (gen_sse3_monitor (op0, op1, op2));
+      else
+	emit_insn (gen_sse3_monitor64 (op0, op1, op2));
       return 0;
 
     case IX86_BUILTIN_MWAIT:
--- /dev/null	2006-03-11 08:41:44.866675760 -0800
+++ testsuite/gcc.target/i386/pr27696.c	2006-05-22 21:26:54.000000000 -0700
@@ -0,0 +1,11 @@
+/* PR target/27696
+   The testcase below uses to trigger an ICE.  */
+
+/* { dg-do compile } */
+/* { dg-options "-msse3" } */
+
+void
+foo (void const * P, unsigned int E, unsigned int H)
+{
+  __builtin_ia32_monitor (P, E, H);
+}



More information about the Gcc-patches mailing list