This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR target/24879: SSE3 intrinsic bug


When I added SSE3 intrinsics, they didn't support 64bit explicitly.
All, but monitor works in 64bit. This patch adds 64bit monitor.


H.J.
 --
gcc/

2005-11-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/24879
	* config/i386/i386.c (ix86_expand_builtin): Support 64bit SSE3
	monitor.

	* config/i386/pmmintrin.h (_mm_monitor): Remove macro. Use
	inline function.
	(_mm_mwait): Likewise.

	* config/i386/sse.md (sse3_monitor): Make it 32bit only.
	(sse3_monitor64): New. 64bit monitor.

gcc/testsuite/

2005-11-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/24879
	* gcc.target/i386/monitor.c: New file.

--- gcc/config/i386/i386.c.sse3	2005-11-15 17:33:02.000000000 -0800
+++ gcc/config/i386/i386.c	2005-11-15 23:21:22.000000000 -0800
@@ -15661,12 +15661,15 @@ ix86_expand_builtin (tree exp, rtx targe
       op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
       op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
       if (!REG_P (op0))
-	op0 = copy_to_mode_reg (SImode, op0);
+	op0 = copy_to_mode_reg (TARGET_64BIT ? DImode : SImode, 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_monitor64 (op0, op1, op2));
+      else
+	emit_insn (gen_sse3_monitor (op0, op1, op2));
       return 0;
 
     case IX86_BUILTIN_MWAIT:
--- gcc/config/i386/pmmintrin.h.sse3	2005-11-04 14:13:48.000000000 -0800
+++ gcc/config/i386/pmmintrin.h	2005-11-15 22:44:02.000000000 -0800
@@ -110,7 +110,6 @@ _mm_lddqu_si128 (__m128i const *__P)
   return (__m128i) __builtin_ia32_lddqu ((char const *)__P);
 }
 
-#if 0
 static __inline void __attribute__((__always_inline__))
 _mm_monitor (void const * __P, unsigned int __E, unsigned int __H)
 {
@@ -122,10 +121,6 @@ _mm_mwait (unsigned int __E, unsigned in
 {
   __builtin_ia32_mwait (__E, __H);
 }
-#else
-#define _mm_monitor(P, E, H)	__builtin_ia32_monitor ((P), (E), (H))
-#define _mm_mwait(E, H)		__builtin_ia32_mwait ((E), (H))
-#endif
 
 #endif /* __SSE3__ */
 
--- gcc/config/i386/sse.md.sse3	2005-11-04 14:13:48.000000000 -0800
+++ gcc/config/i386/sse.md	2005-11-15 23:13:39.000000000 -0800
@@ -3899,6 +3899,17 @@
 		     (match_operand:SI 1 "register_operand" "c")
 		     (match_operand:SI 2 "register_operand" "d")]
 		    UNSPECV_MONITOR)]
-  "TARGET_SSE3"
+  "TARGET_SSE3 && !TARGET_64BIT"
   "monitor\t%0, %1, %2"
   [(set_attr "length" "3")])
+
+(define_insn "sse3_monitor64"
+  [(unspec_volatile [(match_operand:DI 0 "register_operand" "a")
+		     (match_operand:SI 1 "register_operand" "c")
+		     (match_operand:SI 2 "register_operand" "d")]
+		    UNSPECV_MONITOR)]
+  "TARGET_SSE3 && TARGET_64BIT"
+;; Older assembler doesn't support 64bit monitor.
+;;  "monitor\t%0, %1, %2"
+  "monitor"
+  [(set_attr "length" "3")])
--- gcc/testsuite/gcc.target/i386/monitor.c.sse3	2005-11-15 22:59:54.000000000 -0800
+++ gcc/testsuite/gcc.target/i386/monitor.c	2005-11-15 23:25:23.000000000 -0800
@@ -0,0 +1,27 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -msse3" } */
+
+/* Verify that they work in both 32bit and 64bit.  */
+
+#include <pmmintrin.h>
+
+void
+foo (char *p, int x, int y, int z)
+{
+   _mm_monitor (p, y, x);
+   _mm_mwait (z, y);
+}
+
+void
+bar (char *p, long x, long y, long z)
+{
+   _mm_monitor (p, y, x);
+   _mm_mwait (z, y);
+}
+
+void
+foo1 (char *p)
+{
+   _mm_monitor (p, 0, 0);
+   _mm_mwait (0, 0);
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]