]> git.pld-linux.org Git - packages/gcc4.git/blame - gcc4-pr24879.patch
- added from gcc/
[packages/gcc4.git] / gcc4-pr24879.patch
CommitLineData
4ada39a3
AM
1--- gcc/config/i386/i386.c.sse3 2005-11-15 17:33:02.000000000 -0800
2+++ gcc/config/i386/i386.c 2005-11-17 09:44:47.000000000 -0800
3@@ -14347,10 +14347,20 @@ ix86_init_mmx_sse_builtins (void)
4 tree void_ftype_unsigned_unsigned
5 = build_function_type_list (void_type_node, unsigned_type_node,
6 unsigned_type_node, NULL_TREE);
7+ tree void_ftype_di_di
8+ = build_function_type_list (void_type_node,
9+ long_long_unsigned_type_node,
10+ long_long_unsigned_type_node,
11+ NULL_TREE);
12 tree void_ftype_pcvoid_unsigned_unsigned
13 = build_function_type_list (void_type_node, const_ptr_type_node,
14 unsigned_type_node, unsigned_type_node,
15 NULL_TREE);
16+ tree void_ftype_pcvoid_di_di
17+ = build_function_type_list (void_type_node, const_ptr_type_node,
18+ long_long_unsigned_type_node,
19+ long_long_unsigned_type_node,
20+ NULL_TREE);
21 tree unsigned_ftype_void
22 = build_function_type (unsigned_type_node, void_list_node);
23 tree v2si_ftype_v4sf
24@@ -14811,12 +14821,24 @@ ix86_init_mmx_sse_builtins (void)
25 def_builtin (MASK_SSE2, "__builtin_ia32_pmaddwd128", v4si_ftype_v8hi_v8hi, IX86_BUILTIN_PMADDWD128);
26
27 /* Prescott New Instructions. */
28- def_builtin (MASK_SSE3, "__builtin_ia32_monitor",
29- void_ftype_pcvoid_unsigned_unsigned,
30- IX86_BUILTIN_MONITOR);
31- def_builtin (MASK_SSE3, "__builtin_ia32_mwait",
32- void_ftype_unsigned_unsigned,
33- IX86_BUILTIN_MWAIT);
34+ if (TARGET_64BIT)
35+ {
36+ def_builtin (MASK_SSE3, "__builtin_ia32_monitor",
37+ void_ftype_pcvoid_di_di,
38+ IX86_BUILTIN_MONITOR);
39+ def_builtin (MASK_SSE3, "__builtin_ia32_mwait",
40+ void_ftype_di_di,
41+ IX86_BUILTIN_MWAIT);
42+ }
43+ else
44+ {
45+ def_builtin (MASK_SSE3, "__builtin_ia32_monitor",
46+ void_ftype_pcvoid_unsigned_unsigned,
47+ IX86_BUILTIN_MONITOR);
48+ def_builtin (MASK_SSE3, "__builtin_ia32_mwait",
49+ void_ftype_unsigned_unsigned,
50+ IX86_BUILTIN_MWAIT);
51+ }
52 def_builtin (MASK_SSE3, "__builtin_ia32_movshdup",
53 v4sf_ftype_v4sf,
54 IX86_BUILTIN_MOVSHDUP);
55@@ -15660,13 +15682,17 @@ ix86_expand_builtin (tree exp, rtx targe
56 op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
57 op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
58 op2 = expand_expr (arg2, NULL_RTX, VOIDmode, 0);
59+ mode = TARGET_64BIT ? DImode : SImode;
60 if (!REG_P (op0))
61- op0 = copy_to_mode_reg (SImode, op0);
62+ op0 = copy_to_mode_reg (mode, op0);
63 if (!REG_P (op1))
64- op1 = copy_to_mode_reg (SImode, op1);
65+ op1 = copy_to_mode_reg (mode, op1);
66 if (!REG_P (op2))
67- op2 = copy_to_mode_reg (SImode, op2);
68- emit_insn (gen_sse3_monitor (op0, op1, op2));
69+ op2 = copy_to_mode_reg (mode, op2);
70+ if (TARGET_64BIT)
71+ emit_insn (gen_sse3_monitor64 (op0, op1, op2));
72+ else
73+ emit_insn (gen_sse3_monitor (op0, op1, op2));
74 return 0;
75
76 case IX86_BUILTIN_MWAIT:
77@@ -15674,11 +15700,15 @@ ix86_expand_builtin (tree exp, rtx targe
78 arg1 = TREE_VALUE (TREE_CHAIN (arglist));
79 op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
80 op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0);
81+ mode = TARGET_64BIT ? DImode : SImode;
82 if (!REG_P (op0))
83- op0 = copy_to_mode_reg (SImode, op0);
84+ op0 = copy_to_mode_reg (mode, op0);
85 if (!REG_P (op1))
86- op1 = copy_to_mode_reg (SImode, op1);
87- emit_insn (gen_sse3_mwait (op0, op1));
88+ op1 = copy_to_mode_reg (mode, op1);
89+ if (TARGET_64BIT)
90+ emit_insn (gen_sse3_mwait64 (op0, op1));
91+ else
92+ emit_insn (gen_sse3_mwait (op0, op1));
93 return 0;
94
95 case IX86_BUILTIN_LDDQU:
96--- gcc/config/i386/pmmintrin.h.sse3 2005-11-04 14:13:48.000000000 -0800
97+++ gcc/config/i386/pmmintrin.h 2005-11-15 22:44:02.000000000 -0800
98@@ -110,7 +110,6 @@ _mm_lddqu_si128 (__m128i const *__P)
99 return (__m128i) __builtin_ia32_lddqu ((char const *)__P);
100 }
101
102-#if 0
103 static __inline void __attribute__((__always_inline__))
104 _mm_monitor (void const * __P, unsigned int __E, unsigned int __H)
105 {
106@@ -122,10 +121,6 @@ _mm_mwait (unsigned int __E, unsigned in
107 {
108 __builtin_ia32_mwait (__E, __H);
109 }
110-#else
111-#define _mm_monitor(P, E, H) __builtin_ia32_monitor ((P), (E), (H))
112-#define _mm_mwait(E, H) __builtin_ia32_mwait ((E), (H))
113-#endif
114
115 #endif /* __SSE3__ */
116
117--- gcc/config/i386/sse.md.sse3 2005-11-04 14:13:48.000000000 -0800
118+++ gcc/config/i386/sse.md 2005-11-17 09:25:31.000000000 -0800
119@@ -3890,15 +3890,36 @@
120 [(unspec_volatile [(match_operand:SI 0 "register_operand" "a")
121 (match_operand:SI 1 "register_operand" "c")]
122 UNSPECV_MWAIT)]
123- "TARGET_SSE3"
124+ "TARGET_SSE3 && !TARGET_64BIT"
125 "mwait\t%0, %1"
126 [(set_attr "length" "3")])
127
128+(define_insn "sse3_mwait64"
129+ [(unspec_volatile [(match_operand:DI 0 "register_operand" "a")
130+ (match_operand:DI 1 "register_operand" "c")]
131+ UNSPECV_MWAIT)]
132+ "TARGET_SSE3 && TARGET_64BIT"
133+;; Older assembler doesn't support "mwait %rax,%rcx".
134+;; "mwait\t%0, %1"
135+ "mwait"
136+ [(set_attr "length" "3")])
137+
138 (define_insn "sse3_monitor"
139 [(unspec_volatile [(match_operand:SI 0 "register_operand" "a")
140 (match_operand:SI 1 "register_operand" "c")
141 (match_operand:SI 2 "register_operand" "d")]
142 UNSPECV_MONITOR)]
143- "TARGET_SSE3"
144+ "TARGET_SSE3 && !TARGET_64BIT"
145 "monitor\t%0, %1, %2"
146 [(set_attr "length" "3")])
147+
148+(define_insn "sse3_monitor64"
149+ [(unspec_volatile [(match_operand:DI 0 "register_operand" "a")
150+ (match_operand:DI 1 "register_operand" "c")
151+ (match_operand:DI 2 "register_operand" "d")]
152+ UNSPECV_MONITOR)]
153+ "TARGET_SSE3 && TARGET_64BIT"
154+;; Older assembler doesn't support "monitor %rax,%rcx,%rdx".
155+;; "monitor\t%0, %1, %2"
156+ "monitor"
157+ [(set_attr "length" "3")])
158--- gcc/testsuite/gcc.target/i386/monitor.c.sse3 2005-11-15 22:59:54.000000000 -0800
159+++ gcc/testsuite/gcc.target/i386/monitor.c 2005-11-15 23:25:23.000000000 -0800
160@@ -0,0 +1,27 @@
161+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
162+/* { dg-options "-O2 -msse3" } */
163+
164+/* Verify that they work in both 32bit and 64bit. */
165+
166+#include <pmmintrin.h>
167+
168+void
169+foo (char *p, int x, int y, int z)
170+{
171+ _mm_monitor (p, y, x);
172+ _mm_mwait (z, y);
173+}
174+
175+void
176+bar (char *p, long x, long y, long z)
177+{
178+ _mm_monitor (p, y, x);
179+ _mm_mwait (z, y);
180+}
181+
182+void
183+foo1 (char *p)
184+{
185+ _mm_monitor (p, 0, 0);
186+ _mm_mwait (0, 0);
187+}
188
This page took 0.969041 seconds and 4 git commands to generate.