1//===- IntrinsicsX86.td - Defines X86 intrinsics -----------*- tablegen -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines all of the X86-specific intrinsics.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// Interrupt traps
16let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
17  def int_x86_int : Intrinsic<[], [llvm_i8_ty]>;
18}
19
20//===----------------------------------------------------------------------===//
21// Read Time Stamp Counter.
22let TargetPrefix = "x86" in {
23  def int_x86_rdtsc : GCCBuiltin<"__builtin_ia32_rdtsc">,
24              Intrinsic<[llvm_i64_ty], [], []>;
25  def int_x86_rdtscp : GCCBuiltin<"__builtin_ia32_rdtscp">,
26              Intrinsic<[llvm_i64_ty], [llvm_ptr_ty], [IntrReadWriteArgMem]>;
27}
28
29// Read Performance-Monitoring Counter.
30let TargetPrefix = "x86" in {
31  def int_x86_rdpmc : GCCBuiltin<"__builtin_ia32_rdpmc">,
32              Intrinsic<[llvm_i64_ty], [llvm_i32_ty], []>;
33}
34
35//===----------------------------------------------------------------------===//
36// 3DNow!
37
38let TargetPrefix = "x86" in {
39  def int_x86_3dnow_pavgusb : GCCBuiltin<"__builtin_ia32_pavgusb">,
40              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
41                        [IntrNoMem]>;
42  def int_x86_3dnow_pf2id : GCCBuiltin<"__builtin_ia32_pf2id">,
43              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
44  def int_x86_3dnow_pfacc : GCCBuiltin<"__builtin_ia32_pfacc">,
45              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
46                        [IntrNoMem]>;
47  def int_x86_3dnow_pfadd : GCCBuiltin<"__builtin_ia32_pfadd">,
48              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
49                        [IntrNoMem]>;
50  def int_x86_3dnow_pfcmpeq : GCCBuiltin<"__builtin_ia32_pfcmpeq">,
51              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
52                        [IntrNoMem]>;
53  def int_x86_3dnow_pfcmpge : GCCBuiltin<"__builtin_ia32_pfcmpge">,
54              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
55                        [IntrNoMem]>;
56  def int_x86_3dnow_pfcmpgt : GCCBuiltin<"__builtin_ia32_pfcmpgt">,
57              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
58                        [IntrNoMem]>;
59  def int_x86_3dnow_pfmax : GCCBuiltin<"__builtin_ia32_pfmax">,
60              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
61                        [IntrNoMem]>;
62  def int_x86_3dnow_pfmin : GCCBuiltin<"__builtin_ia32_pfmin">,
63              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
64                        [IntrNoMem]>;
65  def int_x86_3dnow_pfmul : GCCBuiltin<"__builtin_ia32_pfmul">,
66              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
67                        [IntrNoMem]>;
68  def int_x86_3dnow_pfrcp : GCCBuiltin<"__builtin_ia32_pfrcp">,
69              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
70  def int_x86_3dnow_pfrcpit1 : GCCBuiltin<"__builtin_ia32_pfrcpit1">,
71              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
72                        [IntrNoMem]>;
73  def int_x86_3dnow_pfrcpit2 : GCCBuiltin<"__builtin_ia32_pfrcpit2">,
74              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
75                        [IntrNoMem]>;
76  def int_x86_3dnow_pfrsqrt : GCCBuiltin<"__builtin_ia32_pfrsqrt">,
77              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
78  def int_x86_3dnow_pfrsqit1 : GCCBuiltin<"__builtin_ia32_pfrsqit1">,
79              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
80                        [IntrNoMem]>;
81  def int_x86_3dnow_pfsub : GCCBuiltin<"__builtin_ia32_pfsub">,
82              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
83                        [IntrNoMem]>;
84  def int_x86_3dnow_pfsubr : GCCBuiltin<"__builtin_ia32_pfsubr">,
85              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
86                        [IntrNoMem]>;
87  def int_x86_3dnow_pi2fd : GCCBuiltin<"__builtin_ia32_pi2fd">,
88              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
89  def int_x86_3dnow_pmulhrw : GCCBuiltin<"__builtin_ia32_pmulhrw">,
90              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
91                        [IntrNoMem]>;
92}
93
94//===----------------------------------------------------------------------===//
95// 3DNow! extensions
96
97let TargetPrefix = "x86" in {
98  def int_x86_3dnowa_pf2iw : GCCBuiltin<"__builtin_ia32_pf2iw">,
99              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
100  def int_x86_3dnowa_pfnacc : GCCBuiltin<"__builtin_ia32_pfnacc">,
101              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
102                        [IntrNoMem]>;
103  def int_x86_3dnowa_pfpnacc : GCCBuiltin<"__builtin_ia32_pfpnacc">,
104              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
105                        [IntrNoMem]>;
106  def int_x86_3dnowa_pi2fw : GCCBuiltin<"__builtin_ia32_pi2fw">,
107              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
108  def int_x86_3dnowa_pswapd :
109              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
110}
111
112//===----------------------------------------------------------------------===//
113// SSE1
114
115// Arithmetic ops
116let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
117  def int_x86_sse_add_ss : GCCBuiltin<"__builtin_ia32_addss">,
118              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
119                         llvm_v4f32_ty], [IntrNoMem]>;
120  def int_x86_sse_sub_ss : GCCBuiltin<"__builtin_ia32_subss">,
121              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
122                         llvm_v4f32_ty], [IntrNoMem]>;
123  def int_x86_sse_mul_ss : GCCBuiltin<"__builtin_ia32_mulss">,
124              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
125                         llvm_v4f32_ty], [IntrNoMem]>;
126  def int_x86_sse_div_ss : GCCBuiltin<"__builtin_ia32_divss">,
127              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
128                         llvm_v4f32_ty], [IntrNoMem]>;
129  def int_x86_sse_sqrt_ss : GCCBuiltin<"__builtin_ia32_sqrtss">,
130              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
131                        [IntrNoMem]>;
132  def int_x86_sse_sqrt_ps : GCCBuiltin<"__builtin_ia32_sqrtps">,
133              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
134                        [IntrNoMem]>;
135  def int_x86_sse_rcp_ss : GCCBuiltin<"__builtin_ia32_rcpss">,
136              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
137                        [IntrNoMem]>;
138  def int_x86_sse_rcp_ps : GCCBuiltin<"__builtin_ia32_rcpps">,
139              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
140                        [IntrNoMem]>;
141  def int_x86_sse_rsqrt_ss : GCCBuiltin<"__builtin_ia32_rsqrtss">,
142              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
143                        [IntrNoMem]>;
144  def int_x86_sse_rsqrt_ps : GCCBuiltin<"__builtin_ia32_rsqrtps">,
145              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
146                        [IntrNoMem]>;
147  def int_x86_sse_min_ss : GCCBuiltin<"__builtin_ia32_minss">,
148              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
149                         llvm_v4f32_ty], [IntrNoMem]>;
150  def int_x86_sse_min_ps : GCCBuiltin<"__builtin_ia32_minps">,
151              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
152                         llvm_v4f32_ty], [IntrNoMem]>;
153  def int_x86_sse_max_ss : GCCBuiltin<"__builtin_ia32_maxss">,
154              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
155                         llvm_v4f32_ty], [IntrNoMem]>;
156  def int_x86_sse_max_ps : GCCBuiltin<"__builtin_ia32_maxps">,
157              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
158                         llvm_v4f32_ty], [IntrNoMem]>;
159}
160
161// Comparison ops
162let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
163  def int_x86_sse_cmp_ss : GCCBuiltin<"__builtin_ia32_cmpss">,
164              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
165                         llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
166  def int_x86_sse_cmp_ps : GCCBuiltin<"__builtin_ia32_cmpps">,
167              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
168                         llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
169  def int_x86_sse_comieq_ss : GCCBuiltin<"__builtin_ia32_comieq">,
170              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
171                         llvm_v4f32_ty], [IntrNoMem]>;
172  def int_x86_sse_comilt_ss : GCCBuiltin<"__builtin_ia32_comilt">,
173              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
174                         llvm_v4f32_ty], [IntrNoMem]>;
175  def int_x86_sse_comile_ss : GCCBuiltin<"__builtin_ia32_comile">,
176              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
177                         llvm_v4f32_ty], [IntrNoMem]>;
178  def int_x86_sse_comigt_ss : GCCBuiltin<"__builtin_ia32_comigt">,
179              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
180                         llvm_v4f32_ty], [IntrNoMem]>;
181  def int_x86_sse_comige_ss : GCCBuiltin<"__builtin_ia32_comige">,
182              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
183                         llvm_v4f32_ty], [IntrNoMem]>;
184  def int_x86_sse_comineq_ss : GCCBuiltin<"__builtin_ia32_comineq">,
185              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
186                         llvm_v4f32_ty], [IntrNoMem]>;
187  def int_x86_sse_ucomieq_ss : GCCBuiltin<"__builtin_ia32_ucomieq">,
188              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
189                         llvm_v4f32_ty], [IntrNoMem]>;
190  def int_x86_sse_ucomilt_ss : GCCBuiltin<"__builtin_ia32_ucomilt">,
191              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
192                         llvm_v4f32_ty], [IntrNoMem]>;
193  def int_x86_sse_ucomile_ss : GCCBuiltin<"__builtin_ia32_ucomile">,
194              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
195                         llvm_v4f32_ty], [IntrNoMem]>;
196  def int_x86_sse_ucomigt_ss : GCCBuiltin<"__builtin_ia32_ucomigt">,
197              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
198                         llvm_v4f32_ty], [IntrNoMem]>;
199  def int_x86_sse_ucomige_ss : GCCBuiltin<"__builtin_ia32_ucomige">,
200              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
201                         llvm_v4f32_ty], [IntrNoMem]>;
202  def int_x86_sse_ucomineq_ss : GCCBuiltin<"__builtin_ia32_ucomineq">,
203              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
204                         llvm_v4f32_ty], [IntrNoMem]>;
205}
206
207
208// Conversion ops
209let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
210  def int_x86_sse_cvtss2si : GCCBuiltin<"__builtin_ia32_cvtss2si">,
211              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
212  def int_x86_sse_cvtss2si64 : GCCBuiltin<"__builtin_ia32_cvtss2si64">,
213              Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
214  def int_x86_sse_cvttss2si : GCCBuiltin<"__builtin_ia32_cvttss2si">,
215              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
216  def int_x86_sse_cvttss2si64 : GCCBuiltin<"__builtin_ia32_cvttss2si64">,
217              Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
218  def int_x86_sse_cvtsi2ss : GCCBuiltin<"__builtin_ia32_cvtsi2ss">,
219              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
220                         llvm_i32_ty], [IntrNoMem]>;
221  def int_x86_sse_cvtsi642ss : GCCBuiltin<"__builtin_ia32_cvtsi642ss">,
222              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
223                         llvm_i64_ty], [IntrNoMem]>;
224
225  def int_x86_sse_cvtps2pi : GCCBuiltin<"__builtin_ia32_cvtps2pi">,
226              Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>;
227  def int_x86_sse_cvttps2pi: GCCBuiltin<"__builtin_ia32_cvttps2pi">,
228              Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>;
229  def int_x86_sse_cvtpi2ps : GCCBuiltin<"__builtin_ia32_cvtpi2ps">,
230              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
231                         llvm_x86mmx_ty], [IntrNoMem]>;
232}
233
234// SIMD store ops
235let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
236  def int_x86_sse_storeu_ps : GCCBuiltin<"__builtin_ia32_storeups">,
237              Intrinsic<[], [llvm_ptr_ty,
238                         llvm_v4f32_ty], [IntrReadWriteArgMem]>;
239}
240
241// Cacheability support ops
242let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
243  def int_x86_sse_sfence : GCCBuiltin<"__builtin_ia32_sfence">,
244              Intrinsic<[], [], []>;
245}
246
247// Control register.
248let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
249  def int_x86_sse_stmxcsr :
250              Intrinsic<[], [llvm_ptr_ty], []>;
251  def int_x86_sse_ldmxcsr :
252              Intrinsic<[], [llvm_ptr_ty], []>;
253}
254
255// Misc.
256let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
257  def int_x86_sse_movmsk_ps : GCCBuiltin<"__builtin_ia32_movmskps">,
258              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
259}
260
261//===----------------------------------------------------------------------===//
262// SSE2
263
264// FP arithmetic ops
265let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
266  def int_x86_sse2_add_sd : GCCBuiltin<"__builtin_ia32_addsd">,
267              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
268                         llvm_v2f64_ty], [IntrNoMem]>;
269  def int_x86_sse2_sub_sd : GCCBuiltin<"__builtin_ia32_subsd">,
270              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
271                         llvm_v2f64_ty], [IntrNoMem]>;
272  def int_x86_sse2_mul_sd : GCCBuiltin<"__builtin_ia32_mulsd">,
273              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
274                         llvm_v2f64_ty], [IntrNoMem]>;
275  def int_x86_sse2_div_sd : GCCBuiltin<"__builtin_ia32_divsd">,
276              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
277                         llvm_v2f64_ty], [IntrNoMem]>;
278  def int_x86_sse2_sqrt_sd : GCCBuiltin<"__builtin_ia32_sqrtsd">,
279              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty],
280                        [IntrNoMem]>;
281  def int_x86_sse2_sqrt_pd : GCCBuiltin<"__builtin_ia32_sqrtpd">,
282              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty],
283                        [IntrNoMem]>;
284  def int_x86_sse2_min_sd : GCCBuiltin<"__builtin_ia32_minsd">,
285              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
286                         llvm_v2f64_ty], [IntrNoMem]>;
287  def int_x86_sse2_min_pd : GCCBuiltin<"__builtin_ia32_minpd">,
288              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
289                         llvm_v2f64_ty], [IntrNoMem]>;
290  def int_x86_sse2_max_sd : GCCBuiltin<"__builtin_ia32_maxsd">,
291              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
292                         llvm_v2f64_ty], [IntrNoMem]>;
293  def int_x86_sse2_max_pd : GCCBuiltin<"__builtin_ia32_maxpd">,
294              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
295                         llvm_v2f64_ty], [IntrNoMem]>;
296}
297
298// FP comparison ops
299let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
300  def int_x86_sse2_cmp_sd : GCCBuiltin<"__builtin_ia32_cmpsd">,
301              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
302                         llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
303  def int_x86_sse2_cmp_pd : GCCBuiltin<"__builtin_ia32_cmppd">,
304              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
305                         llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
306  def int_x86_sse2_comieq_sd : GCCBuiltin<"__builtin_ia32_comisdeq">,
307              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
308                         llvm_v2f64_ty], [IntrNoMem]>;
309  def int_x86_sse2_comilt_sd : GCCBuiltin<"__builtin_ia32_comisdlt">,
310              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
311                         llvm_v2f64_ty], [IntrNoMem]>;
312  def int_x86_sse2_comile_sd : GCCBuiltin<"__builtin_ia32_comisdle">,
313              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
314                         llvm_v2f64_ty], [IntrNoMem]>;
315  def int_x86_sse2_comigt_sd : GCCBuiltin<"__builtin_ia32_comisdgt">,
316              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
317                         llvm_v2f64_ty], [IntrNoMem]>;
318  def int_x86_sse2_comige_sd : GCCBuiltin<"__builtin_ia32_comisdge">,
319              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
320                         llvm_v2f64_ty], [IntrNoMem]>;
321  def int_x86_sse2_comineq_sd : GCCBuiltin<"__builtin_ia32_comisdneq">,
322              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
323                         llvm_v2f64_ty], [IntrNoMem]>;
324  def int_x86_sse2_ucomieq_sd : GCCBuiltin<"__builtin_ia32_ucomisdeq">,
325              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
326                         llvm_v2f64_ty], [IntrNoMem]>;
327  def int_x86_sse2_ucomilt_sd : GCCBuiltin<"__builtin_ia32_ucomisdlt">,
328              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
329                         llvm_v2f64_ty], [IntrNoMem]>;
330  def int_x86_sse2_ucomile_sd : GCCBuiltin<"__builtin_ia32_ucomisdle">,
331              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
332                         llvm_v2f64_ty], [IntrNoMem]>;
333  def int_x86_sse2_ucomigt_sd : GCCBuiltin<"__builtin_ia32_ucomisdgt">,
334              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
335                         llvm_v2f64_ty], [IntrNoMem]>;
336  def int_x86_sse2_ucomige_sd : GCCBuiltin<"__builtin_ia32_ucomisdge">,
337              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
338                         llvm_v2f64_ty], [IntrNoMem]>;
339  def int_x86_sse2_ucomineq_sd : GCCBuiltin<"__builtin_ia32_ucomisdneq">,
340              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
341                         llvm_v2f64_ty], [IntrNoMem]>;
342}
343
344// Integer arithmetic ops.
345let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
346  def int_x86_sse2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb128">,
347              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
348                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
349  def int_x86_sse2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw128">,
350              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
351                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
352  def int_x86_sse2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb128">,
353              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
354                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
355  def int_x86_sse2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw128">,
356              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
357                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
358  def int_x86_sse2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb128">,
359              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
360                         llvm_v16i8_ty], [IntrNoMem]>;
361  def int_x86_sse2_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw128">,
362              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
363                         llvm_v8i16_ty], [IntrNoMem]>;
364  def int_x86_sse2_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb128">,
365              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
366                         llvm_v16i8_ty], [IntrNoMem]>;
367  def int_x86_sse2_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw128">,
368              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
369                         llvm_v8i16_ty], [IntrNoMem]>;
370  def int_x86_sse2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw128">,
371              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
372                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
373  def int_x86_sse2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw128">,
374              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
375                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
376  def int_x86_sse2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq128">,
377              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty,
378                         llvm_v4i32_ty], [IntrNoMem, Commutative]>;
379  def int_x86_sse2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd128">,
380              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty,
381                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
382  def int_x86_sse2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb128">,
383              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
384                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
385  def int_x86_sse2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw128">,
386              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
387                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
388  def int_x86_sse2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub128">,
389              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
390                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
391  def int_x86_sse2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw128">,
392              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
393                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
394  def int_x86_sse2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub128">,
395              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
396                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
397  def int_x86_sse2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw128">,
398              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
399                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
400  def int_x86_sse2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw128">,
401              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty,
402                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
403}
404
405// Integer shift ops.
406let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
407  def int_x86_sse2_psll_w : GCCBuiltin<"__builtin_ia32_psllw128">,
408              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
409                         llvm_v8i16_ty], [IntrNoMem]>;
410  def int_x86_sse2_psll_d : GCCBuiltin<"__builtin_ia32_pslld128">,
411              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
412                         llvm_v4i32_ty], [IntrNoMem]>;
413  def int_x86_sse2_psll_q : GCCBuiltin<"__builtin_ia32_psllq128">,
414              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
415                         llvm_v2i64_ty], [IntrNoMem]>;
416  def int_x86_sse2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw128">,
417              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
418                         llvm_v8i16_ty], [IntrNoMem]>;
419  def int_x86_sse2_psrl_d : GCCBuiltin<"__builtin_ia32_psrld128">,
420              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
421                         llvm_v4i32_ty], [IntrNoMem]>;
422  def int_x86_sse2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq128">,
423              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
424                         llvm_v2i64_ty], [IntrNoMem]>;
425  def int_x86_sse2_psra_w : GCCBuiltin<"__builtin_ia32_psraw128">,
426              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
427                         llvm_v8i16_ty], [IntrNoMem]>;
428  def int_x86_sse2_psra_d : GCCBuiltin<"__builtin_ia32_psrad128">,
429              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
430                         llvm_v4i32_ty], [IntrNoMem]>;
431
432  def int_x86_sse2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi128">,
433              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
434                         llvm_i32_ty], [IntrNoMem]>;
435  def int_x86_sse2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi128">,
436              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
437                         llvm_i32_ty], [IntrNoMem]>;
438  def int_x86_sse2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi128">,
439              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
440                         llvm_i32_ty], [IntrNoMem]>;
441  def int_x86_sse2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi128">,
442              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
443                         llvm_i32_ty], [IntrNoMem]>;
444  def int_x86_sse2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi128">,
445              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
446                         llvm_i32_ty], [IntrNoMem]>;
447  def int_x86_sse2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi128">,
448              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
449                         llvm_i32_ty], [IntrNoMem]>;
450  def int_x86_sse2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi128">,
451              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
452                         llvm_i32_ty], [IntrNoMem]>;
453  def int_x86_sse2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi128">,
454              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
455                         llvm_i32_ty], [IntrNoMem]>;
456}
457
458// Conversion ops
459let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
460  def int_x86_sse2_cvtdq2pd : GCCBuiltin<"__builtin_ia32_cvtdq2pd">,
461              Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
462  def int_x86_sse2_cvtdq2ps : GCCBuiltin<"__builtin_ia32_cvtdq2ps">,
463              Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
464  def int_x86_sse2_cvtpd2dq : GCCBuiltin<"__builtin_ia32_cvtpd2dq">,
465              Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
466  def int_x86_sse2_cvttpd2dq : GCCBuiltin<"__builtin_ia32_cvttpd2dq">,
467              Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
468  def int_x86_sse2_cvtpd2ps : GCCBuiltin<"__builtin_ia32_cvtpd2ps">,
469              Intrinsic<[llvm_v4f32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
470  def int_x86_sse2_cvtps2dq : GCCBuiltin<"__builtin_ia32_cvtps2dq">,
471              Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
472  def int_x86_sse2_cvttps2dq : GCCBuiltin<"__builtin_ia32_cvttps2dq">,
473              Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
474  def int_x86_sse2_cvtps2pd : GCCBuiltin<"__builtin_ia32_cvtps2pd">,
475              Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
476  def int_x86_sse2_cvtsd2si : GCCBuiltin<"__builtin_ia32_cvtsd2si">,
477              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
478  def int_x86_sse2_cvtsd2si64 : GCCBuiltin<"__builtin_ia32_cvtsd2si64">,
479              Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
480  def int_x86_sse2_cvttsd2si : GCCBuiltin<"__builtin_ia32_cvttsd2si">,
481              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
482  def int_x86_sse2_cvttsd2si64 : GCCBuiltin<"__builtin_ia32_cvttsd2si64">,
483              Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
484  def int_x86_sse2_cvtsi2sd : GCCBuiltin<"__builtin_ia32_cvtsi2sd">,
485              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
486                         llvm_i32_ty], [IntrNoMem]>;
487  def int_x86_sse2_cvtsi642sd : GCCBuiltin<"__builtin_ia32_cvtsi642sd">,
488              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
489                         llvm_i64_ty], [IntrNoMem]>;
490  def int_x86_sse2_cvtsd2ss : GCCBuiltin<"__builtin_ia32_cvtsd2ss">,
491              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
492                         llvm_v2f64_ty], [IntrNoMem]>;
493  def int_x86_sse2_cvtss2sd : GCCBuiltin<"__builtin_ia32_cvtss2sd">,
494              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
495                         llvm_v4f32_ty], [IntrNoMem]>;
496  def int_x86_sse_cvtpd2pi : GCCBuiltin<"__builtin_ia32_cvtpd2pi">,
497              Intrinsic<[llvm_x86mmx_ty], [llvm_v2f64_ty], [IntrNoMem]>;
498  def int_x86_sse_cvttpd2pi: GCCBuiltin<"__builtin_ia32_cvttpd2pi">,
499              Intrinsic<[llvm_x86mmx_ty], [llvm_v2f64_ty], [IntrNoMem]>;
500  def int_x86_sse_cvtpi2pd : GCCBuiltin<"__builtin_ia32_cvtpi2pd">,
501              Intrinsic<[llvm_v2f64_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
502}
503
504// SIMD store ops
505let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
506  def int_x86_sse2_storeu_pd : GCCBuiltin<"__builtin_ia32_storeupd">,
507              Intrinsic<[], [llvm_ptr_ty,
508                         llvm_v2f64_ty], [IntrReadWriteArgMem]>;
509  def int_x86_sse2_storeu_dq : GCCBuiltin<"__builtin_ia32_storedqu">,
510              Intrinsic<[], [llvm_ptr_ty,
511                         llvm_v16i8_ty], [IntrReadWriteArgMem]>;
512  def int_x86_sse2_storel_dq : GCCBuiltin<"__builtin_ia32_storelv4si">,
513              Intrinsic<[], [llvm_ptr_ty,
514                         llvm_v4i32_ty], [IntrReadWriteArgMem]>;
515}
516
517// Misc.
518let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
519  def int_x86_sse2_packsswb_128 : GCCBuiltin<"__builtin_ia32_packsswb128">,
520              Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty,
521                         llvm_v8i16_ty], [IntrNoMem]>;
522  def int_x86_sse2_packssdw_128 : GCCBuiltin<"__builtin_ia32_packssdw128">,
523              Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty,
524                         llvm_v4i32_ty], [IntrNoMem]>;
525  def int_x86_sse2_packuswb_128 : GCCBuiltin<"__builtin_ia32_packuswb128">,
526              Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty,
527                         llvm_v8i16_ty], [IntrNoMem]>;
528  def int_x86_sse2_movmsk_pd : GCCBuiltin<"__builtin_ia32_movmskpd">,
529              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
530  def int_x86_sse2_pmovmskb_128 : GCCBuiltin<"__builtin_ia32_pmovmskb128">,
531              Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>;
532  def int_x86_sse2_maskmov_dqu : GCCBuiltin<"__builtin_ia32_maskmovdqu">,
533              Intrinsic<[], [llvm_v16i8_ty,
534                         llvm_v16i8_ty, llvm_ptr_ty], []>;
535  def int_x86_sse2_clflush : GCCBuiltin<"__builtin_ia32_clflush">,
536              Intrinsic<[], [llvm_ptr_ty], []>;
537  def int_x86_sse2_lfence : GCCBuiltin<"__builtin_ia32_lfence">,
538              Intrinsic<[], [], []>;
539  def int_x86_sse2_mfence : GCCBuiltin<"__builtin_ia32_mfence">,
540              Intrinsic<[], [], []>;
541  def int_x86_sse2_pause : GCCBuiltin<"__builtin_ia32_pause">,
542              Intrinsic<[], [], []>;
543}
544
545//===----------------------------------------------------------------------===//
546// SSE3
547
548// Addition / subtraction ops.
549let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
550  def int_x86_sse3_addsub_ps : GCCBuiltin<"__builtin_ia32_addsubps">,
551              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
552                         llvm_v4f32_ty], [IntrNoMem]>;
553  def int_x86_sse3_addsub_pd : GCCBuiltin<"__builtin_ia32_addsubpd">,
554              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
555                         llvm_v2f64_ty], [IntrNoMem]>;
556}
557
558// Horizontal ops.
559let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
560  def int_x86_sse3_hadd_ps : GCCBuiltin<"__builtin_ia32_haddps">,
561              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
562                         llvm_v4f32_ty], [IntrNoMem]>;
563  def int_x86_sse3_hadd_pd : GCCBuiltin<"__builtin_ia32_haddpd">,
564              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
565                         llvm_v2f64_ty], [IntrNoMem]>;
566  def int_x86_sse3_hsub_ps : GCCBuiltin<"__builtin_ia32_hsubps">,
567              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
568                         llvm_v4f32_ty], [IntrNoMem]>;
569  def int_x86_sse3_hsub_pd : GCCBuiltin<"__builtin_ia32_hsubpd">,
570              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
571                         llvm_v2f64_ty], [IntrNoMem]>;
572}
573
574// Specialized unaligned load.
575let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
576  def int_x86_sse3_ldu_dq : GCCBuiltin<"__builtin_ia32_lddqu">,
577              Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
578}
579
580// Thread synchronization ops.
581let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
582  def int_x86_sse3_monitor : GCCBuiltin<"__builtin_ia32_monitor">,
583              Intrinsic<[], [llvm_ptr_ty,
584                         llvm_i32_ty, llvm_i32_ty], []>;
585  def int_x86_sse3_mwait : GCCBuiltin<"__builtin_ia32_mwait">,
586              Intrinsic<[], [llvm_i32_ty,
587                         llvm_i32_ty], []>;
588}
589
590//===----------------------------------------------------------------------===//
591// SSSE3
592
593// Horizontal arithmetic ops
594let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
595  def int_x86_ssse3_phadd_w         : GCCBuiltin<"__builtin_ia32_phaddw">,
596              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
597                         llvm_x86mmx_ty], [IntrNoMem]>;
598  def int_x86_ssse3_phadd_w_128     : GCCBuiltin<"__builtin_ia32_phaddw128">,
599              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
600                         llvm_v8i16_ty], [IntrNoMem]>;
601
602  def int_x86_ssse3_phadd_d         : GCCBuiltin<"__builtin_ia32_phaddd">,
603              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
604                         llvm_x86mmx_ty], [IntrNoMem]>;
605  def int_x86_ssse3_phadd_d_128     : GCCBuiltin<"__builtin_ia32_phaddd128">,
606              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
607                         llvm_v4i32_ty], [IntrNoMem]>;
608
609  def int_x86_ssse3_phadd_sw        : GCCBuiltin<"__builtin_ia32_phaddsw">,
610              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
611                         llvm_x86mmx_ty], [IntrNoMem]>;
612  def int_x86_ssse3_phadd_sw_128    : GCCBuiltin<"__builtin_ia32_phaddsw128">,
613              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
614                         llvm_v8i16_ty], [IntrNoMem]>;
615
616  def int_x86_ssse3_phsub_w         : GCCBuiltin<"__builtin_ia32_phsubw">,
617              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
618                         llvm_x86mmx_ty], [IntrNoMem]>;
619  def int_x86_ssse3_phsub_w_128     : GCCBuiltin<"__builtin_ia32_phsubw128">,
620              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
621                         llvm_v8i16_ty], [IntrNoMem]>;
622
623  def int_x86_ssse3_phsub_d         : GCCBuiltin<"__builtin_ia32_phsubd">,
624              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
625                         llvm_x86mmx_ty], [IntrNoMem]>;
626  def int_x86_ssse3_phsub_d_128     : GCCBuiltin<"__builtin_ia32_phsubd128">,
627              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
628                         llvm_v4i32_ty], [IntrNoMem]>;
629
630  def int_x86_ssse3_phsub_sw        : GCCBuiltin<"__builtin_ia32_phsubsw">,
631              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
632                         llvm_x86mmx_ty], [IntrNoMem]>;
633  def int_x86_ssse3_phsub_sw_128    : GCCBuiltin<"__builtin_ia32_phsubsw128">,
634              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
635                         llvm_v8i16_ty], [IntrNoMem]>;
636
637  def int_x86_ssse3_pmadd_ub_sw     : GCCBuiltin<"__builtin_ia32_pmaddubsw">,
638              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
639                         llvm_x86mmx_ty], [IntrNoMem]>;
640  def int_x86_ssse3_pmadd_ub_sw_128 : GCCBuiltin<"__builtin_ia32_pmaddubsw128">,
641              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty,
642                         llvm_v16i8_ty], [IntrNoMem]>;
643}
644
645// Packed multiply high with round and scale
646let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
647  def int_x86_ssse3_pmul_hr_sw      : GCCBuiltin<"__builtin_ia32_pmulhrsw">,
648              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
649                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
650  def int_x86_ssse3_pmul_hr_sw_128  : GCCBuiltin<"__builtin_ia32_pmulhrsw128">,
651              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
652                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
653}
654
655// Shuffle ops
656let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
657  def int_x86_ssse3_pshuf_b         : GCCBuiltin<"__builtin_ia32_pshufb">,
658              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
659                         llvm_x86mmx_ty], [IntrNoMem]>;
660  def int_x86_ssse3_pshuf_b_128     : GCCBuiltin<"__builtin_ia32_pshufb128">,
661              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
662                         llvm_v16i8_ty], [IntrNoMem]>;
663  def int_x86_sse2_pshuf_d          : GCCBuiltin<"__builtin_ia32_pshufd">,
664              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i8_ty],
665                         [IntrNoMem]>;
666  def int_x86_sse2_pshufl_w         : GCCBuiltin<"__builtin_ia32_pshuflw">,
667              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i8_ty],
668                         [IntrNoMem]>;
669  def int_x86_sse2_pshufh_w         : GCCBuiltin<"__builtin_ia32_pshufhw">,
670              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i8_ty],
671                         [IntrNoMem]>;
672  def int_x86_sse_pshuf_w           : GCCBuiltin<"__builtin_ia32_pshufw">,
673              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_i8_ty],
674                         [IntrNoMem]>;
675}
676
677// Sign ops
678let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
679  def int_x86_ssse3_psign_b         : GCCBuiltin<"__builtin_ia32_psignb">,
680              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
681                         llvm_x86mmx_ty], [IntrNoMem]>;
682  def int_x86_ssse3_psign_b_128     : GCCBuiltin<"__builtin_ia32_psignb128">,
683              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
684                         llvm_v16i8_ty], [IntrNoMem]>;
685
686  def int_x86_ssse3_psign_w         : GCCBuiltin<"__builtin_ia32_psignw">,
687              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
688                         llvm_x86mmx_ty], [IntrNoMem]>;
689  def int_x86_ssse3_psign_w_128     : GCCBuiltin<"__builtin_ia32_psignw128">,
690              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
691                         llvm_v8i16_ty], [IntrNoMem]>;
692
693  def int_x86_ssse3_psign_d         : GCCBuiltin<"__builtin_ia32_psignd">,
694              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
695                         llvm_x86mmx_ty], [IntrNoMem]>;
696  def int_x86_ssse3_psign_d_128     : GCCBuiltin<"__builtin_ia32_psignd128">,
697              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
698                         llvm_v4i32_ty], [IntrNoMem]>;
699}
700
701// Absolute value ops
702let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
703  def int_x86_ssse3_pabs_b     : GCCBuiltin<"__builtin_ia32_pabsb">,
704              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
705  def int_x86_ssse3_pabs_b_128 : GCCBuiltin<"__builtin_ia32_pabsb128">,
706              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>;
707
708  def int_x86_ssse3_pabs_w     : GCCBuiltin<"__builtin_ia32_pabsw">,
709              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
710  def int_x86_ssse3_pabs_w_128 : GCCBuiltin<"__builtin_ia32_pabsw128">,
711              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>;
712
713  def int_x86_ssse3_pabs_d     : GCCBuiltin<"__builtin_ia32_pabsd">,
714              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
715  def int_x86_ssse3_pabs_d_128 : GCCBuiltin<"__builtin_ia32_pabsd128">,
716              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
717}
718
719//===----------------------------------------------------------------------===//
720// SSE4.1
721
722// FP rounding ops
723let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
724  def int_x86_sse41_round_ss        : GCCBuiltin<"__builtin_ia32_roundss">,
725              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
726                         llvm_i32_ty], [IntrNoMem]>;
727  def int_x86_sse41_round_ps        : GCCBuiltin<"__builtin_ia32_roundps">,
728              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
729                         llvm_i32_ty], [IntrNoMem]>;
730  def int_x86_sse41_round_sd        : GCCBuiltin<"__builtin_ia32_roundsd">,
731              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
732                         llvm_i32_ty], [IntrNoMem]>;
733  def int_x86_sse41_round_pd        : GCCBuiltin<"__builtin_ia32_roundpd">,
734              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
735                         llvm_i32_ty], [IntrNoMem]>;
736}
737
738// Vector sign and zero extend
739let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
740  def int_x86_sse41_pmovsxbd        : GCCBuiltin<"__builtin_ia32_pmovsxbd128">,
741              Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty],
742                        [IntrNoMem]>;
743  def int_x86_sse41_pmovsxbq        : GCCBuiltin<"__builtin_ia32_pmovsxbq128">,
744              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty],
745                        [IntrNoMem]>;
746  def int_x86_sse41_pmovsxbw        : GCCBuiltin<"__builtin_ia32_pmovsxbw128">,
747              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty],
748                        [IntrNoMem]>;
749  def int_x86_sse41_pmovsxdq        : GCCBuiltin<"__builtin_ia32_pmovsxdq128">,
750              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty],
751                        [IntrNoMem]>;
752  def int_x86_sse41_pmovsxwd        : GCCBuiltin<"__builtin_ia32_pmovsxwd128">,
753              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty],
754                        [IntrNoMem]>;
755  def int_x86_sse41_pmovsxwq        : GCCBuiltin<"__builtin_ia32_pmovsxwq128">,
756              Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty],
757                        [IntrNoMem]>;
758  def int_x86_sse41_pmovzxbd        : GCCBuiltin<"__builtin_ia32_pmovzxbd128">,
759              Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty],
760                        [IntrNoMem]>;
761  def int_x86_sse41_pmovzxbq        : GCCBuiltin<"__builtin_ia32_pmovzxbq128">,
762              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty],
763                        [IntrNoMem]>;
764  def int_x86_sse41_pmovzxbw        : GCCBuiltin<"__builtin_ia32_pmovzxbw128">,
765              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty],
766                        [IntrNoMem]>;
767  def int_x86_sse41_pmovzxdq        : GCCBuiltin<"__builtin_ia32_pmovzxdq128">,
768              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty],
769                        [IntrNoMem]>;
770  def int_x86_sse41_pmovzxwd        : GCCBuiltin<"__builtin_ia32_pmovzxwd128">,
771              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty],
772                        [IntrNoMem]>;
773  def int_x86_sse41_pmovzxwq        : GCCBuiltin<"__builtin_ia32_pmovzxwq128">,
774              Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty],
775                        [IntrNoMem]>;
776}
777
778// Vector min element
779let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
780  def int_x86_sse41_phminposuw     : GCCBuiltin<"__builtin_ia32_phminposuw128">,
781              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty],
782                        [IntrNoMem]>;
783}
784
785// Vector compare, min, max
786let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
787  def int_x86_sse41_pmaxsb          : GCCBuiltin<"__builtin_ia32_pmaxsb128">,
788              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
789                        [IntrNoMem, Commutative]>;
790  def int_x86_sse41_pmaxsd          : GCCBuiltin<"__builtin_ia32_pmaxsd128">,
791              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
792                        [IntrNoMem, Commutative]>;
793  def int_x86_sse41_pmaxud          : GCCBuiltin<"__builtin_ia32_pmaxud128">,
794              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
795                        [IntrNoMem, Commutative]>;
796  def int_x86_sse41_pmaxuw          : GCCBuiltin<"__builtin_ia32_pmaxuw128">,
797              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
798                        [IntrNoMem, Commutative]>;
799  def int_x86_sse41_pminsb          : GCCBuiltin<"__builtin_ia32_pminsb128">,
800              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
801                        [IntrNoMem, Commutative]>;
802  def int_x86_sse41_pminsd          : GCCBuiltin<"__builtin_ia32_pminsd128">,
803              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
804                        [IntrNoMem, Commutative]>;
805  def int_x86_sse41_pminud          : GCCBuiltin<"__builtin_ia32_pminud128">,
806              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
807                        [IntrNoMem, Commutative]>;
808  def int_x86_sse41_pminuw          : GCCBuiltin<"__builtin_ia32_pminuw128">,
809              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
810                        [IntrNoMem, Commutative]>;
811}
812
813// Advanced Encryption Standard (AES) Instructions
814let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
815  def int_x86_aesni_aesimc          : GCCBuiltin<"__builtin_ia32_aesimc128">,
816              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty],
817                        [IntrNoMem]>;
818  def int_x86_aesni_aesenc          : GCCBuiltin<"__builtin_ia32_aesenc128">,
819              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
820                        [IntrNoMem]>;
821  def int_x86_aesni_aesenclast : GCCBuiltin<"__builtin_ia32_aesenclast128">,
822              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
823                        [IntrNoMem]>;
824  def int_x86_aesni_aesdec          : GCCBuiltin<"__builtin_ia32_aesdec128">,
825              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
826                        [IntrNoMem]>;
827  def int_x86_aesni_aesdeclast : GCCBuiltin<"__builtin_ia32_aesdeclast128">,
828              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
829                        [IntrNoMem]>;
830  def int_x86_aesni_aeskeygenassist :
831              GCCBuiltin<"__builtin_ia32_aeskeygenassist128">,
832              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty],
833                        [IntrNoMem]>;
834}
835
836// PCLMUL instruction
837let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
838  def int_x86_pclmulqdq : GCCBuiltin<"__builtin_ia32_pclmulqdq128">,
839          Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
840                    [IntrNoMem]>;
841}
842
843// Vector pack
844let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
845  def int_x86_sse41_packusdw        : GCCBuiltin<"__builtin_ia32_packusdw128">,
846              Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
847                        [IntrNoMem]>;
848}
849
850// Vector multiply
851let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
852  def int_x86_sse41_pmuldq          : GCCBuiltin<"__builtin_ia32_pmuldq128">,
853              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
854                        [IntrNoMem, Commutative]>;
855}
856
857// Vector extract
858let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
859  def int_x86_sse41_pextrb         :
860              Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
861                        [IntrNoMem]>;
862  def int_x86_sse41_pextrd         :
863              Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty],
864                        [IntrNoMem]>;
865  def int_x86_sse41_pextrq         :
866              Intrinsic<[llvm_i64_ty], [llvm_v2i64_ty, llvm_i32_ty],
867                        [IntrNoMem]>;
868  def int_x86_sse41_extractps      : GCCBuiltin<"__builtin_ia32_extractps128">,
869              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, llvm_i32_ty],
870                        [IntrNoMem]>;
871}
872
873// Vector insert
874let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
875  def int_x86_sse41_insertps       : GCCBuiltin<"__builtin_ia32_insertps128">,
876          Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
877                    [IntrNoMem]>;
878}
879
880// Vector blend
881let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
882  def int_x86_sse41_pblendvb         : GCCBuiltin<"__builtin_ia32_pblendvb128">,
883        Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,llvm_v16i8_ty],
884                  [IntrNoMem]>;
885  def int_x86_sse41_blendvpd         : GCCBuiltin<"__builtin_ia32_blendvpd">,
886        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,llvm_v2f64_ty],
887                  [IntrNoMem]>;
888  def int_x86_sse41_blendvps         : GCCBuiltin<"__builtin_ia32_blendvps">,
889        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,llvm_v4f32_ty],
890                  [IntrNoMem]>;
891}
892
893// Vector dot product
894let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
895  def int_x86_sse41_dppd            : GCCBuiltin<"__builtin_ia32_dppd">,
896          Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
897                    [IntrNoMem, Commutative]>;
898  def int_x86_sse41_dpps            : GCCBuiltin<"__builtin_ia32_dpps">,
899          Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
900                    [IntrNoMem, Commutative]>;
901}
902
903// Vector sum of absolute differences
904let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
905  def int_x86_sse41_mpsadbw         : GCCBuiltin<"__builtin_ia32_mpsadbw128">,
906          Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty,llvm_i8_ty],
907                    [IntrNoMem, Commutative]>;
908}
909
910// Cacheability support ops
911let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
912  def int_x86_sse41_movntdqa        : GCCBuiltin<"__builtin_ia32_movntdqa">,
913          Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
914}
915
916// Test instruction with bitwise comparison.
917let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
918  def int_x86_sse41_ptestz          : GCCBuiltin<"__builtin_ia32_ptestz128">,
919          Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
920                    [IntrNoMem]>;
921  def int_x86_sse41_ptestc          : GCCBuiltin<"__builtin_ia32_ptestc128">,
922          Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
923                    [IntrNoMem]>;
924  def int_x86_sse41_ptestnzc        : GCCBuiltin<"__builtin_ia32_ptestnzc128">,
925          Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
926                    [IntrNoMem]>;
927}
928
929//===----------------------------------------------------------------------===//
930// SSE4.2
931
932// Miscellaneous
933// CRC Instruction
934let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
935  def int_x86_sse42_crc32_32_8       : GCCBuiltin<"__builtin_ia32_crc32qi">,
936          Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i8_ty],
937                    [IntrNoMem]>;
938  def int_x86_sse42_crc32_32_16      : GCCBuiltin<"__builtin_ia32_crc32hi">,
939          Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i16_ty],
940                    [IntrNoMem]>;
941  def int_x86_sse42_crc32_32_32      : GCCBuiltin<"__builtin_ia32_crc32si">,
942          Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
943                    [IntrNoMem]>;
944  def int_x86_sse42_crc32_64_64      : GCCBuiltin<"__builtin_ia32_crc32di">,
945          Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty],
946                    [IntrNoMem]>;
947}
948
949// String/text processing ops.
950let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
951  def int_x86_sse42_pcmpistrm128  : GCCBuiltin<"__builtin_ia32_pcmpistrm128">,
952    Intrinsic<[llvm_v16i8_ty],
953        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
954        [IntrNoMem]>;
955  def int_x86_sse42_pcmpistri128  : GCCBuiltin<"__builtin_ia32_pcmpistri128">,
956    Intrinsic<[llvm_i32_ty],
957        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
958        [IntrNoMem]>;
959  def int_x86_sse42_pcmpistria128 : GCCBuiltin<"__builtin_ia32_pcmpistria128">,
960    Intrinsic<[llvm_i32_ty],
961        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
962        [IntrNoMem]>;
963  def int_x86_sse42_pcmpistric128 : GCCBuiltin<"__builtin_ia32_pcmpistric128">,
964    Intrinsic<[llvm_i32_ty],
965        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
966        [IntrNoMem]>;
967  def int_x86_sse42_pcmpistrio128 : GCCBuiltin<"__builtin_ia32_pcmpistrio128">,
968    Intrinsic<[llvm_i32_ty],
969        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
970        [IntrNoMem]>;
971  def int_x86_sse42_pcmpistris128 : GCCBuiltin<"__builtin_ia32_pcmpistris128">,
972    Intrinsic<[llvm_i32_ty],
973        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
974        [IntrNoMem]>;
975  def int_x86_sse42_pcmpistriz128 : GCCBuiltin<"__builtin_ia32_pcmpistriz128">,
976    Intrinsic<[llvm_i32_ty],
977        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
978        [IntrNoMem]>;
979  def int_x86_sse42_pcmpestrm128  : GCCBuiltin<"__builtin_ia32_pcmpestrm128">,
980    Intrinsic<[llvm_v16i8_ty],
981        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
982         llvm_i8_ty],
983        [IntrNoMem]>;
984  def int_x86_sse42_pcmpestri128  : GCCBuiltin<"__builtin_ia32_pcmpestri128">,
985    Intrinsic<[llvm_i32_ty],
986        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
987         llvm_i8_ty],
988        [IntrNoMem]>;
989  def int_x86_sse42_pcmpestria128 : GCCBuiltin<"__builtin_ia32_pcmpestria128">,
990    Intrinsic<[llvm_i32_ty],
991        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
992         llvm_i8_ty],
993        [IntrNoMem]>;
994  def int_x86_sse42_pcmpestric128 : GCCBuiltin<"__builtin_ia32_pcmpestric128">,
995    Intrinsic<[llvm_i32_ty],
996        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
997         llvm_i8_ty],
998        [IntrNoMem]>;
999  def int_x86_sse42_pcmpestrio128 : GCCBuiltin<"__builtin_ia32_pcmpestrio128">,
1000    Intrinsic<[llvm_i32_ty],
1001        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1002         llvm_i8_ty],
1003        [IntrNoMem]>;
1004  def int_x86_sse42_pcmpestris128 : GCCBuiltin<"__builtin_ia32_pcmpestris128">,
1005    Intrinsic<[llvm_i32_ty],
1006        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1007         llvm_i8_ty],
1008        [IntrNoMem]>;
1009  def int_x86_sse42_pcmpestriz128 : GCCBuiltin<"__builtin_ia32_pcmpestriz128">,
1010    Intrinsic<[llvm_i32_ty],
1011        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1012         llvm_i8_ty],
1013        [IntrNoMem]>;
1014}
1015
1016//===----------------------------------------------------------------------===//
1017// SSE4A
1018
1019let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1020  def int_x86_sse4a_extrqi : GCCBuiltin<"__builtin_ia32_extrqi">,
1021    Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty, llvm_i8_ty],
1022              [IntrNoMem]>;
1023  def int_x86_sse4a_extrq  : GCCBuiltin<"__builtin_ia32_extrq">,
1024    Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v16i8_ty], [IntrNoMem]>;
1025
1026  def int_x86_sse4a_insertqi : GCCBuiltin<"__builtin_ia32_insertqi">,
1027    Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
1028                                llvm_i8_ty, llvm_i8_ty], [IntrNoMem]>;
1029  def int_x86_sse4a_insertq  : GCCBuiltin<"__builtin_ia32_insertq">,
1030    Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>;
1031
1032  def int_x86_sse4a_movnt_ss : GCCBuiltin<"__builtin_ia32_movntss">,
1033    Intrinsic<[], [llvm_ptr_ty, llvm_v4f32_ty], []>;
1034  def int_x86_sse4a_movnt_sd : GCCBuiltin<"__builtin_ia32_movntsd">,
1035    Intrinsic<[], [llvm_ptr_ty, llvm_v2f64_ty], []>;
1036}
1037
1038//===----------------------------------------------------------------------===//
1039// AVX
1040
1041// Arithmetic ops
1042let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1043  def int_x86_avx_addsub_pd_256 : GCCBuiltin<"__builtin_ia32_addsubpd256">,
1044        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1045                  llvm_v4f64_ty], [IntrNoMem]>;
1046  def int_x86_avx_addsub_ps_256 : GCCBuiltin<"__builtin_ia32_addsubps256">,
1047        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1048                  llvm_v8f32_ty], [IntrNoMem]>;
1049  def int_x86_avx_max_pd_256 : GCCBuiltin<"__builtin_ia32_maxpd256">,
1050        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1051                  llvm_v4f64_ty], [IntrNoMem]>;
1052  def int_x86_avx_max_ps_256 : GCCBuiltin<"__builtin_ia32_maxps256">,
1053        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1054                  llvm_v8f32_ty], [IntrNoMem]>;
1055  def int_x86_avx_min_pd_256 : GCCBuiltin<"__builtin_ia32_minpd256">,
1056        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1057                  llvm_v4f64_ty], [IntrNoMem]>;
1058  def int_x86_avx_min_ps_256 : GCCBuiltin<"__builtin_ia32_minps256">,
1059        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1060                  llvm_v8f32_ty], [IntrNoMem]>;
1061
1062  def int_x86_avx_sqrt_pd_256 : GCCBuiltin<"__builtin_ia32_sqrtpd256">,
1063        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1064  def int_x86_avx_sqrt_ps_256 : GCCBuiltin<"__builtin_ia32_sqrtps256">,
1065        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1066
1067  def int_x86_avx_rsqrt_ps_256 : GCCBuiltin<"__builtin_ia32_rsqrtps256">,
1068        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1069
1070  def int_x86_avx_rcp_ps_256 : GCCBuiltin<"__builtin_ia32_rcpps256">,
1071        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1072
1073  def int_x86_avx_round_pd_256 : GCCBuiltin<"__builtin_ia32_roundpd256">,
1074        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1075                  llvm_i32_ty], [IntrNoMem]>;
1076  def int_x86_avx_round_ps_256 : GCCBuiltin<"__builtin_ia32_roundps256">,
1077        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1078                  llvm_i32_ty], [IntrNoMem]>;
1079}
1080
1081// Horizontal ops
1082let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1083  def int_x86_avx_hadd_pd_256 : GCCBuiltin<"__builtin_ia32_haddpd256">,
1084        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1085                  llvm_v4f64_ty], [IntrNoMem]>;
1086  def int_x86_avx_hsub_ps_256 : GCCBuiltin<"__builtin_ia32_hsubps256">,
1087        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1088                  llvm_v8f32_ty], [IntrNoMem]>;
1089  def int_x86_avx_hsub_pd_256 : GCCBuiltin<"__builtin_ia32_hsubpd256">,
1090        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1091                  llvm_v4f64_ty], [IntrNoMem]>;
1092  def int_x86_avx_hadd_ps_256 : GCCBuiltin<"__builtin_ia32_haddps256">,
1093        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1094                  llvm_v8f32_ty], [IntrNoMem]>;
1095}
1096
1097// Vector permutation
1098let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1099  def int_x86_avx_vpermilvar_pd : GCCBuiltin<"__builtin_ia32_vpermilvarpd">,
1100        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
1101                  llvm_v2i64_ty], [IntrNoMem]>;
1102  def int_x86_avx_vpermilvar_ps : GCCBuiltin<"__builtin_ia32_vpermilvarps">,
1103        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
1104                  llvm_v4i32_ty], [IntrNoMem]>;
1105
1106  def int_x86_avx_vpermilvar_pd_256 :
1107        GCCBuiltin<"__builtin_ia32_vpermilvarpd256">,
1108        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4i64_ty], [IntrNoMem]>;
1109  def int_x86_avx_vpermilvar_ps_256 :
1110        GCCBuiltin<"__builtin_ia32_vpermilvarps256">,
1111        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8i32_ty], [IntrNoMem]>;
1112
1113  def int_x86_avx_vperm2f128_pd_256 :
1114        GCCBuiltin<"__builtin_ia32_vperm2f128_pd256">,
1115        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1116                  llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1117  def int_x86_avx_vperm2f128_ps_256 :
1118        GCCBuiltin<"__builtin_ia32_vperm2f128_ps256">,
1119        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1120                  llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1121  def int_x86_avx_vperm2f128_si_256 :
1122        GCCBuiltin<"__builtin_ia32_vperm2f128_si256">,
1123        Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1124                  llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
1125
1126  def int_x86_avx512_mask_vpermt_d_512:
1127        GCCBuiltin<"__builtin_ia32_vpermt2vard512_mask">,
1128        Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1129                  llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1130
1131  def int_x86_avx512_mask_vpermt_q_512:
1132        GCCBuiltin<"__builtin_ia32_vpermt2varq512_mask">,
1133        Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1134                  llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1135
1136  def int_x86_avx512_mask_vpermt_ps_512:
1137        GCCBuiltin<"__builtin_ia32_vpermt2varps512_mask">,
1138        Intrinsic<[llvm_v16f32_ty], [llvm_v16i32_ty,
1139                  llvm_v16f32_ty, llvm_v16f32_ty, llvm_i16_ty], [IntrNoMem]>;
1140
1141  def int_x86_avx512_mask_vpermt_pd_512:
1142        GCCBuiltin<"__builtin_ia32_vpermt2varpd512_mask">,
1143        Intrinsic<[llvm_v8f64_ty], [llvm_v8i64_ty,
1144                  llvm_v8f64_ty, llvm_v8f64_ty, llvm_i8_ty], [IntrNoMem]>;
1145
1146}
1147
1148// Vector blend
1149let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1150  def int_x86_avx_blendv_pd_256 : GCCBuiltin<"__builtin_ia32_blendvpd256">,
1151        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1152                  llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>;
1153  def int_x86_avx_blendv_ps_256 : GCCBuiltin<"__builtin_ia32_blendvps256">,
1154        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1155                  llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>;
1156}
1157
1158// Vector dot product
1159let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1160  def int_x86_avx_dp_ps_256 : GCCBuiltin<"__builtin_ia32_dpps256">,
1161        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1162                  llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1163}
1164
1165// Vector compare
1166let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1167  def int_x86_avx_cmp_pd_256 : GCCBuiltin<"__builtin_ia32_cmppd256">,
1168        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1169                  llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1170  def int_x86_avx_cmp_ps_256 : GCCBuiltin<"__builtin_ia32_cmpps256">,
1171        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1172                  llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1173}
1174
1175// Vector convert
1176let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1177  def int_x86_avx_cvtdq2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtdq2pd256">,
1178        Intrinsic<[llvm_v4f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1179  def int_x86_avx_cvtdq2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtdq2ps256">,
1180        Intrinsic<[llvm_v8f32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
1181  def int_x86_avx_cvt_pd2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtpd2ps256">,
1182        Intrinsic<[llvm_v4f32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1183  def int_x86_avx_cvt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvtps2dq256">,
1184        Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1185  def int_x86_avx_cvt_ps2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtps2pd256">,
1186        Intrinsic<[llvm_v4f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1187  def int_x86_avx_cvtt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvttpd2dq256">,
1188        Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1189  def int_x86_avx_cvt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvtpd2dq256">,
1190        Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1191  def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">,
1192        Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1193}
1194
1195// Vector bit test
1196let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1197  def int_x86_avx_vtestz_pd : GCCBuiltin<"__builtin_ia32_vtestzpd">,
1198        Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1199                  llvm_v2f64_ty], [IntrNoMem]>;
1200  def int_x86_avx_vtestc_pd : GCCBuiltin<"__builtin_ia32_vtestcpd">,
1201        Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1202                  llvm_v2f64_ty], [IntrNoMem]>;
1203  def int_x86_avx_vtestnzc_pd : GCCBuiltin<"__builtin_ia32_vtestnzcpd">,
1204        Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1205                  llvm_v2f64_ty], [IntrNoMem]>;
1206  def int_x86_avx_vtestz_ps : GCCBuiltin<"__builtin_ia32_vtestzps">,
1207        Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1208                  llvm_v4f32_ty], [IntrNoMem]>;
1209  def int_x86_avx_vtestc_ps : GCCBuiltin<"__builtin_ia32_vtestcps">,
1210        Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1211                  llvm_v4f32_ty], [IntrNoMem]>;
1212  def int_x86_avx_vtestnzc_ps : GCCBuiltin<"__builtin_ia32_vtestnzcps">,
1213        Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1214                  llvm_v4f32_ty], [IntrNoMem]>;
1215  def int_x86_avx_vtestz_pd_256 : GCCBuiltin<"__builtin_ia32_vtestzpd256">,
1216        Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1217                  llvm_v4f64_ty], [IntrNoMem]>;
1218  def int_x86_avx_vtestc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestcpd256">,
1219        Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1220                  llvm_v4f64_ty], [IntrNoMem]>;
1221  def int_x86_avx_vtestnzc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestnzcpd256">,
1222        Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1223                  llvm_v4f64_ty], [IntrNoMem]>;
1224  def int_x86_avx_vtestz_ps_256 : GCCBuiltin<"__builtin_ia32_vtestzps256">,
1225        Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1226                  llvm_v8f32_ty], [IntrNoMem]>;
1227  def int_x86_avx_vtestc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestcps256">,
1228        Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1229                  llvm_v8f32_ty], [IntrNoMem]>;
1230  def int_x86_avx_vtestnzc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestnzcps256">,
1231        Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1232                  llvm_v8f32_ty], [IntrNoMem]>;
1233  def int_x86_avx_ptestz_256 : GCCBuiltin<"__builtin_ia32_ptestz256">,
1234        Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1235                  llvm_v4i64_ty], [IntrNoMem]>;
1236  def int_x86_avx_ptestc_256 : GCCBuiltin<"__builtin_ia32_ptestc256">,
1237        Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1238                  llvm_v4i64_ty], [IntrNoMem]>;
1239  def int_x86_avx_ptestnzc_256 : GCCBuiltin<"__builtin_ia32_ptestnzc256">,
1240        Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1241                  llvm_v4i64_ty], [IntrNoMem]>;
1242  def int_x86_avx512_mask_ptestm_d_512 : GCCBuiltin<"__builtin_ia32_ptestmd512">,
1243        Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
1244                  llvm_i16_ty], [IntrNoMem]>;
1245  def int_x86_avx512_mask_ptestm_q_512 : GCCBuiltin<"__builtin_ia32_ptestmq512">,
1246        Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
1247                  llvm_i8_ty], [IntrNoMem]>;
1248}
1249
1250// Vector extract sign mask
1251let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1252  def int_x86_avx_movmsk_pd_256 : GCCBuiltin<"__builtin_ia32_movmskpd256">,
1253        Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1254  def int_x86_avx_movmsk_ps_256 : GCCBuiltin<"__builtin_ia32_movmskps256">,
1255        Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1256}
1257
1258// Vector zero
1259let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1260  def int_x86_avx_vzeroall : GCCBuiltin<"__builtin_ia32_vzeroall">,
1261        Intrinsic<[], [], []>;
1262  def int_x86_avx_vzeroupper : GCCBuiltin<"__builtin_ia32_vzeroupper">,
1263        Intrinsic<[], [], []>;
1264}
1265
1266// Vector load with broadcast
1267let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1268  def int_x86_avx_vbroadcastf128_pd_256 :
1269        GCCBuiltin<"__builtin_ia32_vbroadcastf128_pd256">,
1270        Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1271  def int_x86_avx_vbroadcastf128_ps_256 :
1272        GCCBuiltin<"__builtin_ia32_vbroadcastf128_ps256">,
1273        Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1274}
1275
1276// SIMD load ops
1277let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1278  def int_x86_avx_ldu_dq_256 : GCCBuiltin<"__builtin_ia32_lddqu256">,
1279        Intrinsic<[llvm_v32i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
1280}
1281
1282// SIMD store ops
1283let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1284  def int_x86_avx_storeu_pd_256 : GCCBuiltin<"__builtin_ia32_storeupd256">,
1285        Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty], [IntrReadWriteArgMem]>;
1286  def int_x86_avx_storeu_ps_256 : GCCBuiltin<"__builtin_ia32_storeups256">,
1287        Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty], [IntrReadWriteArgMem]>;
1288  def int_x86_avx_storeu_dq_256 : GCCBuiltin<"__builtin_ia32_storedqu256">,
1289        Intrinsic<[], [llvm_ptr_ty, llvm_v32i8_ty], [IntrReadWriteArgMem]>;
1290}
1291
1292// Conditional load ops
1293let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1294  def int_x86_avx_maskload_pd : GCCBuiltin<"__builtin_ia32_maskloadpd">,
1295        Intrinsic<[llvm_v2f64_ty], [llvm_ptr_ty, llvm_v2f64_ty],
1296                  [IntrReadArgMem]>;
1297  def int_x86_avx_maskload_ps : GCCBuiltin<"__builtin_ia32_maskloadps">,
1298        Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty, llvm_v4f32_ty],
1299                  [IntrReadArgMem]>;
1300  def int_x86_avx_maskload_pd_256 : GCCBuiltin<"__builtin_ia32_maskloadpd256">,
1301        Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty, llvm_v4f64_ty],
1302                  [IntrReadArgMem]>;
1303  def int_x86_avx_maskload_ps_256 : GCCBuiltin<"__builtin_ia32_maskloadps256">,
1304        Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty, llvm_v8f32_ty],
1305                  [IntrReadArgMem]>;
1306  def int_x86_avx512_mask_loadu_ps_512 : GCCBuiltin<"__builtin_ia32_loadups512_mask">,
1307        Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1308                  [IntrReadArgMem]>;
1309  def int_x86_avx512_mask_loadu_pd_512 : GCCBuiltin<"__builtin_ia32_loadupd512_mask">,
1310        Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1311                  [IntrReadArgMem]>;
1312  def int_x86_avx512_mask_load_ps_512 : GCCBuiltin<"__builtin_ia32_loadaps512_mask">,
1313        Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1314                  [IntrReadArgMem]>;
1315  def int_x86_avx512_mask_load_pd_512 : GCCBuiltin<"__builtin_ia32_loadapd512_mask">,
1316        Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1317                  [IntrReadArgMem]>;
1318}
1319
1320// Conditional store ops
1321let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1322  def int_x86_avx_maskstore_pd : GCCBuiltin<"__builtin_ia32_maskstorepd">,
1323        Intrinsic<[], [llvm_ptr_ty,
1324                  llvm_v2f64_ty, llvm_v2f64_ty], [IntrReadWriteArgMem]>;
1325  def int_x86_avx_maskstore_ps : GCCBuiltin<"__builtin_ia32_maskstoreps">,
1326        Intrinsic<[], [llvm_ptr_ty,
1327                  llvm_v4f32_ty, llvm_v4f32_ty], [IntrReadWriteArgMem]>;
1328  def int_x86_avx_maskstore_pd_256 :
1329        GCCBuiltin<"__builtin_ia32_maskstorepd256">,
1330        Intrinsic<[], [llvm_ptr_ty,
1331                  llvm_v4f64_ty, llvm_v4f64_ty], [IntrReadWriteArgMem]>;
1332  def int_x86_avx_maskstore_ps_256 :
1333        GCCBuiltin<"__builtin_ia32_maskstoreps256">,
1334        Intrinsic<[], [llvm_ptr_ty,
1335                  llvm_v8f32_ty, llvm_v8f32_ty], [IntrReadWriteArgMem]>;
1336  def int_x86_avx512_mask_storeu_ps_512 :
1337        GCCBuiltin<"__builtin_ia32_storeups512_mask">,
1338        Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1339                  [IntrReadWriteArgMem]>;
1340  def int_x86_avx512_mask_storeu_pd_512 :
1341        GCCBuiltin<"__builtin_ia32_storeupd512_mask">,
1342        Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1343                  [IntrReadWriteArgMem]>;
1344  def int_x86_avx512_mask_store_ps_512 :
1345        GCCBuiltin<"__builtin_ia32_storeaps512_mask">,
1346        Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1347                  [IntrReadWriteArgMem]>;
1348  def int_x86_avx512_mask_store_pd_512 :
1349        GCCBuiltin<"__builtin_ia32_storeapd512_mask">,
1350        Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1351                  [IntrReadWriteArgMem]>;
1352  def int_x86_avx512_mask_store_ss :
1353        GCCBuiltin<"__builtin_ia32_storess_mask">,
1354        Intrinsic<[], [llvm_ptr_ty, llvm_v4f32_ty, llvm_i8_ty],
1355                  [IntrReadWriteArgMem]>;
1356}
1357
1358//===----------------------------------------------------------------------===//
1359// AVX2
1360
1361// Integer arithmetic ops.
1362let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1363  def int_x86_avx2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb256">,
1364              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1365                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1366  def int_x86_avx2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw256">,
1367              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1368                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1369  def int_x86_avx2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb256">,
1370              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1371                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1372  def int_x86_avx2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw256">,
1373              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1374                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1375  def int_x86_avx2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb256">,
1376              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1377                         llvm_v32i8_ty], [IntrNoMem]>;
1378  def int_x86_avx2_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw256">,
1379              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1380                         llvm_v16i16_ty], [IntrNoMem]>;
1381  def int_x86_avx2_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb256">,
1382              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1383                         llvm_v32i8_ty], [IntrNoMem]>;
1384  def int_x86_avx2_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw256">,
1385              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1386                         llvm_v16i16_ty], [IntrNoMem]>;
1387  def int_x86_avx2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw256">,
1388              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1389                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1390  def int_x86_avx2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw256">,
1391              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1392                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1393  def int_x86_avx2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq256">,
1394              Intrinsic<[llvm_v4i64_ty], [llvm_v8i32_ty,
1395                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1396  def int_x86_avx2_pmul_dq : GCCBuiltin<"__builtin_ia32_pmuldq256">,
1397              Intrinsic<[llvm_v4i64_ty], [llvm_v8i32_ty,
1398                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1399  def int_x86_avx2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd256">,
1400              Intrinsic<[llvm_v8i32_ty], [llvm_v16i16_ty,
1401                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1402  def int_x86_avx2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb256">,
1403              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1404                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1405  def int_x86_avx2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw256">,
1406              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1407                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1408  def int_x86_avx2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw256">,
1409              Intrinsic<[llvm_v4i64_ty], [llvm_v32i8_ty,
1410                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1411}
1412
1413// Vector min, max
1414let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1415  def int_x86_avx2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub256">,
1416              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1417                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1418  def int_x86_avx2_pmaxu_w : GCCBuiltin<"__builtin_ia32_pmaxuw256">,
1419              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1420                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1421  def int_x86_avx2_pmaxu_d : GCCBuiltin<"__builtin_ia32_pmaxud256">,
1422              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1423                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1424  def int_x86_avx2_pmaxs_b : GCCBuiltin<"__builtin_ia32_pmaxsb256">,
1425              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1426                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1427  def int_x86_avx2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw256">,
1428              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1429                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1430  def int_x86_avx2_pmaxs_d : GCCBuiltin<"__builtin_ia32_pmaxsd256">,
1431              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1432                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1433  def int_x86_avx2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub256">,
1434              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1435                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1436  def int_x86_avx2_pminu_w : GCCBuiltin<"__builtin_ia32_pminuw256">,
1437              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1438                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1439  def int_x86_avx2_pminu_d : GCCBuiltin<"__builtin_ia32_pminud256">,
1440              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1441                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1442  def int_x86_avx2_pmins_b : GCCBuiltin<"__builtin_ia32_pminsb256">,
1443              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1444                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1445  def int_x86_avx2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw256">,
1446              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1447                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1448  def int_x86_avx2_pmins_d : GCCBuiltin<"__builtin_ia32_pminsd256">,
1449              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1450                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1451  def int_x86_avx512_mask_pmaxu_d_512 : GCCBuiltin<"__builtin_ia32_pmaxud512_mask">,
1452              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
1453                         llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1454  def int_x86_avx512_mask_pmaxs_d_512 : GCCBuiltin<"__builtin_ia32_pmaxsd512_mask">,
1455              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
1456                         llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1457  def int_x86_avx512_mask_pmaxu_q_512 : GCCBuiltin<"__builtin_ia32_pmaxuq512_mask">,
1458              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
1459                         llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1460  def int_x86_avx512_mask_pmaxs_q_512 : GCCBuiltin<"__builtin_ia32_pmaxsq512_mask">,
1461              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
1462                         llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1463  def int_x86_avx512_mask_pminu_d_512 : GCCBuiltin<"__builtin_ia32_pminud512_mask">,
1464              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
1465                         llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1466  def int_x86_avx512_mask_pmins_d_512 : GCCBuiltin<"__builtin_ia32_pminsd512_mask">,
1467              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
1468                         llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1469  def int_x86_avx512_mask_pminu_q_512 : GCCBuiltin<"__builtin_ia32_pminuq512_mask">,
1470              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
1471                         llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1472  def int_x86_avx512_mask_pmins_q_512 : GCCBuiltin<"__builtin_ia32_pminsq512_mask">,
1473              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
1474                         llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1475}
1476
1477// Integer shift ops.
1478let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1479  def int_x86_avx2_psll_w : GCCBuiltin<"__builtin_ia32_psllw256">,
1480              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1481                         llvm_v8i16_ty], [IntrNoMem]>;
1482  def int_x86_avx2_psll_d : GCCBuiltin<"__builtin_ia32_pslld256">,
1483              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1484                         llvm_v4i32_ty], [IntrNoMem]>;
1485  def int_x86_avx2_psll_q : GCCBuiltin<"__builtin_ia32_psllq256">,
1486              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1487                         llvm_v2i64_ty], [IntrNoMem]>;
1488  def int_x86_avx2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw256">,
1489              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1490                         llvm_v8i16_ty], [IntrNoMem]>;
1491  def int_x86_avx2_psrl_d : GCCBuiltin<"__builtin_ia32_psrld256">,
1492              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1493                         llvm_v4i32_ty], [IntrNoMem]>;
1494  def int_x86_avx2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq256">,
1495              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1496                         llvm_v2i64_ty], [IntrNoMem]>;
1497  def int_x86_avx2_psra_w : GCCBuiltin<"__builtin_ia32_psraw256">,
1498              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1499                         llvm_v8i16_ty], [IntrNoMem]>;
1500  def int_x86_avx2_psra_d : GCCBuiltin<"__builtin_ia32_psrad256">,
1501              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1502                         llvm_v4i32_ty], [IntrNoMem]>;
1503
1504  def int_x86_avx2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi256">,
1505              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1506                         llvm_i32_ty], [IntrNoMem]>;
1507  def int_x86_avx2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi256">,
1508              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1509                         llvm_i32_ty], [IntrNoMem]>;
1510  def int_x86_avx2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi256">,
1511              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1512                         llvm_i32_ty], [IntrNoMem]>;
1513  def int_x86_avx2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi256">,
1514              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1515                         llvm_i32_ty], [IntrNoMem]>;
1516  def int_x86_avx2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi256">,
1517              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1518                         llvm_i32_ty], [IntrNoMem]>;
1519  def int_x86_avx2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi256">,
1520              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1521                         llvm_i32_ty], [IntrNoMem]>;
1522  def int_x86_avx2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi256">,
1523              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1524                         llvm_i32_ty], [IntrNoMem]>;
1525  def int_x86_avx2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi256">,
1526              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1527                         llvm_i32_ty], [IntrNoMem]>;
1528
1529  def int_x86_avx512_mask_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi512">,
1530              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1531                         llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1532  def int_x86_avx512_mask_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi512">,
1533              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1534                         llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1535  def int_x86_avx512_mask_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi512">,
1536              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1537                         llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1538  def int_x86_avx512_mask_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi512">,
1539              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1540                         llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1541  def int_x86_avx512_mask_psrai_d : GCCBuiltin<"__builtin_ia32_psradi512">,
1542              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1543                         llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1544  def int_x86_avx512_mask_psrai_q : GCCBuiltin<"__builtin_ia32_psraqi512">,
1545              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1546                         llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1547
1548  def int_x86_avx512_mask_psll_d : GCCBuiltin<"__builtin_ia32_pslld512_mask">,
1549              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1550                         llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1551  def int_x86_avx512_mask_psll_q : GCCBuiltin<"__builtin_ia32_psllq512_mask">,
1552              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1553                         llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1554  def int_x86_avx512_mask_psrl_d : GCCBuiltin<"__builtin_ia32_psrld512_mask">,
1555              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1556                         llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1557  def int_x86_avx512_mask_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq512_mask">,
1558              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1559                         llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1560  def int_x86_avx512_mask_psra_d : GCCBuiltin<"__builtin_ia32_psrad512_mask">,
1561              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1562                         llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1563  def int_x86_avx512_mask_psra_q : GCCBuiltin<"__builtin_ia32_psraq512_mask">,
1564              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1565                         llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1566}
1567
1568// Pack ops.
1569let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1570  def int_x86_avx2_packsswb : GCCBuiltin<"__builtin_ia32_packsswb256">,
1571              Intrinsic<[llvm_v32i8_ty], [llvm_v16i16_ty,
1572                         llvm_v16i16_ty], [IntrNoMem]>;
1573  def int_x86_avx2_packssdw : GCCBuiltin<"__builtin_ia32_packssdw256">,
1574              Intrinsic<[llvm_v16i16_ty], [llvm_v8i32_ty,
1575                         llvm_v8i32_ty], [IntrNoMem]>;
1576  def int_x86_avx2_packuswb : GCCBuiltin<"__builtin_ia32_packuswb256">,
1577              Intrinsic<[llvm_v32i8_ty], [llvm_v16i16_ty,
1578                         llvm_v16i16_ty], [IntrNoMem]>;
1579  def int_x86_avx2_packusdw : GCCBuiltin<"__builtin_ia32_packusdw256">,
1580              Intrinsic<[llvm_v16i16_ty], [llvm_v8i32_ty,
1581                         llvm_v8i32_ty], [IntrNoMem]>;
1582}
1583
1584// Absolute value ops
1585let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1586  def int_x86_avx2_pabs_b : GCCBuiltin<"__builtin_ia32_pabsb256">,
1587              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty], [IntrNoMem]>;
1588  def int_x86_avx2_pabs_w : GCCBuiltin<"__builtin_ia32_pabsw256">,
1589              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty], [IntrNoMem]>;
1590  def int_x86_avx2_pabs_d : GCCBuiltin<"__builtin_ia32_pabsd256">,
1591              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
1592  def int_x86_avx512_mask_pabs_d_512 : GCCBuiltin<"__builtin_ia32_pabsd512_mask">,
1593              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
1594                                           llvm_i16_ty], [IntrNoMem]>;
1595  def int_x86_avx512_mask_pabs_q_512 : GCCBuiltin<"__builtin_ia32_pabsq512_mask">,
1596              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
1597                                          llvm_i8_ty], [IntrNoMem]>;
1598}
1599
1600// Horizontal arithmetic ops
1601let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1602  def int_x86_avx2_phadd_w : GCCBuiltin<"__builtin_ia32_phaddw256">,
1603              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1604                         llvm_v16i16_ty], [IntrNoMem]>;
1605  def int_x86_avx2_phadd_d : GCCBuiltin<"__builtin_ia32_phaddd256">,
1606              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1607                         llvm_v8i32_ty], [IntrNoMem]>;
1608  def int_x86_avx2_phadd_sw : GCCBuiltin<"__builtin_ia32_phaddsw256">,
1609              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1610                         llvm_v16i16_ty], [IntrNoMem]>;
1611  def int_x86_avx2_phsub_w : GCCBuiltin<"__builtin_ia32_phsubw256">,
1612              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1613                         llvm_v16i16_ty], [IntrNoMem]>;
1614  def int_x86_avx2_phsub_d : GCCBuiltin<"__builtin_ia32_phsubd256">,
1615              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1616                         llvm_v8i32_ty], [IntrNoMem]>;
1617  def int_x86_avx2_phsub_sw : GCCBuiltin<"__builtin_ia32_phsubsw256">,
1618              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1619                         llvm_v16i16_ty], [IntrNoMem]>;
1620  def int_x86_avx2_pmadd_ub_sw : GCCBuiltin<"__builtin_ia32_pmaddubsw256">,
1621              Intrinsic<[llvm_v16i16_ty], [llvm_v32i8_ty,
1622                         llvm_v32i8_ty], [IntrNoMem]>;
1623}
1624
1625// Sign ops
1626let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1627  def int_x86_avx2_psign_b : GCCBuiltin<"__builtin_ia32_psignb256">,
1628              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1629                         llvm_v32i8_ty], [IntrNoMem]>;
1630  def int_x86_avx2_psign_w : GCCBuiltin<"__builtin_ia32_psignw256">,
1631              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1632                         llvm_v16i16_ty], [IntrNoMem]>;
1633  def int_x86_avx2_psign_d : GCCBuiltin<"__builtin_ia32_psignd256">,
1634              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1635                         llvm_v8i32_ty], [IntrNoMem]>;
1636}
1637
1638// Packed multiply high with round and scale
1639let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1640  def int_x86_avx2_pmul_hr_sw : GCCBuiltin<"__builtin_ia32_pmulhrsw256">,
1641              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1642                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1643}
1644
1645// Vector sign and zero extend
1646let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1647  def int_x86_avx2_pmovsxbd : GCCBuiltin<"__builtin_ia32_pmovsxbd256">,
1648              Intrinsic<[llvm_v8i32_ty], [llvm_v16i8_ty],
1649                        [IntrNoMem]>;
1650  def int_x86_avx2_pmovsxbq : GCCBuiltin<"__builtin_ia32_pmovsxbq256">,
1651              Intrinsic<[llvm_v4i64_ty], [llvm_v16i8_ty],
1652                        [IntrNoMem]>;
1653  def int_x86_avx2_pmovsxbw : GCCBuiltin<"__builtin_ia32_pmovsxbw256">,
1654              Intrinsic<[llvm_v16i16_ty], [llvm_v16i8_ty],
1655                        [IntrNoMem]>;
1656  def int_x86_avx2_pmovsxdq : GCCBuiltin<"__builtin_ia32_pmovsxdq256">,
1657              Intrinsic<[llvm_v4i64_ty], [llvm_v4i32_ty],
1658                        [IntrNoMem]>;
1659  def int_x86_avx2_pmovsxwd : GCCBuiltin<"__builtin_ia32_pmovsxwd256">,
1660              Intrinsic<[llvm_v8i32_ty], [llvm_v8i16_ty],
1661                        [IntrNoMem]>;
1662  def int_x86_avx2_pmovsxwq : GCCBuiltin<"__builtin_ia32_pmovsxwq256">,
1663              Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty],
1664                        [IntrNoMem]>;
1665  def int_x86_avx2_pmovzxbd : GCCBuiltin<"__builtin_ia32_pmovzxbd256">,
1666              Intrinsic<[llvm_v8i32_ty], [llvm_v16i8_ty],
1667                        [IntrNoMem]>;
1668  def int_x86_avx2_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq256">,
1669              Intrinsic<[llvm_v4i64_ty], [llvm_v16i8_ty],
1670                        [IntrNoMem]>;
1671  def int_x86_avx2_pmovzxbw : GCCBuiltin<"__builtin_ia32_pmovzxbw256">,
1672              Intrinsic<[llvm_v16i16_ty], [llvm_v16i8_ty],
1673                        [IntrNoMem]>;
1674  def int_x86_avx2_pmovzxdq : GCCBuiltin<"__builtin_ia32_pmovzxdq256">,
1675              Intrinsic<[llvm_v4i64_ty], [llvm_v4i32_ty],
1676                        [IntrNoMem]>;
1677  def int_x86_avx2_pmovzxwd : GCCBuiltin<"__builtin_ia32_pmovzxwd256">,
1678              Intrinsic<[llvm_v8i32_ty], [llvm_v8i16_ty],
1679                        [IntrNoMem]>;
1680  def int_x86_avx2_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq256">,
1681              Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty],
1682                        [IntrNoMem]>;
1683}
1684
1685// Vector blend
1686let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1687  def int_x86_avx2_pblendvb : GCCBuiltin<"__builtin_ia32_pblendvb256">,
1688              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty,
1689                         llvm_v32i8_ty], [IntrNoMem]>;
1690}
1691
1692// Vector load with broadcast
1693let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1694  def int_x86_avx2_vbroadcast_ss_ps :
1695              GCCBuiltin<"__builtin_ia32_vbroadcastss_ps">,
1696              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1697  def int_x86_avx2_vbroadcast_sd_pd_256 :
1698              GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd256">,
1699              Intrinsic<[llvm_v4f64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
1700  def int_x86_avx2_vbroadcast_ss_ps_256 :
1701              GCCBuiltin<"__builtin_ia32_vbroadcastss_ps256">,
1702              Intrinsic<[llvm_v8f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1703  def int_x86_avx2_pbroadcastb_128 :
1704              GCCBuiltin<"__builtin_ia32_pbroadcastb128">,
1705              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>;
1706  def int_x86_avx2_pbroadcastb_256 :
1707              GCCBuiltin<"__builtin_ia32_pbroadcastb256">,
1708              Intrinsic<[llvm_v32i8_ty], [llvm_v16i8_ty], [IntrNoMem]>;
1709  def int_x86_avx2_pbroadcastw_128 :
1710              GCCBuiltin<"__builtin_ia32_pbroadcastw128">,
1711              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>;
1712  def int_x86_avx2_pbroadcastw_256 :
1713              GCCBuiltin<"__builtin_ia32_pbroadcastw256">,
1714              Intrinsic<[llvm_v16i16_ty], [llvm_v8i16_ty], [IntrNoMem]>;
1715  def int_x86_avx2_pbroadcastd_128 :
1716              GCCBuiltin<"__builtin_ia32_pbroadcastd128">,
1717              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1718  def int_x86_avx2_pbroadcastd_256 :
1719              GCCBuiltin<"__builtin_ia32_pbroadcastd256">,
1720              Intrinsic<[llvm_v8i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1721  def int_x86_avx2_pbroadcastq_128 :
1722              GCCBuiltin<"__builtin_ia32_pbroadcastq128">,
1723              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], [IntrNoMem]>;
1724  def int_x86_avx2_pbroadcastq_256 :
1725              GCCBuiltin<"__builtin_ia32_pbroadcastq256">,
1726              Intrinsic<[llvm_v4i64_ty], [llvm_v2i64_ty], [IntrNoMem]>;
1727  def int_x86_avx512_mask_pbroadcast_d_gpr_512 :
1728              GCCBuiltin<"__builtin_ia32_pbroadcastd512_gpr_mask">,
1729              Intrinsic<[llvm_v16i32_ty], [llvm_i32_ty, llvm_v16i32_ty,
1730              llvm_i16_ty], [IntrNoMem]>;
1731  def int_x86_avx512_mask_pbroadcast_q_gpr_512 :
1732              GCCBuiltin<"__builtin_ia32_pbroadcastq512_gpr_mask">,
1733              Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty, llvm_v8i64_ty,
1734              llvm_i8_ty], [IntrNoMem]>;
1735  def int_x86_avx512_mask_pbroadcast_q_mem_512 :
1736              GCCBuiltin<"__builtin_ia32_pbroadcastq512_mem_mask">,
1737              Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty, llvm_v8i64_ty,
1738              llvm_i8_ty], [IntrNoMem]>;
1739}
1740
1741// Vector permutation
1742let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1743  def int_x86_avx2_permd : GCCBuiltin<"__builtin_ia32_permvarsi256">,
1744              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
1745                        [IntrNoMem]>;
1746  def int_x86_avx2_permps : GCCBuiltin<"__builtin_ia32_permvarsf256">,
1747              Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty],
1748                        [IntrNoMem]>;
1749  def int_x86_avx2_vperm2i128 : GCCBuiltin<"__builtin_ia32_permti256">,
1750              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1751                         llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
1752}
1753
1754// Vector extract and insert
1755let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1756  def int_x86_avx512_mask_vextractf32x4_512 :
1757      GCCBuiltin<"__builtin_ia32_extractf32x4_mask">,
1758                 Intrinsic<[llvm_v4f32_ty], [llvm_v16f32_ty, llvm_i8_ty,
1759                           llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
1760  def int_x86_avx512_mask_vextracti32x4_512 :
1761      GCCBuiltin<"__builtin_ia32_extracti32x4_mask">,
1762                 Intrinsic<[llvm_v4i32_ty], [llvm_v16i32_ty, llvm_i8_ty,
1763                           llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
1764  def int_x86_avx512_mask_vextractf64x4_512 :
1765      GCCBuiltin<"__builtin_ia32_extractf64x4_mask">,
1766                 Intrinsic<[llvm_v4f64_ty], [llvm_v8f64_ty, llvm_i8_ty,
1767                           llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1768  def int_x86_avx512_mask_vextracti64x4_512 :
1769      GCCBuiltin<"__builtin_ia32_extracti64x4_mask">,
1770                 Intrinsic<[llvm_v4i64_ty], [llvm_v8i64_ty, llvm_i8_ty,
1771                           llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
1772}
1773
1774// Conditional load ops
1775let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1776  def int_x86_avx2_maskload_d : GCCBuiltin<"__builtin_ia32_maskloadd">,
1777        Intrinsic<[llvm_v4i32_ty], [llvm_ptr_ty, llvm_v4i32_ty],
1778                  [IntrReadArgMem]>;
1779  def int_x86_avx2_maskload_q : GCCBuiltin<"__builtin_ia32_maskloadq">,
1780        Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_v2i64_ty],
1781                  [IntrReadArgMem]>;
1782  def int_x86_avx2_maskload_d_256 : GCCBuiltin<"__builtin_ia32_maskloadd256">,
1783        Intrinsic<[llvm_v8i32_ty], [llvm_ptr_ty, llvm_v8i32_ty],
1784                  [IntrReadArgMem]>;
1785  def int_x86_avx2_maskload_q_256 : GCCBuiltin<"__builtin_ia32_maskloadq256">,
1786        Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty, llvm_v4i64_ty],
1787                  [IntrReadArgMem]>;
1788  def int_x86_avx512_mask_loadu_d_512 : GCCBuiltin<"__builtin_ia32_loaddqusi512_mask">,
1789        Intrinsic<[llvm_v16i32_ty], [llvm_ptr_ty, llvm_v16i32_ty, llvm_i16_ty],
1790                  [IntrReadArgMem]>;
1791  def int_x86_avx512_mask_loadu_q_512 : GCCBuiltin<"__builtin_ia32_loaddqudi512_mask">,
1792        Intrinsic<[llvm_v8i64_ty], [llvm_ptr_ty, llvm_v8i64_ty, llvm_i8_ty],
1793                  [IntrReadArgMem]>;
1794}
1795
1796// Conditional store ops
1797let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1798  def int_x86_avx2_maskstore_d : GCCBuiltin<"__builtin_ia32_maskstored">,
1799        Intrinsic<[], [llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i32_ty],
1800                  [IntrReadWriteArgMem]>;
1801  def int_x86_avx2_maskstore_q : GCCBuiltin<"__builtin_ia32_maskstoreq">,
1802        Intrinsic<[], [llvm_ptr_ty, llvm_v2i64_ty, llvm_v2i64_ty],
1803                  [IntrReadWriteArgMem]>;
1804  def int_x86_avx2_maskstore_d_256 :
1805        GCCBuiltin<"__builtin_ia32_maskstored256">,
1806        Intrinsic<[], [llvm_ptr_ty, llvm_v8i32_ty, llvm_v8i32_ty],
1807                  [IntrReadWriteArgMem]>;
1808  def int_x86_avx2_maskstore_q_256 :
1809        GCCBuiltin<"__builtin_ia32_maskstoreq256">,
1810        Intrinsic<[], [llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i64_ty],
1811                  [IntrReadWriteArgMem]>;
1812  def int_x86_avx512_mask_storeu_d_512 :
1813        GCCBuiltin<"__builtin_ia32_storedqusi512_mask">,
1814        Intrinsic<[], [llvm_ptr_ty, llvm_v16i32_ty, llvm_i16_ty],
1815                  [IntrReadWriteArgMem]>;
1816  def int_x86_avx512_mask_storeu_q_512 :
1817        GCCBuiltin<"__builtin_ia32_storedqudi512_mask">,
1818        Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty, llvm_i8_ty],
1819                  [IntrReadWriteArgMem]>;
1820}
1821
1822// Variable bit shift ops
1823let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1824  def int_x86_avx2_psllv_d : GCCBuiltin<"__builtin_ia32_psllv4si">,
1825              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
1826                        [IntrNoMem]>;
1827  def int_x86_avx2_psllv_d_256 : GCCBuiltin<"__builtin_ia32_psllv8si">,
1828              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
1829                        [IntrNoMem]>;
1830  def int_x86_avx2_psllv_q : GCCBuiltin<"__builtin_ia32_psllv2di">,
1831              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
1832                        [IntrNoMem]>;
1833  def int_x86_avx2_psllv_q_256 : GCCBuiltin<"__builtin_ia32_psllv4di">,
1834              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty],
1835                        [IntrNoMem]>;
1836
1837  def int_x86_avx2_psrlv_d : GCCBuiltin<"__builtin_ia32_psrlv4si">,
1838              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
1839                        [IntrNoMem]>;
1840  def int_x86_avx2_psrlv_d_256 : GCCBuiltin<"__builtin_ia32_psrlv8si">,
1841              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
1842                        [IntrNoMem]>;
1843  def int_x86_avx2_psrlv_q : GCCBuiltin<"__builtin_ia32_psrlv2di">,
1844              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
1845                        [IntrNoMem]>;
1846  def int_x86_avx2_psrlv_q_256 : GCCBuiltin<"__builtin_ia32_psrlv4di">,
1847              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty],
1848                        [IntrNoMem]>;
1849
1850  def int_x86_avx2_psrav_d : GCCBuiltin<"__builtin_ia32_psrav4si">,
1851              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
1852                        [IntrNoMem]>;
1853  def int_x86_avx2_psrav_d_256 : GCCBuiltin<"__builtin_ia32_psrav8si">,
1854              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
1855                        [IntrNoMem]>;
1856
1857  def int_x86_avx512_mask_psllv_d : GCCBuiltin<"__builtin_ia32_psllv16si_mask">,
1858              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1859                         llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
1860                        [IntrNoMem]>;
1861  def int_x86_avx512_mask_psllv_q : GCCBuiltin<"__builtin_ia32_psllv8di_mask">,
1862              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1863                         llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
1864                        [IntrNoMem]>;
1865  def int_x86_avx512_mask_psrav_d : GCCBuiltin<"__builtin_ia32_psrav16si_mask">,
1866              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1867                         llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
1868                        [IntrNoMem]>;
1869  def int_x86_avx512_mask_psrav_q : GCCBuiltin<"__builtin_ia32_psrav8di_mask">,
1870              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1871                         llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
1872                        [IntrNoMem]>;
1873  def int_x86_avx512_mask_psrlv_d : GCCBuiltin<"__builtin_ia32_psrlv16si_mask">,
1874              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1875                         llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
1876                        [IntrNoMem]>;
1877  def int_x86_avx512_mask_psrlv_q : GCCBuiltin<"__builtin_ia32_psrlv8di_mask">,
1878              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1879                         llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
1880                        [IntrNoMem]>;
1881}
1882
1883// Gather ops
1884let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1885  def int_x86_avx2_gather_d_pd : GCCBuiltin<"__builtin_ia32_gatherd_pd">,
1886      Intrinsic<[llvm_v2f64_ty],
1887        [llvm_v2f64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v2f64_ty, llvm_i8_ty],
1888        [IntrReadArgMem]>;
1889  def int_x86_avx2_gather_d_pd_256 : GCCBuiltin<"__builtin_ia32_gatherd_pd256">,
1890      Intrinsic<[llvm_v4f64_ty],
1891        [llvm_v4f64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4f64_ty, llvm_i8_ty],
1892        [IntrReadArgMem]>;
1893  def int_x86_avx2_gather_q_pd : GCCBuiltin<"__builtin_ia32_gatherq_pd">,
1894      Intrinsic<[llvm_v2f64_ty],
1895        [llvm_v2f64_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v2f64_ty, llvm_i8_ty],
1896        [IntrReadArgMem]>;
1897  def int_x86_avx2_gather_q_pd_256 : GCCBuiltin<"__builtin_ia32_gatherq_pd256">,
1898      Intrinsic<[llvm_v4f64_ty],
1899        [llvm_v4f64_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4f64_ty, llvm_i8_ty],
1900        [IntrReadArgMem]>;
1901  def int_x86_avx2_gather_d_ps : GCCBuiltin<"__builtin_ia32_gatherd_ps">,
1902      Intrinsic<[llvm_v4f32_ty],
1903        [llvm_v4f32_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4f32_ty, llvm_i8_ty],
1904        [IntrReadArgMem]>;
1905  def int_x86_avx2_gather_d_ps_256 : GCCBuiltin<"__builtin_ia32_gatherd_ps256">,
1906      Intrinsic<[llvm_v8f32_ty],
1907        [llvm_v8f32_ty, llvm_ptr_ty, llvm_v8i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1908        [IntrReadArgMem]>;
1909  def int_x86_avx2_gather_q_ps : GCCBuiltin<"__builtin_ia32_gatherq_ps">,
1910      Intrinsic<[llvm_v4f32_ty],
1911        [llvm_v4f32_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v4f32_ty, llvm_i8_ty],
1912        [IntrReadArgMem]>;
1913  def int_x86_avx2_gather_q_ps_256 : GCCBuiltin<"__builtin_ia32_gatherq_ps256">,
1914      Intrinsic<[llvm_v4f32_ty],
1915        [llvm_v4f32_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4f32_ty, llvm_i8_ty],
1916        [IntrReadArgMem]>;
1917
1918  def int_x86_avx2_gather_d_q : GCCBuiltin<"__builtin_ia32_gatherd_q">,
1919      Intrinsic<[llvm_v2i64_ty],
1920        [llvm_v2i64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v2i64_ty, llvm_i8_ty],
1921        [IntrReadArgMem]>;
1922  def int_x86_avx2_gather_d_q_256 : GCCBuiltin<"__builtin_ia32_gatherd_q256">,
1923      Intrinsic<[llvm_v4i64_ty],
1924        [llvm_v4i64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i64_ty, llvm_i8_ty],
1925        [IntrReadArgMem]>;
1926  def int_x86_avx2_gather_q_q : GCCBuiltin<"__builtin_ia32_gatherq_q">,
1927      Intrinsic<[llvm_v2i64_ty],
1928        [llvm_v2i64_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
1929        [IntrReadArgMem]>;
1930  def int_x86_avx2_gather_q_q_256 : GCCBuiltin<"__builtin_ia32_gatherq_q256">,
1931      Intrinsic<[llvm_v4i64_ty],
1932        [llvm_v4i64_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
1933        [IntrReadArgMem]>;
1934  def int_x86_avx2_gather_d_d : GCCBuiltin<"__builtin_ia32_gatherd_d">,
1935      Intrinsic<[llvm_v4i32_ty],
1936        [llvm_v4i32_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
1937        [IntrReadArgMem]>;
1938  def int_x86_avx2_gather_d_d_256 : GCCBuiltin<"__builtin_ia32_gatherd_d256">,
1939      Intrinsic<[llvm_v8i32_ty],
1940        [llvm_v8i32_ty, llvm_ptr_ty, llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
1941        [IntrReadArgMem]>;
1942  def int_x86_avx2_gather_q_d : GCCBuiltin<"__builtin_ia32_gatherq_d">,
1943      Intrinsic<[llvm_v4i32_ty],
1944        [llvm_v4i32_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v4i32_ty, llvm_i8_ty],
1945        [IntrReadArgMem]>;
1946  def int_x86_avx2_gather_q_d_256 : GCCBuiltin<"__builtin_ia32_gatherq_d256">,
1947      Intrinsic<[llvm_v4i32_ty],
1948        [llvm_v4i32_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i32_ty, llvm_i8_ty],
1949        [IntrReadArgMem]>;
1950}
1951
1952// Misc.
1953let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1954  def int_x86_avx2_pmovmskb : GCCBuiltin<"__builtin_ia32_pmovmskb256">,
1955              Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty], [IntrNoMem]>;
1956  def int_x86_avx2_pshuf_b : GCCBuiltin<"__builtin_ia32_pshufb256">,
1957              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1958                         llvm_v32i8_ty], [IntrNoMem]>;
1959  def int_x86_avx2_mpsadbw : GCCBuiltin<"__builtin_ia32_mpsadbw256">,
1960              Intrinsic<[llvm_v16i16_ty], [llvm_v32i8_ty, llvm_v32i8_ty,
1961                         llvm_i8_ty], [IntrNoMem, Commutative]>;
1962  def int_x86_avx2_movntdqa : GCCBuiltin<"__builtin_ia32_movntdqa256">,
1963              Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
1964}
1965
1966//===----------------------------------------------------------------------===//
1967// FMA3 and FMA4
1968
1969let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1970  def int_x86_fma_vfmadd_ss : GCCBuiltin<"__builtin_ia32_vfmaddss">,
1971              Intrinsic<[llvm_v4f32_ty],
1972                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1973                        [IntrNoMem]>;
1974  def int_x86_fma_vfmadd_sd : GCCBuiltin<"__builtin_ia32_vfmaddsd">,
1975              Intrinsic<[llvm_v2f64_ty],
1976                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1977                        [IntrNoMem]>;
1978  def int_x86_fma_vfmadd_ps : GCCBuiltin<"__builtin_ia32_vfmaddps">,
1979              Intrinsic<[llvm_v4f32_ty],
1980                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1981                        [IntrNoMem]>;
1982  def int_x86_fma_vfmadd_pd : GCCBuiltin<"__builtin_ia32_vfmaddpd">,
1983              Intrinsic<[llvm_v2f64_ty],
1984                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1985                        [IntrNoMem]>;
1986  def int_x86_fma_vfmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfmaddps256">,
1987              Intrinsic<[llvm_v8f32_ty],
1988                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
1989                        [IntrNoMem]>;
1990  def int_x86_fma_vfmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfmaddpd256">,
1991              Intrinsic<[llvm_v4f64_ty],
1992                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
1993                        [IntrNoMem]>;
1994  def int_x86_fma_mask_vfmadd_ps_512 : GCCBuiltin<"__builtin_ia32_vfmaddps512_mask">,
1995              Intrinsic<[llvm_v16f32_ty],
1996                        [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty,
1997                         llvm_i16_ty, llvm_i32_ty],
1998                        [IntrNoMem]>;
1999  def int_x86_fma_mask_vfmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfmaddps256_mask">,
2000              Intrinsic<[llvm_v8f32_ty],
2001                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty,
2002                         llvm_i8_ty],
2003                        [IntrNoMem]>;
2004  def int_x86_fma_mask_vfmadd_ps_128 : GCCBuiltin<"__builtin_ia32_vfmaddps128_mask">,
2005              Intrinsic<[llvm_v4f32_ty],
2006                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
2007                         llvm_i8_ty],
2008                        [IntrNoMem]>;
2009  def int_x86_fma_mask_vfmadd_pd_512 : GCCBuiltin<"__builtin_ia32_vfmaddpd512_mask">,
2010              Intrinsic<[llvm_v8f64_ty],
2011                        [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty,
2012                         llvm_i8_ty, llvm_i32_ty],
2013                        [IntrNoMem]>;
2014  def int_x86_fma_mask_vfmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfmaddpd256_mask">,
2015              Intrinsic<[llvm_v4f64_ty],
2016                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty,
2017                         llvm_i8_ty],
2018                        [IntrNoMem]>;
2019  def int_x86_fma_mask_vfmadd_pd_128 : GCCBuiltin<"__builtin_ia32_vfmaddpd128_mask">,
2020              Intrinsic<[llvm_v2f64_ty],
2021                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
2022                         llvm_i8_ty],
2023                        [IntrNoMem]>;
2024  def int_x86_fma_vfmsub_ss : GCCBuiltin<"__builtin_ia32_vfmsubss">,
2025              Intrinsic<[llvm_v4f32_ty],
2026                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2027                        [IntrNoMem]>;
2028  def int_x86_fma_vfmsub_sd : GCCBuiltin<"__builtin_ia32_vfmsubsd">,
2029              Intrinsic<[llvm_v2f64_ty],
2030                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2031                        [IntrNoMem]>;
2032  def int_x86_fma_vfmsub_ps : GCCBuiltin<"__builtin_ia32_vfmsubps">,
2033              Intrinsic<[llvm_v4f32_ty],
2034                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2035                        [IntrNoMem]>;
2036  def int_x86_fma_vfmsub_pd : GCCBuiltin<"__builtin_ia32_vfmsubpd">,
2037              Intrinsic<[llvm_v2f64_ty],
2038                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2039                        [IntrNoMem]>;
2040  def int_x86_fma_vfmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfmsubps256">,
2041              Intrinsic<[llvm_v8f32_ty],
2042                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2043                        [IntrNoMem]>;
2044  def int_x86_fma_vfmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfmsubpd256">,
2045              Intrinsic<[llvm_v4f64_ty],
2046                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
2047                        [IntrNoMem]>;
2048  def int_x86_fma_mask_vfmsub_ps_512 : GCCBuiltin<"__builtin_ia32_vfmsubps512_mask">,
2049              Intrinsic<[llvm_v16f32_ty],
2050                        [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty,
2051                         llvm_i16_ty, llvm_i32_ty],
2052                        [IntrNoMem]>;
2053  def int_x86_fma_mask_vfmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfmsubps256_mask">,
2054              Intrinsic<[llvm_v8f32_ty],
2055                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty,
2056                         llvm_i8_ty],
2057                        [IntrNoMem]>;
2058  def int_x86_fma_mask_vfmsub_ps_128 : GCCBuiltin<"__builtin_ia32_vfmsubps128_mask">,
2059              Intrinsic<[llvm_v4f32_ty],
2060                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
2061                         llvm_i8_ty],
2062                        [IntrNoMem]>;
2063  def int_x86_fma_mask_vfmsub_pd_512 : GCCBuiltin<"__builtin_ia32_vfmsubpd512_mask">,
2064              Intrinsic<[llvm_v8f64_ty],
2065                        [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty,
2066                         llvm_i8_ty, llvm_i32_ty],
2067                        [IntrNoMem]>;
2068  def int_x86_fma_mask_vfmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfmsubpd256_mask">,
2069              Intrinsic<[llvm_v4f64_ty],
2070                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty,
2071                         llvm_i8_ty],
2072                        [IntrNoMem]>;
2073  def int_x86_fma_mask_vfmsub_pd_128 : GCCBuiltin<"__builtin_ia32_vfmsubpd128_mask">,
2074              Intrinsic<[llvm_v2f64_ty],
2075                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
2076                         llvm_i8_ty],
2077                        [IntrNoMem]>;
2078  def int_x86_fma_vfnmadd_ss : GCCBuiltin<"__builtin_ia32_vfnmaddss">,
2079              Intrinsic<[llvm_v4f32_ty],
2080                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2081                        [IntrNoMem]>;
2082  def int_x86_fma_vfnmadd_sd : GCCBuiltin<"__builtin_ia32_vfnmaddsd">,
2083              Intrinsic<[llvm_v2f64_ty],
2084                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2085                        [IntrNoMem]>;
2086  def int_x86_fma_vfnmadd_ps : GCCBuiltin<"__builtin_ia32_vfnmaddps">,
2087              Intrinsic<[llvm_v4f32_ty],
2088                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2089                        [IntrNoMem]>;
2090  def int_x86_fma_vfnmadd_pd : GCCBuiltin<"__builtin_ia32_vfnmaddpd">,
2091              Intrinsic<[llvm_v2f64_ty],
2092                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2093                        [IntrNoMem]>;
2094  def int_x86_fma_vfnmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmaddps256">,
2095              Intrinsic<[llvm_v8f32_ty],
2096                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2097                        [IntrNoMem]>;
2098  def int_x86_fma_vfnmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmaddpd256">,
2099              Intrinsic<[llvm_v4f64_ty],
2100                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
2101                        [IntrNoMem]>;
2102  def int_x86_fma_mask_vfnmadd_ps_512 : GCCBuiltin<"__builtin_ia32_vfnmaddps512_mask">,
2103              Intrinsic<[llvm_v16f32_ty],
2104                        [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty,
2105                         llvm_i16_ty, llvm_i32_ty],
2106                        [IntrNoMem]>;
2107  def int_x86_fma_mask_vfnmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmaddps256_mask">,
2108              Intrinsic<[llvm_v8f32_ty],
2109                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty,
2110                         llvm_i8_ty],
2111                        [IntrNoMem]>;
2112  def int_x86_fma_mask_vfnmadd_ps_128 : GCCBuiltin<"__builtin_ia32_vfnmaddps128_mask">,
2113              Intrinsic<[llvm_v4f32_ty],
2114                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
2115                         llvm_i8_ty],
2116                        [IntrNoMem]>;
2117  def int_x86_fma_mask_vfnmadd_pd_512 : GCCBuiltin<"__builtin_ia32_vfnmaddpd512_mask">,
2118              Intrinsic<[llvm_v8f64_ty],
2119                        [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty,
2120                         llvm_i8_ty, llvm_i32_ty],
2121                        [IntrNoMem]>;
2122  def int_x86_fma_mask_vfnmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmaddpd256_mask">,
2123              Intrinsic<[llvm_v4f64_ty],
2124                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty,
2125                         llvm_i8_ty],
2126                        [IntrNoMem]>;
2127  def int_x86_fma_mask_vfnmadd_pd_128 : GCCBuiltin<"__builtin_ia32_vfnmaddpd128_mask">,
2128              Intrinsic<[llvm_v2f64_ty],
2129                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
2130                         llvm_i8_ty],
2131                        [IntrNoMem]>;
2132  def int_x86_fma_vfnmsub_ss : GCCBuiltin<"__builtin_ia32_vfnmsubss">,
2133              Intrinsic<[llvm_v4f32_ty],
2134                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2135                        [IntrNoMem]>;
2136  def int_x86_fma_vfnmsub_sd : GCCBuiltin<"__builtin_ia32_vfnmsubsd">,
2137              Intrinsic<[llvm_v2f64_ty],
2138                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2139                        [IntrNoMem]>;
2140  def int_x86_fma_vfnmsub_ps : GCCBuiltin<"__builtin_ia32_vfnmsubps">,
2141              Intrinsic<[llvm_v4f32_ty],
2142                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2143                        [IntrNoMem]>;
2144  def int_x86_fma_vfnmsub_pd : GCCBuiltin<"__builtin_ia32_vfnmsubpd">,
2145              Intrinsic<[llvm_v2f64_ty],
2146                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2147                        [IntrNoMem]>;
2148  def int_x86_fma_vfnmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmsubps256">,
2149              Intrinsic<[llvm_v8f32_ty],
2150                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2151                        [IntrNoMem]>;
2152  def int_x86_fma_vfnmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmsubpd256">,
2153              Intrinsic<[llvm_v4f64_ty],
2154                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
2155                        [IntrNoMem]>;
2156  def int_x86_fma_mask_vfnmsub_ps_512 : GCCBuiltin<"__builtin_ia32_vfnmsubps512_mask">,
2157              Intrinsic<[llvm_v16f32_ty],
2158                        [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty,
2159                         llvm_i16_ty, llvm_i32_ty],
2160                        [IntrNoMem]>;
2161  def int_x86_fma_mask_vfnmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmsubps256_mask">,
2162              Intrinsic<[llvm_v8f32_ty],
2163                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty,
2164                         llvm_i8_ty],
2165                        [IntrNoMem]>;
2166  def int_x86_fma_mask_vfnmsub_ps_128 : GCCBuiltin<"__builtin_ia32_vfnmsubps128_mask">,
2167              Intrinsic<[llvm_v4f32_ty],
2168                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
2169                         llvm_i8_ty],
2170                        [IntrNoMem]>;
2171  def int_x86_fma_mask_vfnmsub_pd_512 : GCCBuiltin<"__builtin_ia32_vfnmsubpd512_mask">,
2172              Intrinsic<[llvm_v8f64_ty],
2173                        [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty,
2174                         llvm_i8_ty, llvm_i32_ty],
2175                        [IntrNoMem]>;
2176  def int_x86_fma_mask_vfnmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmsubpd256_mask">,
2177              Intrinsic<[llvm_v4f64_ty],
2178                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty,
2179                         llvm_i8_ty],
2180                        [IntrNoMem]>;
2181  def int_x86_fma_mask_vfnmsub_pd_128 : GCCBuiltin<"__builtin_ia32_vfnmsubpd128_mask">,
2182              Intrinsic<[llvm_v2f64_ty],
2183                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
2184                         llvm_i8_ty],
2185                        [IntrNoMem]>;
2186  def int_x86_fma_vfmaddsub_ps : GCCBuiltin<"__builtin_ia32_vfmaddsubps">,
2187              Intrinsic<[llvm_v4f32_ty],
2188                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2189                        [IntrNoMem]>;
2190  def int_x86_fma_vfmaddsub_pd : GCCBuiltin<"__builtin_ia32_vfmaddsubpd">,
2191              Intrinsic<[llvm_v2f64_ty],
2192                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2193                        [IntrNoMem]>;
2194  def int_x86_fma_vfmaddsub_ps_256 :
2195               GCCBuiltin<"__builtin_ia32_vfmaddsubps256">,
2196              Intrinsic<[llvm_v8f32_ty],
2197                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2198                        [IntrNoMem]>;
2199  def int_x86_fma_vfmaddsub_pd_256 :
2200              GCCBuiltin<"__builtin_ia32_vfmaddsubpd256">,
2201              Intrinsic<[llvm_v4f64_ty],
2202                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
2203                        [IntrNoMem]>;
2204  def int_x86_fma_mask_vfmaddsub_ps_512 : GCCBuiltin<"__builtin_ia32_vfmaddsubps512_mask">,
2205              Intrinsic<[llvm_v16f32_ty],
2206                        [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty,
2207                         llvm_i16_ty, llvm_i32_ty],
2208                        [IntrNoMem]>;
2209  def int_x86_fma_mask_vfmaddsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfmaddsubps256_mask">,
2210              Intrinsic<[llvm_v8f32_ty],
2211                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty,
2212                         llvm_i8_ty],
2213                        [IntrNoMem]>;
2214  def int_x86_fma_mask_vfmaddsub_ps_128 : GCCBuiltin<"__builtin_ia32_vfmaddsubps128_mask">,
2215              Intrinsic<[llvm_v4f32_ty],
2216                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
2217                         llvm_i8_ty],
2218                        [IntrNoMem]>;
2219  def int_x86_fma_mask_vfmaddsub_pd_512 : GCCBuiltin<"__builtin_ia32_vfmaddsubpd512_mask">,
2220              Intrinsic<[llvm_v8f64_ty],
2221                        [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty,
2222                         llvm_i8_ty, llvm_i32_ty],
2223                        [IntrNoMem]>;
2224  def int_x86_fma_mask_vfmaddsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfmaddsubpd256_mask">,
2225              Intrinsic<[llvm_v4f64_ty],
2226                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty,
2227                         llvm_i8_ty],
2228                        [IntrNoMem]>;
2229  def int_x86_fma_mask_vfmaddsub_pd_128 : GCCBuiltin<"__builtin_ia32_vfmaddsubpd128_mask">,
2230              Intrinsic<[llvm_v2f64_ty],
2231                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
2232                         llvm_i8_ty],
2233                        [IntrNoMem]>;
2234  def int_x86_fma_vfmsubadd_ps : GCCBuiltin<"__builtin_ia32_vfmsubaddps">,
2235              Intrinsic<[llvm_v4f32_ty],
2236                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2237                        [IntrNoMem]>;
2238  def int_x86_fma_vfmsubadd_pd : GCCBuiltin<"__builtin_ia32_vfmsubaddpd">,
2239              Intrinsic<[llvm_v2f64_ty],
2240                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2241                        [IntrNoMem]>;
2242  def int_x86_fma_vfmsubadd_ps_256 :
2243              GCCBuiltin<"__builtin_ia32_vfmsubaddps256">,
2244              Intrinsic<[llvm_v8f32_ty],
2245                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2246                        [IntrNoMem]>;
2247  def int_x86_fma_vfmsubadd_pd_256 :
2248              GCCBuiltin<"__builtin_ia32_vfmsubaddpd256">,
2249              Intrinsic<[llvm_v4f64_ty],
2250                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
2251                        [IntrNoMem]>;
2252  def int_x86_fma_mask_vfmsubadd_ps_512 : GCCBuiltin<"__builtin_ia32_vfmsubaddps512_mask">,
2253              Intrinsic<[llvm_v16f32_ty],
2254                        [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty,
2255                         llvm_i16_ty, llvm_i32_ty],
2256                        [IntrNoMem]>;
2257  def int_x86_fma_mask_vfmsubadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfmsubaddps256_mask">,
2258              Intrinsic<[llvm_v8f32_ty],
2259                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty,
2260                         llvm_i8_ty],
2261                        [IntrNoMem]>;
2262  def int_x86_fma_mask_vfmsubadd_ps_128 : GCCBuiltin<"__builtin_ia32_vfmsubaddps128_mask">,
2263              Intrinsic<[llvm_v4f32_ty],
2264                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
2265                         llvm_i8_ty],
2266                        [IntrNoMem]>;
2267  def int_x86_fma_mask_vfmsubadd_pd_512 : GCCBuiltin<"__builtin_ia32_vfmsubaddpd512_mask">,
2268              Intrinsic<[llvm_v8f64_ty],
2269                        [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty,
2270                         llvm_i8_ty, llvm_i32_ty],
2271                        [IntrNoMem]>;
2272  def int_x86_fma_mask_vfmsubadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfmsubaddpd256_mask">,
2273              Intrinsic<[llvm_v4f64_ty],
2274                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty,
2275                         llvm_i8_ty],
2276                        [IntrNoMem]>;
2277  def int_x86_fma_mask_vfmsubadd_pd_128 : GCCBuiltin<"__builtin_ia32_vfmsubaddpd128_mask">,
2278              Intrinsic<[llvm_v2f64_ty],
2279                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
2280                         llvm_i8_ty],
2281                        [IntrNoMem]>;
2282}
2283
2284//===----------------------------------------------------------------------===//
2285// XOP
2286
2287  def int_x86_xop_vpermil2pd : GCCBuiltin<"__builtin_ia32_vpermil2pd">,
2288              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
2289                                          llvm_v2f64_ty, llvm_i8_ty],
2290                        [IntrNoMem]>;
2291
2292  def int_x86_xop_vpermil2pd_256 :
2293              GCCBuiltin<"__builtin_ia32_vpermil2pd256">,
2294              Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty,
2295                                          llvm_v4f64_ty, llvm_i8_ty],
2296                        [IntrNoMem]>;
2297
2298  def int_x86_xop_vpermil2ps : GCCBuiltin<"__builtin_ia32_vpermil2ps">,
2299              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
2300                                          llvm_v4f32_ty, llvm_i8_ty],
2301                        [IntrNoMem]>;
2302  def int_x86_xop_vpermil2ps_256 :
2303              GCCBuiltin<"__builtin_ia32_vpermil2ps256">,
2304              Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty,
2305                                          llvm_v8f32_ty, llvm_i8_ty],
2306                        [IntrNoMem]>;
2307
2308  def int_x86_xop_vfrcz_pd : GCCBuiltin<"__builtin_ia32_vfrczpd">,
2309              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
2310  def int_x86_xop_vfrcz_ps : GCCBuiltin<"__builtin_ia32_vfrczps">,
2311              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
2312  def int_x86_xop_vfrcz_sd : GCCBuiltin<"__builtin_ia32_vfrczsd">,
2313              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
2314  def int_x86_xop_vfrcz_ss : GCCBuiltin<"__builtin_ia32_vfrczss">,
2315              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
2316  def int_x86_xop_vfrcz_pd_256 : GCCBuiltin<"__builtin_ia32_vfrczpd256">,
2317              Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty], [IntrNoMem]>;
2318  def int_x86_xop_vfrcz_ps_256 : GCCBuiltin<"__builtin_ia32_vfrczps256">,
2319              Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
2320
2321  def int_x86_xop_vpcmov :
2322              GCCBuiltin<"__builtin_ia32_vpcmov">,
2323              Intrinsic<[llvm_v2i64_ty],
2324                        [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty],
2325                        [IntrNoMem]>;
2326  def int_x86_xop_vpcmov_256 :
2327              GCCBuiltin<"__builtin_ia32_vpcmov_256">,
2328              Intrinsic<[llvm_v4i64_ty],
2329                        [llvm_v4i64_ty, llvm_v4i64_ty, llvm_v4i64_ty],
2330                        [IntrNoMem]>;
2331
2332  def int_x86_xop_vpcomb : GCCBuiltin<"__builtin_ia32_vpcomb">,
2333              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,
2334                         llvm_i8_ty], [IntrNoMem]>;
2335  def int_x86_xop_vpcomw : GCCBuiltin<"__builtin_ia32_vpcomw">,
2336              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty,
2337                         llvm_i8_ty], [IntrNoMem]>;
2338  def int_x86_xop_vpcomd : GCCBuiltin<"__builtin_ia32_vpcomd">,
2339              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2340                         llvm_i8_ty], [IntrNoMem]>;
2341  def int_x86_xop_vpcomq : GCCBuiltin<"__builtin_ia32_vpcomq">,
2342              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2343                         llvm_i8_ty], [IntrNoMem]>;
2344  def int_x86_xop_vpcomub : GCCBuiltin<"__builtin_ia32_vpcomub">,
2345              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,
2346                         llvm_i8_ty], [IntrNoMem]>;
2347  def int_x86_xop_vpcomuw : GCCBuiltin<"__builtin_ia32_vpcomuw">,
2348              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty,
2349                         llvm_i8_ty], [IntrNoMem]>;
2350  def int_x86_xop_vpcomud : GCCBuiltin<"__builtin_ia32_vpcomud">,
2351              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2352                         llvm_i8_ty], [IntrNoMem]>;
2353  def int_x86_xop_vpcomuq : GCCBuiltin<"__builtin_ia32_vpcomuq">,
2354              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2355                         llvm_i8_ty], [IntrNoMem]>;
2356
2357  def int_x86_xop_vphaddbd :
2358              GCCBuiltin<"__builtin_ia32_vphaddbd">,
2359              Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2360  def int_x86_xop_vphaddbq :
2361              GCCBuiltin<"__builtin_ia32_vphaddbq">,
2362              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2363  def int_x86_xop_vphaddbw :
2364              GCCBuiltin<"__builtin_ia32_vphaddbw">,
2365              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2366  def int_x86_xop_vphadddq :
2367              GCCBuiltin<"__builtin_ia32_vphadddq">,
2368              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
2369  def int_x86_xop_vphaddubd :
2370              GCCBuiltin<"__builtin_ia32_vphaddubd">,
2371              Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2372  def int_x86_xop_vphaddubq :
2373              GCCBuiltin<"__builtin_ia32_vphaddubq">,
2374              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2375  def int_x86_xop_vphaddubw :
2376              GCCBuiltin<"__builtin_ia32_vphaddubw">,
2377              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2378  def int_x86_xop_vphaddudq :
2379              GCCBuiltin<"__builtin_ia32_vphaddudq">,
2380              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
2381  def int_x86_xop_vphadduwd :
2382              GCCBuiltin<"__builtin_ia32_vphadduwd">,
2383              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2384  def int_x86_xop_vphadduwq :
2385              GCCBuiltin<"__builtin_ia32_vphadduwq">,
2386              Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2387  def int_x86_xop_vphaddwd :
2388              GCCBuiltin<"__builtin_ia32_vphaddwd">,
2389              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2390  def int_x86_xop_vphaddwq :
2391              GCCBuiltin<"__builtin_ia32_vphaddwq">,
2392              Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2393  def int_x86_xop_vphsubbw :
2394              GCCBuiltin<"__builtin_ia32_vphsubbw">,
2395              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2396  def int_x86_xop_vphsubdq :
2397              GCCBuiltin<"__builtin_ia32_vphsubdq">,
2398              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
2399  def int_x86_xop_vphsubwd :
2400              GCCBuiltin<"__builtin_ia32_vphsubwd">,
2401              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2402  def int_x86_xop_vpmacsdd :
2403              GCCBuiltin<"__builtin_ia32_vpmacsdd">,
2404              Intrinsic<[llvm_v4i32_ty],
2405                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
2406                        [IntrNoMem]>;
2407  def int_x86_xop_vpmacsdqh :
2408              GCCBuiltin<"__builtin_ia32_vpmacsdqh">,
2409              Intrinsic<[llvm_v2i64_ty],
2410                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v2i64_ty],
2411                        [IntrNoMem]>;
2412  def int_x86_xop_vpmacsdql :
2413              GCCBuiltin<"__builtin_ia32_vpmacsdql">,
2414              Intrinsic<[llvm_v2i64_ty],
2415                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v2i64_ty],
2416                        [IntrNoMem]>;
2417  def int_x86_xop_vpmacssdd :
2418              GCCBuiltin<"__builtin_ia32_vpmacssdd">,
2419              Intrinsic<[llvm_v4i32_ty],
2420                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
2421                        [IntrNoMem]>;
2422  def int_x86_xop_vpmacssdqh :
2423              GCCBuiltin<"__builtin_ia32_vpmacssdqh">,
2424              Intrinsic<[llvm_v2i64_ty],
2425                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v2i64_ty],
2426                        [IntrNoMem]>;
2427  def int_x86_xop_vpmacssdql :
2428              GCCBuiltin<"__builtin_ia32_vpmacssdql">,
2429              Intrinsic<[llvm_v2i64_ty],
2430                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v2i64_ty],
2431                        [IntrNoMem]>;
2432  def int_x86_xop_vpmacsswd :
2433              GCCBuiltin<"__builtin_ia32_vpmacsswd">,
2434              Intrinsic<[llvm_v4i32_ty],
2435                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v4i32_ty],
2436                        [IntrNoMem]>;
2437  def int_x86_xop_vpmacssww :
2438              GCCBuiltin<"__builtin_ia32_vpmacssww">,
2439              Intrinsic<[llvm_v8i16_ty],
2440                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty],
2441                        [IntrNoMem]>;
2442  def int_x86_xop_vpmacswd :
2443              GCCBuiltin<"__builtin_ia32_vpmacswd">,
2444              Intrinsic<[llvm_v4i32_ty],
2445                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v4i32_ty],
2446                        [IntrNoMem]>;
2447  def int_x86_xop_vpmacsww :
2448              GCCBuiltin<"__builtin_ia32_vpmacsww">,
2449              Intrinsic<[llvm_v8i16_ty],
2450                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty],
2451                        [IntrNoMem]>;
2452  def int_x86_xop_vpmadcsswd :
2453              GCCBuiltin<"__builtin_ia32_vpmadcsswd">,
2454              Intrinsic<[llvm_v4i32_ty],
2455                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v4i32_ty],
2456                        [IntrNoMem]>;
2457  def int_x86_xop_vpmadcswd :
2458              GCCBuiltin<"__builtin_ia32_vpmadcswd">,
2459              Intrinsic<[llvm_v4i32_ty],
2460                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v4i32_ty],
2461                        [IntrNoMem]>;
2462  def int_x86_xop_vpperm :
2463              GCCBuiltin<"__builtin_ia32_vpperm">,
2464              Intrinsic<[llvm_v16i8_ty],
2465                        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty],
2466                        [IntrNoMem]>;
2467
2468  def int_x86_xop_vprotb : GCCBuiltin<"__builtin_ia32_vprotb">,
2469              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
2470                        [IntrNoMem]>;
2471  def int_x86_xop_vprotd : GCCBuiltin<"__builtin_ia32_vprotd">,
2472              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2473                        [IntrNoMem]>;
2474  def int_x86_xop_vprotq : GCCBuiltin<"__builtin_ia32_vprotq">,
2475              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2476                        [IntrNoMem]>;
2477  def int_x86_xop_vprotw : GCCBuiltin<"__builtin_ia32_vprotw">,
2478              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
2479                        [IntrNoMem]>;
2480  def int_x86_xop_vprotbi : GCCBuiltin<"__builtin_ia32_vprotbi">,
2481              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i8_ty],
2482                        [IntrNoMem]>;
2483  def int_x86_xop_vprotdi : GCCBuiltin<"__builtin_ia32_vprotdi">,
2484              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i8_ty],
2485                        [IntrNoMem]>;
2486  def int_x86_xop_vprotqi : GCCBuiltin<"__builtin_ia32_vprotqi">,
2487              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty],
2488                        [IntrNoMem]>;
2489  def int_x86_xop_vprotwi : GCCBuiltin<"__builtin_ia32_vprotwi">,
2490              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i8_ty],
2491                        [IntrNoMem]>;
2492
2493  def int_x86_xop_vpshab :
2494              GCCBuiltin<"__builtin_ia32_vpshab">,
2495              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
2496                        [IntrNoMem]>;
2497  def int_x86_xop_vpshad :
2498              GCCBuiltin<"__builtin_ia32_vpshad">,
2499              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2500                        [IntrNoMem]>;
2501  def int_x86_xop_vpshaq :
2502              GCCBuiltin<"__builtin_ia32_vpshaq">,
2503              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2504                        [IntrNoMem]>;
2505  def int_x86_xop_vpshaw :
2506              GCCBuiltin<"__builtin_ia32_vpshaw">,
2507              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
2508                        [IntrNoMem]>;
2509  def int_x86_xop_vpshlb :
2510              GCCBuiltin<"__builtin_ia32_vpshlb">,
2511              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
2512                        [IntrNoMem]>;
2513  def int_x86_xop_vpshld :
2514              GCCBuiltin<"__builtin_ia32_vpshld">,
2515              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2516                        [IntrNoMem]>;
2517  def int_x86_xop_vpshlq :
2518              GCCBuiltin<"__builtin_ia32_vpshlq">,
2519              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2520                        [IntrNoMem]>;
2521  def int_x86_xop_vpshlw :
2522              GCCBuiltin<"__builtin_ia32_vpshlw">,
2523              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
2524                        [IntrNoMem]>;
2525
2526//===----------------------------------------------------------------------===//
2527// MMX
2528
2529// Empty MMX state op.
2530let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2531  def int_x86_mmx_emms  : GCCBuiltin<"__builtin_ia32_emms">,
2532              Intrinsic<[], [], []>;
2533  def int_x86_mmx_femms : GCCBuiltin<"__builtin_ia32_femms">,
2534              Intrinsic<[], [], []>;
2535}
2536
2537// Integer arithmetic ops.
2538let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2539  // Addition
2540  def int_x86_mmx_padd_b : GCCBuiltin<"__builtin_ia32_paddb">,
2541              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2542                        [IntrNoMem]>;
2543  def int_x86_mmx_padd_w : GCCBuiltin<"__builtin_ia32_paddw">,
2544              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2545                        [IntrNoMem]>;
2546  def int_x86_mmx_padd_d : GCCBuiltin<"__builtin_ia32_paddd">,
2547              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2548                        [IntrNoMem]>;
2549  def int_x86_mmx_padd_q : GCCBuiltin<"__builtin_ia32_paddq">,
2550              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2551                        [IntrNoMem]>;
2552
2553  def int_x86_mmx_padds_b : GCCBuiltin<"__builtin_ia32_paddsb">,
2554              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2555                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2556  def int_x86_mmx_padds_w : GCCBuiltin<"__builtin_ia32_paddsw">,
2557              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2558                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2559
2560  def int_x86_mmx_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb">,
2561              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2562                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2563  def int_x86_mmx_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw">,
2564              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2565                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2566
2567  // Subtraction
2568  def int_x86_mmx_psub_b : GCCBuiltin<"__builtin_ia32_psubb">,
2569              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2570                        [IntrNoMem]>;
2571  def int_x86_mmx_psub_w : GCCBuiltin<"__builtin_ia32_psubw">,
2572              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2573                        [IntrNoMem]>;
2574  def int_x86_mmx_psub_d : GCCBuiltin<"__builtin_ia32_psubd">,
2575              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2576                        [IntrNoMem]>;
2577  def int_x86_mmx_psub_q : GCCBuiltin<"__builtin_ia32_psubq">,
2578              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2579                        [IntrNoMem]>;
2580
2581  def int_x86_mmx_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb">,
2582              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2583                         llvm_x86mmx_ty], [IntrNoMem]>;
2584  def int_x86_mmx_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw">,
2585              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2586                         llvm_x86mmx_ty], [IntrNoMem]>;
2587
2588  def int_x86_mmx_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb">,
2589              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2590                         llvm_x86mmx_ty], [IntrNoMem]>;
2591  def int_x86_mmx_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw">,
2592              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2593                         llvm_x86mmx_ty], [IntrNoMem]>;
2594
2595  // Multiplication
2596  def int_x86_mmx_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw">,
2597              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2598                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2599  def int_x86_mmx_pmull_w : GCCBuiltin<"__builtin_ia32_pmullw">,
2600              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2601                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2602  def int_x86_mmx_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw">,
2603              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2604                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2605  def int_x86_mmx_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq">,
2606              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2607                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2608  def int_x86_mmx_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd">,
2609              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2610                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2611
2612  // Bitwise operations
2613  def int_x86_mmx_pand : GCCBuiltin<"__builtin_ia32_pand">,
2614              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2615                        [IntrNoMem]>;
2616  def int_x86_mmx_pandn : GCCBuiltin<"__builtin_ia32_pandn">,
2617              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2618                        [IntrNoMem]>;
2619  def int_x86_mmx_por : GCCBuiltin<"__builtin_ia32_por">,
2620              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2621                        [IntrNoMem]>;
2622  def int_x86_mmx_pxor : GCCBuiltin<"__builtin_ia32_pxor">,
2623              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2624                        [IntrNoMem]>;
2625
2626  // Averages
2627  def int_x86_mmx_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb">,
2628              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2629                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2630  def int_x86_mmx_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw">,
2631              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2632                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2633
2634  // Maximum
2635  def int_x86_mmx_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub">,
2636              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2637                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2638  def int_x86_mmx_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw">,
2639              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2640                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2641
2642  // Minimum
2643  def int_x86_mmx_pminu_b : GCCBuiltin<"__builtin_ia32_pminub">,
2644              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2645                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2646  def int_x86_mmx_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw">,
2647              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2648                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2649
2650  // Packed sum of absolute differences
2651  def int_x86_mmx_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw">,
2652              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2653                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2654}
2655
2656// Integer shift ops.
2657let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2658  // Shift left logical
2659  def int_x86_mmx_psll_w : GCCBuiltin<"__builtin_ia32_psllw">,
2660              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2661                         llvm_x86mmx_ty], [IntrNoMem]>;
2662  def int_x86_mmx_psll_d : GCCBuiltin<"__builtin_ia32_pslld">,
2663              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2664                         llvm_x86mmx_ty], [IntrNoMem]>;
2665  def int_x86_mmx_psll_q : GCCBuiltin<"__builtin_ia32_psllq">,
2666              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2667                         llvm_x86mmx_ty], [IntrNoMem]>;
2668
2669  def int_x86_mmx_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw">,
2670              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2671                         llvm_x86mmx_ty], [IntrNoMem]>;
2672  def int_x86_mmx_psrl_d : GCCBuiltin<"__builtin_ia32_psrld">,
2673              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2674                         llvm_x86mmx_ty], [IntrNoMem]>;
2675  def int_x86_mmx_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq">,
2676              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2677                         llvm_x86mmx_ty], [IntrNoMem]>;
2678
2679  def int_x86_mmx_psra_w : GCCBuiltin<"__builtin_ia32_psraw">,
2680              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2681                         llvm_x86mmx_ty], [IntrNoMem]>;
2682  def int_x86_mmx_psra_d : GCCBuiltin<"__builtin_ia32_psrad">,
2683              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2684                         llvm_x86mmx_ty], [IntrNoMem]>;
2685
2686  def int_x86_mmx_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi">,
2687              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2688                         llvm_i32_ty], [IntrNoMem]>;
2689  def int_x86_mmx_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi">,
2690              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2691                         llvm_i32_ty], [IntrNoMem]>;
2692  def int_x86_mmx_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi">,
2693              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2694                         llvm_i32_ty], [IntrNoMem]>;
2695
2696  def int_x86_mmx_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi">,
2697              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2698                         llvm_i32_ty], [IntrNoMem]>;
2699  def int_x86_mmx_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi">,
2700              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2701                         llvm_i32_ty], [IntrNoMem]>;
2702  def int_x86_mmx_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi">,
2703              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2704                         llvm_i32_ty], [IntrNoMem]>;
2705
2706  def int_x86_mmx_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi">,
2707              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2708                         llvm_i32_ty], [IntrNoMem]>;
2709  def int_x86_mmx_psrai_d : GCCBuiltin<"__builtin_ia32_psradi">,
2710              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2711                         llvm_i32_ty], [IntrNoMem]>;
2712}
2713
2714// Pack ops.
2715let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2716  def int_x86_mmx_packsswb : GCCBuiltin<"__builtin_ia32_packsswb">,
2717              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2718                         llvm_x86mmx_ty], [IntrNoMem]>;
2719  def int_x86_mmx_packssdw : GCCBuiltin<"__builtin_ia32_packssdw">,
2720              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2721                         llvm_x86mmx_ty], [IntrNoMem]>;
2722  def int_x86_mmx_packuswb : GCCBuiltin<"__builtin_ia32_packuswb">,
2723              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2724                         llvm_x86mmx_ty], [IntrNoMem]>;
2725}
2726
2727// Unpacking ops.
2728let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2729  def int_x86_mmx_punpckhbw : GCCBuiltin<"__builtin_ia32_punpckhbw">,
2730              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2731                        [IntrNoMem]>;
2732  def int_x86_mmx_punpckhwd : GCCBuiltin<"__builtin_ia32_punpckhwd">,
2733              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2734                        [IntrNoMem]>;
2735  def int_x86_mmx_punpckhdq : GCCBuiltin<"__builtin_ia32_punpckhdq">,
2736              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2737                        [IntrNoMem]>;
2738  def int_x86_mmx_punpcklbw : GCCBuiltin<"__builtin_ia32_punpcklbw">,
2739              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2740                        [IntrNoMem]>;
2741  def int_x86_mmx_punpcklwd : GCCBuiltin<"__builtin_ia32_punpcklwd">,
2742              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2743                        [IntrNoMem]>;
2744  def int_x86_mmx_punpckldq : GCCBuiltin<"__builtin_ia32_punpckldq">,
2745              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2746                        [IntrNoMem]>;
2747}
2748
2749// Integer comparison ops
2750let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2751  def int_x86_mmx_pcmpeq_b : GCCBuiltin<"__builtin_ia32_pcmpeqb">,
2752              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2753                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2754  def int_x86_mmx_pcmpeq_w : GCCBuiltin<"__builtin_ia32_pcmpeqw">,
2755              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2756                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2757  def int_x86_mmx_pcmpeq_d : GCCBuiltin<"__builtin_ia32_pcmpeqd">,
2758              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2759                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2760
2761  def int_x86_mmx_pcmpgt_b : GCCBuiltin<"__builtin_ia32_pcmpgtb">,
2762              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2763                         llvm_x86mmx_ty], [IntrNoMem]>;
2764  def int_x86_mmx_pcmpgt_w : GCCBuiltin<"__builtin_ia32_pcmpgtw">,
2765              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2766                         llvm_x86mmx_ty], [IntrNoMem]>;
2767  def int_x86_mmx_pcmpgt_d : GCCBuiltin<"__builtin_ia32_pcmpgtd">,
2768              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2769                         llvm_x86mmx_ty], [IntrNoMem]>;
2770}
2771
2772// Misc.
2773let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2774  def int_x86_mmx_maskmovq : GCCBuiltin<"__builtin_ia32_maskmovq">,
2775              Intrinsic<[], [llvm_x86mmx_ty, llvm_x86mmx_ty, llvm_ptr_ty], []>;
2776
2777  def int_x86_mmx_pmovmskb : GCCBuiltin<"__builtin_ia32_pmovmskb">,
2778              Intrinsic<[llvm_i32_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
2779
2780  def int_x86_mmx_movnt_dq : GCCBuiltin<"__builtin_ia32_movntq">,
2781              Intrinsic<[], [llvm_ptrx86mmx_ty, llvm_x86mmx_ty], []>;
2782
2783  def int_x86_mmx_palignr_b : GCCBuiltin<"__builtin_ia32_palignr">,
2784              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2785                        llvm_x86mmx_ty, llvm_i8_ty], [IntrNoMem]>;
2786
2787  def int_x86_mmx_pextr_w : GCCBuiltin<"__builtin_ia32_vec_ext_v4hi">,
2788              Intrinsic<[llvm_i32_ty], [llvm_x86mmx_ty, llvm_i32_ty],
2789                        [IntrNoMem]>;
2790
2791  def int_x86_mmx_pinsr_w : GCCBuiltin<"__builtin_ia32_vec_set_v4hi">,
2792              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2793                        llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2794}
2795
2796//===----------------------------------------------------------------------===//
2797// BMI
2798
2799let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2800  def int_x86_bmi_bextr_32 : GCCBuiltin<"__builtin_ia32_bextr_u32">,
2801              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2802  def int_x86_bmi_bextr_64 : GCCBuiltin<"__builtin_ia32_bextr_u64">,
2803              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2804  def int_x86_bmi_bzhi_32 : GCCBuiltin<"__builtin_ia32_bzhi_si">,
2805              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2806  def int_x86_bmi_bzhi_64 : GCCBuiltin<"__builtin_ia32_bzhi_di">,
2807              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2808  def int_x86_bmi_pdep_32 : GCCBuiltin<"__builtin_ia32_pdep_si">,
2809              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2810  def int_x86_bmi_pdep_64 : GCCBuiltin<"__builtin_ia32_pdep_di">,
2811              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2812  def int_x86_bmi_pext_32 : GCCBuiltin<"__builtin_ia32_pext_si">,
2813              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2814  def int_x86_bmi_pext_64 : GCCBuiltin<"__builtin_ia32_pext_di">,
2815              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2816}
2817
2818//===----------------------------------------------------------------------===//
2819// FS/GS Base
2820
2821let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2822  def int_x86_rdfsbase_32 : GCCBuiltin<"__builtin_ia32_rdfsbase32">,
2823              Intrinsic<[llvm_i32_ty], []>;
2824  def int_x86_rdgsbase_32 : GCCBuiltin<"__builtin_ia32_rdgsbase32">,
2825              Intrinsic<[llvm_i32_ty], []>;
2826  def int_x86_rdfsbase_64 : GCCBuiltin<"__builtin_ia32_rdfsbase64">,
2827              Intrinsic<[llvm_i64_ty], []>;
2828  def int_x86_rdgsbase_64 : GCCBuiltin<"__builtin_ia32_rdgsbase64">,
2829              Intrinsic<[llvm_i64_ty], []>;
2830  def int_x86_wrfsbase_32 : GCCBuiltin<"__builtin_ia32_wrfsbase32">,
2831              Intrinsic<[], [llvm_i32_ty]>;
2832  def int_x86_wrgsbase_32 : GCCBuiltin<"__builtin_ia32_wrgsbase32">,
2833              Intrinsic<[], [llvm_i32_ty]>;
2834  def int_x86_wrfsbase_64 : GCCBuiltin<"__builtin_ia32_wrfsbase64">,
2835              Intrinsic<[], [llvm_i64_ty]>;
2836  def int_x86_wrgsbase_64 : GCCBuiltin<"__builtin_ia32_wrgsbase64">,
2837              Intrinsic<[], [llvm_i64_ty]>;
2838}
2839
2840//===----------------------------------------------------------------------===//
2841// Half float conversion
2842
2843let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2844  def int_x86_vcvtph2ps_128 : GCCBuiltin<"__builtin_ia32_vcvtph2ps">,
2845              Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2846  def int_x86_vcvtph2ps_256 : GCCBuiltin<"__builtin_ia32_vcvtph2ps256">,
2847              Intrinsic<[llvm_v8f32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2848  def int_x86_vcvtps2ph_128 : GCCBuiltin<"__builtin_ia32_vcvtps2ph">,
2849              Intrinsic<[llvm_v8i16_ty], [llvm_v4f32_ty, llvm_i32_ty],
2850                        [IntrNoMem]>;
2851  def int_x86_vcvtps2ph_256 : GCCBuiltin<"__builtin_ia32_vcvtps2ph256">,
2852              Intrinsic<[llvm_v8i16_ty], [llvm_v8f32_ty, llvm_i32_ty],
2853                        [IntrNoMem]>;
2854  def int_x86_avx512_mask_vcvtph2ps_512 : GCCBuiltin<"__builtin_ia32_vcvtph2ps512_mask">,
2855              Intrinsic<[llvm_v16f32_ty], [llvm_v16i16_ty, llvm_v16f32_ty,
2856                                           llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
2857  def int_x86_avx512_mask_vcvtps2ph_512 : GCCBuiltin<"__builtin_ia32_vcvtps2ph512_mask">,
2858              Intrinsic<[llvm_v16i16_ty], [llvm_v16f32_ty, llvm_i32_ty,
2859                                           llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2860}
2861
2862//===----------------------------------------------------------------------===//
2863// TBM
2864
2865let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2866  def int_x86_tbm_bextri_u32 : GCCBuiltin<"__builtin_ia32_bextri_u32">,
2867        Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2868  def int_x86_tbm_bextri_u64 : GCCBuiltin<"__builtin_ia32_bextri_u64">,
2869        Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2870}
2871
2872//===----------------------------------------------------------------------===//
2873// RDRAND intrinsics - Return a random value and whether it is valid.
2874// RDSEED intrinsics - Return a NIST SP800-90B & C compliant random value and
2875// whether it is valid.
2876
2877let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2878  // These are declared side-effecting so they don't get eliminated by CSE or
2879  // LICM.
2880  def int_x86_rdrand_16 : Intrinsic<[llvm_i16_ty, llvm_i32_ty], [], []>;
2881  def int_x86_rdrand_32 : Intrinsic<[llvm_i32_ty, llvm_i32_ty], [], []>;
2882  def int_x86_rdrand_64 : Intrinsic<[llvm_i64_ty, llvm_i32_ty], [], []>;
2883  def int_x86_rdseed_16 : Intrinsic<[llvm_i16_ty, llvm_i32_ty], [], []>;
2884  def int_x86_rdseed_32 : Intrinsic<[llvm_i32_ty, llvm_i32_ty], [], []>;
2885  def int_x86_rdseed_64 : Intrinsic<[llvm_i64_ty, llvm_i32_ty], [], []>;
2886}
2887
2888//===----------------------------------------------------------------------===//
2889// ADX
2890
2891let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2892  def int_x86_addcarryx_u32: GCCBuiltin<"__builtin_ia32_addcarryx_u32">,
2893        Intrinsic<[llvm_i8_ty], [llvm_i8_ty, llvm_i32_ty, llvm_i32_ty,
2894                                 llvm_ptr_ty], [IntrReadWriteArgMem]>;
2895  def int_x86_addcarryx_u64: GCCBuiltin<"__builtin_ia32_addcarryx_u64">,
2896        Intrinsic<[llvm_i8_ty], [llvm_i8_ty, llvm_i64_ty, llvm_i64_ty,
2897                                 llvm_ptr_ty], [IntrReadWriteArgMem]>;
2898  def int_x86_addcarry_u32: GCCBuiltin<"__builtin_ia32_addcarry_u32">,
2899        Intrinsic<[llvm_i8_ty], [llvm_i8_ty, llvm_i32_ty, llvm_i32_ty,
2900                                 llvm_ptr_ty], [IntrReadWriteArgMem]>;
2901  def int_x86_addcarry_u64: GCCBuiltin<"__builtin_ia32_addcarry_u64">,
2902        Intrinsic<[llvm_i8_ty], [llvm_i8_ty, llvm_i64_ty, llvm_i64_ty,
2903                                 llvm_ptr_ty], [IntrReadWriteArgMem]>;
2904  def int_x86_subborrow_u32: GCCBuiltin<"__builtin_ia32_subborrow_u32">,
2905        Intrinsic<[llvm_i8_ty], [llvm_i8_ty, llvm_i32_ty, llvm_i32_ty,
2906                                 llvm_ptr_ty], [IntrReadWriteArgMem]>;
2907  def int_x86_subborrow_u64: GCCBuiltin<"__builtin_ia32_subborrow_u64">,
2908        Intrinsic<[llvm_i8_ty], [llvm_i8_ty, llvm_i64_ty, llvm_i64_ty,
2909                                 llvm_ptr_ty], [IntrReadWriteArgMem]>;
2910}
2911
2912//===----------------------------------------------------------------------===//
2913// RTM intrinsics. Transactional Memory support.
2914
2915let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2916  def int_x86_xbegin : GCCBuiltin<"__builtin_ia32_xbegin">,
2917              Intrinsic<[llvm_i32_ty], [], []>;
2918  def int_x86_xend : GCCBuiltin<"__builtin_ia32_xend">,
2919              Intrinsic<[], [], []>;
2920  def int_x86_xabort : GCCBuiltin<"__builtin_ia32_xabort">,
2921              Intrinsic<[], [llvm_i8_ty], [IntrNoReturn]>;
2922  def int_x86_xtest : GCCBuiltin<"__builtin_ia32_xtest">,
2923              Intrinsic<[llvm_i32_ty], [], []>;
2924}
2925
2926//===----------------------------------------------------------------------===//
2927// AVX512
2928
2929// Mask ops
2930let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2931  // Mask instructions
2932  // 16-bit mask
2933  def int_x86_avx512_kand_w : GCCBuiltin<"__builtin_ia32_kandhi">,
2934              Intrinsic<[llvm_i16_ty], [llvm_i16_ty, llvm_i16_ty],
2935                         [IntrNoMem]>;
2936  def int_x86_avx512_kandn_w : GCCBuiltin<"__builtin_ia32_kandnhi">,
2937              Intrinsic<[llvm_i16_ty], [llvm_i16_ty, llvm_i16_ty],
2938                         [IntrNoMem]>;
2939  def int_x86_avx512_knot_w : GCCBuiltin<"__builtin_ia32_knothi">,
2940              Intrinsic<[llvm_i16_ty], [llvm_i16_ty], [IntrNoMem]>;
2941  def int_x86_avx512_kor_w : GCCBuiltin<"__builtin_ia32_korhi">,
2942              Intrinsic<[llvm_i16_ty], [llvm_i16_ty, llvm_i16_ty],
2943                         [IntrNoMem]>;
2944  def int_x86_avx512_kxor_w : GCCBuiltin<"__builtin_ia32_kxorhi">,
2945              Intrinsic<[llvm_i16_ty], [llvm_i16_ty, llvm_i16_ty],
2946                         [IntrNoMem]>;
2947  def int_x86_avx512_kxnor_w : GCCBuiltin<"__builtin_ia32_kxnorhi">,
2948              Intrinsic<[llvm_i16_ty], [llvm_i16_ty, llvm_i16_ty],
2949                         [IntrNoMem]>;
2950  def int_x86_avx512_kunpck_bw : GCCBuiltin<"__builtin_ia32_kunpckhi">,
2951              Intrinsic<[llvm_i16_ty], [llvm_i16_ty, llvm_i16_ty],
2952                         [IntrNoMem]>;
2953  def int_x86_avx512_kortestz_w : GCCBuiltin<"__builtin_ia32_kortestzhi">,
2954              Intrinsic<[llvm_i32_ty], [llvm_i16_ty, llvm_i16_ty],
2955                        [IntrNoMem]>;
2956  def int_x86_avx512_kortestc_w : GCCBuiltin<"__builtin_ia32_kortestchi">,
2957              Intrinsic<[llvm_i32_ty], [llvm_i16_ty, llvm_i16_ty],
2958                        [IntrNoMem]>;
2959}
2960
2961// Conversion ops
2962let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2963  def int_x86_avx512_cvtss2usi : GCCBuiltin<"__builtin_ia32_cvtss2usi">,
2964              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
2965  def int_x86_avx512_cvtss2usi64 : GCCBuiltin<"__builtin_ia32_cvtss2usi64">,
2966              Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
2967  def int_x86_avx512_cvttss2usi : GCCBuiltin<"__builtin_ia32_cvttss2usi">,
2968              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
2969  def int_x86_avx512_cvttss2usi64 : GCCBuiltin<"__builtin_ia32_cvttss2usi64">,
2970              Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
2971  def int_x86_avx512_cvtusi2ss : GCCBuiltin<"__builtin_ia32_cvtusi2ss">,
2972              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
2973                         llvm_i32_ty], [IntrNoMem]>;
2974  def int_x86_avx512_cvtusi642ss : GCCBuiltin<"__builtin_ia32_cvtusi642ss">,
2975              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
2976                         llvm_i64_ty], [IntrNoMem]>;
2977
2978  def int_x86_avx512_cvtsd2usi : GCCBuiltin<"__builtin_ia32_cvtsd2usi">,
2979              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
2980  def int_x86_avx512_cvtsd2usi64 : GCCBuiltin<"__builtin_ia32_cvtsd2usi64">,
2981              Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
2982  def int_x86_avx512_cvttsd2usi : GCCBuiltin<"__builtin_ia32_cvttsd2usi">,
2983              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
2984  def int_x86_avx512_cvttsd2usi64 : GCCBuiltin<"__builtin_ia32_cvttsd2usi64">,
2985              Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
2986  def int_x86_avx512_cvtusi2sd : GCCBuiltin<"__builtin_ia32_cvtusi2sd">,
2987              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
2988                         llvm_i32_ty], [IntrNoMem]>;
2989  def int_x86_avx512_cvtusi642sd : GCCBuiltin<"__builtin_ia32_cvtusi642sd">,
2990              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
2991                         llvm_i64_ty], [IntrNoMem]>;
2992}
2993
2994// Vector convert
2995let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2996  def int_x86_avx512_mask_cvttps2dq_512: GCCBuiltin<"__builtin_ia32_cvttps2dq512_mask">,
2997        Intrinsic<[llvm_v16i32_ty], [llvm_v16f32_ty, llvm_v16i32_ty,
2998                                     llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
2999  def int_x86_avx512_mask_cvttps2udq_512: GCCBuiltin<"__builtin_ia32_cvttps2udq512_mask">,
3000        Intrinsic<[llvm_v16i32_ty], [llvm_v16f32_ty, llvm_v16i32_ty,
3001                                     llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3002  def int_x86_avx512_mask_cvttpd2dq_512: GCCBuiltin<"__builtin_ia32_cvttpd2dq512_mask">,
3003        Intrinsic<[llvm_v8i32_ty], [llvm_v8f64_ty, llvm_v8i32_ty,
3004                                    llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3005  def int_x86_avx512_mask_cvttpd2udq_512: GCCBuiltin<"__builtin_ia32_cvttpd2udq512_mask">,
3006        Intrinsic<[llvm_v8i32_ty], [llvm_v8f64_ty, llvm_v8i32_ty,
3007                                    llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3008  def int_x86_avx512_mask_rndscale_ps_512: GCCBuiltin<"__builtin_ia32_rndscaleps_mask">,
3009        Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_i32_ty, llvm_v16f32_ty,
3010                                     llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3011  def int_x86_avx512_mask_rndscale_pd_512: GCCBuiltin<"__builtin_ia32_rndscalepd_mask">,
3012        Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_i32_ty, llvm_v8f64_ty,
3013                                     llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3014  def int_x86_avx512_mask_cvtps2dq_512: GCCBuiltin<"__builtin_ia32_cvtps2dq512_mask">,
3015        Intrinsic<[llvm_v16i32_ty], [llvm_v16f32_ty, llvm_v16i32_ty,
3016                                     llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3017  def int_x86_avx512_mask_cvtpd2dq_512: GCCBuiltin<"__builtin_ia32_cvtpd2dq512_mask">,
3018        Intrinsic<[llvm_v8i32_ty], [llvm_v8f64_ty, llvm_v8i32_ty,
3019                                    llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3020  def int_x86_avx512_mask_cvtps2udq_512: GCCBuiltin<"__builtin_ia32_cvtps2udq512_mask">,
3021        Intrinsic<[llvm_v16i32_ty], [llvm_v16f32_ty, llvm_v16i32_ty,
3022                                     llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3023  def int_x86_avx512_mask_cvtpd2udq_512: GCCBuiltin<"__builtin_ia32_cvtpd2udq512_mask">,
3024        Intrinsic<[llvm_v8i32_ty], [llvm_v8f64_ty, llvm_v8i32_ty,
3025                                    llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3026  def int_x86_avx512_mask_cvtdq2ps_512 : GCCBuiltin<"__builtin_ia32_cvtdq2ps512_mask">,
3027        Intrinsic<[llvm_v16f32_ty], [llvm_v16i32_ty, llvm_v16f32_ty,
3028                                     llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3029  def int_x86_avx512_mask_cvtdq2pd_512 : GCCBuiltin<"__builtin_ia32_cvtdq2pd512_mask">,
3030        Intrinsic<[llvm_v8f64_ty], [llvm_v8i32_ty, llvm_v8f64_ty,
3031                                    llvm_i8_ty], [IntrNoMem]>;
3032  def int_x86_avx512_mask_cvtudq2ps_512 : GCCBuiltin<"__builtin_ia32_cvtudq2ps512_mask">,
3033        Intrinsic<[llvm_v16f32_ty], [llvm_v16i32_ty, llvm_v16f32_ty,
3034                                     llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3035  def int_x86_avx512_mask_cvtudq2pd_512 : GCCBuiltin<"__builtin_ia32_cvtudq2pd512_mask">,
3036        Intrinsic<[llvm_v8f64_ty], [llvm_v8i32_ty, llvm_v8f64_ty,
3037                                    llvm_i8_ty], [IntrNoMem]>;
3038  def int_x86_avx512_mask_cvtpd2ps_512 : GCCBuiltin<"__builtin_ia32_cvtpd2ps512_mask">,
3039        Intrinsic<[llvm_v8f32_ty], [llvm_v8f64_ty, llvm_v8f32_ty,
3040                                    llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3041}
3042
3043// Vector load with broadcast
3044let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
3045  def int_x86_avx512_vbroadcast_ss_512 :
3046        GCCBuiltin<"__builtin_ia32_vbroadcastss512">,
3047        Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
3048  def int_x86_avx512_vbroadcast_ss_ps_512 :
3049              GCCBuiltin<"__builtin_ia32_vbroadcastss_ps512">,
3050              Intrinsic<[llvm_v16f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
3051
3052  def int_x86_avx512_vbroadcast_sd_512 :
3053        GCCBuiltin<"__builtin_ia32_vbroadcastsd512">,
3054        Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
3055  def int_x86_avx512_vbroadcast_sd_pd_512 :
3056              GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd512">,
3057              Intrinsic<[llvm_v8f64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
3058
3059  def int_x86_avx512_pbroadcastd_512 :
3060         GCCBuiltin<"__builtin_ia32_pbroadcastd512">,
3061         Intrinsic<[llvm_v16i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
3062  def int_x86_avx512_pbroadcastd_i32_512 :
3063         Intrinsic<[llvm_v16i32_ty], [llvm_i32_ty], [IntrNoMem]>;
3064
3065  def int_x86_avx512_pbroadcastq_512 :
3066         GCCBuiltin<"__builtin_ia32_pbroadcastq512">,
3067         Intrinsic<[llvm_v8i64_ty], [llvm_v2i64_ty], [IntrNoMem]>;
3068  def int_x86_avx512_pbroadcastq_i64_512 :
3069         Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty], [IntrNoMem]>;
3070}
3071
3072// Vector sign and zero extend
3073let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
3074  def int_x86_avx512_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq512">,
3075              Intrinsic<[llvm_v8i64_ty], [llvm_v16i8_ty],
3076                        [IntrNoMem]>;
3077  def int_x86_avx512_pmovzxwd : GCCBuiltin<"__builtin_ia32_pmovzxwd512">,
3078              Intrinsic<[llvm_v16i32_ty], [llvm_v16i16_ty],
3079                        [IntrNoMem]>;
3080  def int_x86_avx512_pmovzxbd : GCCBuiltin<"__builtin_ia32_pmovzxbd512">,
3081              Intrinsic<[llvm_v16i32_ty], [llvm_v16i8_ty],
3082                        [IntrNoMem]>;
3083  def int_x86_avx512_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq512">,
3084              Intrinsic<[llvm_v8i64_ty], [llvm_v8i16_ty],
3085                        [IntrNoMem]>;
3086  def int_x86_avx512_pmovzxdq : GCCBuiltin<"__builtin_ia32_pmovzxdq512">,
3087              Intrinsic<[llvm_v8i64_ty], [llvm_v8i32_ty],
3088                        [IntrNoMem]>;
3089}
3090//Bitwise Ops
3091let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
3092  def int_x86_avx512_mask_pand_d_512 : GCCBuiltin<"__builtin_ia32_pandd512_mask">,
3093          Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3094                     llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
3095  def int_x86_avx512_mask_pand_q_512 : GCCBuiltin<"__builtin_ia32_pandq512_mask">,
3096          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
3097                     llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
3098  def int_x86_avx512_mask_por_d_512 : GCCBuiltin<"__builtin_ia32_pord512_mask">,
3099          Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3100                     llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
3101  def int_x86_avx512_mask_por_q_512 : GCCBuiltin<"__builtin_ia32_porq512_mask">,
3102          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
3103                     llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
3104  def int_x86_avx512_mask_pxor_d_512 : GCCBuiltin<"__builtin_ia32_pxord512_mask">,
3105          Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3106                     llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
3107  def int_x86_avx512_mask_pxor_q_512 : GCCBuiltin<"__builtin_ia32_pxorq512_mask">,
3108          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
3109                     llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
3110}
3111// Arithmetic ops
3112let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
3113
3114  def int_x86_avx512_mask_add_ps_512 : GCCBuiltin<"__builtin_ia32_addps512_mask">,
3115          Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3116                     llvm_v16f32_ty, llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3117  def int_x86_avx512_mask_add_pd_512 : GCCBuiltin<"__builtin_ia32_addpd512_mask">,
3118          Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3119                     llvm_v8f64_ty, llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3120  def int_x86_avx512_mask_sub_ps_512 : GCCBuiltin<"__builtin_ia32_subps512_mask">,
3121          Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3122                     llvm_v16f32_ty, llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3123  def int_x86_avx512_mask_sub_pd_512 : GCCBuiltin<"__builtin_ia32_subpd512_mask">,
3124          Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3125                     llvm_v8f64_ty, llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3126  def int_x86_avx512_mask_mul_ps_512 : GCCBuiltin<"__builtin_ia32_mulps512_mask">,
3127          Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3128                     llvm_v16f32_ty, llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3129  def int_x86_avx512_mask_mul_pd_512 : GCCBuiltin<"__builtin_ia32_mulpd512_mask">,
3130          Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3131                     llvm_v8f64_ty, llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3132  def int_x86_avx512_mask_div_ps_512 : GCCBuiltin<"__builtin_ia32_divps512_mask">,
3133          Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3134                     llvm_v16f32_ty, llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3135  def int_x86_avx512_mask_div_pd_512 : GCCBuiltin<"__builtin_ia32_divpd512_mask">,
3136          Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3137                     llvm_v8f64_ty, llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3138  def int_x86_avx512_mask_max_ps_512 : GCCBuiltin<"__builtin_ia32_maxps512_mask">,
3139          Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3140                     llvm_v16f32_ty, llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3141  def int_x86_avx512_mask_max_pd_512 : GCCBuiltin<"__builtin_ia32_maxpd512_mask">,
3142          Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3143                     llvm_v8f64_ty, llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3144  def int_x86_avx512_mask_min_ps_512 : GCCBuiltin<"__builtin_ia32_minps512_mask">,
3145          Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3146                     llvm_v16f32_ty, llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3147  def int_x86_avx512_mask_min_pd_512 : GCCBuiltin<"__builtin_ia32_minpd512_mask">,
3148          Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3149                     llvm_v8f64_ty, llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3150
3151  def int_x86_avx512_mask_rndscale_ss : GCCBuiltin<"__builtin_ia32_rndscaless_mask">,
3152          Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
3153                                     llvm_i8_ty, llvm_i32_ty, llvm_i32_ty],
3154                                     [IntrNoMem]>;
3155  def int_x86_avx512_mask_rndscale_sd : GCCBuiltin<"__builtin_ia32_rndscalesd_mask">,
3156          Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
3157                                      llvm_i8_ty, llvm_i32_ty, llvm_i32_ty],
3158                                     [IntrNoMem]>;
3159  def int_x86_avx512_sqrt_ss        : GCCBuiltin<"__builtin_ia32_sqrtrndss">,
3160              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty],
3161                        [IntrNoMem]>;
3162  def int_x86_avx512_sqrt_sd        : GCCBuiltin<"__builtin_ia32_sqrtrndsd">,
3163              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty],
3164                        [IntrNoMem]>;
3165
3166  def int_x86_avx512_sqrt_pd_512 : GCCBuiltin<"__builtin_ia32_sqrtpd512_mask">,
3167        Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3168                                    llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3169  def int_x86_avx512_sqrt_ps_512 : GCCBuiltin<"__builtin_ia32_sqrtps512_mask">,
3170        Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3171                                     llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3172
3173  def int_x86_avx512_rsqrt14_ss : GCCBuiltin<"__builtin_ia32_rsqrt14ss_mask">,
3174        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
3175                                    llvm_i8_ty], [IntrNoMem]>;
3176  def int_x86_avx512_rsqrt14_sd : GCCBuiltin<"__builtin_ia32_rsqrt14sd_mask">,
3177        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
3178                                    llvm_i8_ty], [IntrNoMem]>;
3179
3180  def int_x86_avx512_rsqrt14_pd_512 : GCCBuiltin<"__builtin_ia32_rsqrt14pd512_mask">,
3181        Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3182                                    llvm_i8_ty], [IntrNoMem]>;
3183  def int_x86_avx512_rsqrt14_ps_512 : GCCBuiltin<"__builtin_ia32_rsqrt14ps512_mask">,
3184        Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3185                                     llvm_i16_ty], [IntrNoMem]>;
3186  def int_x86_avx512_rcp14_ss : GCCBuiltin<"__builtin_ia32_rcp14ss_mask">,
3187        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty,
3188                                    llvm_i8_ty], [IntrNoMem]>;
3189  def int_x86_avx512_rcp14_sd : GCCBuiltin<"__builtin_ia32_rcp14sd_mask">,
3190        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,
3191                                    llvm_i8_ty], [IntrNoMem]>;
3192
3193  def int_x86_avx512_rcp14_pd_512 : GCCBuiltin<"__builtin_ia32_rcp14pd512_mask">,
3194        Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3195                                    llvm_i8_ty], [IntrNoMem]>;
3196  def int_x86_avx512_rcp14_ps_512 : GCCBuiltin<"__builtin_ia32_rcp14ps512_mask">,
3197        Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3198                                     llvm_i16_ty], [IntrNoMem]>;
3199
3200  def int_x86_avx512_rcp28_ps : GCCBuiltin<"__builtin_ia32_rcp28ps_mask">,
3201            Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3202                                         llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3203  def int_x86_avx512_rcp28_pd : GCCBuiltin<"__builtin_ia32_rcp28pd_mask">,
3204            Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3205                                        llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3206  def int_x86_avx512_exp2_ps : GCCBuiltin<"__builtin_ia32_exp2ps_mask">,
3207            Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3208                                         llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3209  def int_x86_avx512_exp2_pd : GCCBuiltin<"__builtin_ia32_exp2pd_mask">,
3210            Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3211                                        llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3212
3213  def int_x86_avx512_rcp28_ss : GCCBuiltin<"__builtin_ia32_rcp28ss_mask">,
3214            Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
3215                                        llvm_v4f32_ty, llvm_i8_ty, llvm_i32_ty],
3216                      [IntrNoMem]>;
3217  def int_x86_avx512_rcp28_sd : GCCBuiltin<"__builtin_ia32_rcp28sd_mask">,
3218            Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
3219                                        llvm_v2f64_ty, llvm_i8_ty, llvm_i32_ty],
3220                      [IntrNoMem]>;
3221  def int_x86_avx512_rsqrt28_ps : GCCBuiltin<"__builtin_ia32_rsqrt28ps_mask">,
3222            Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3223                                         llvm_i16_ty, llvm_i32_ty],
3224                      [IntrNoMem]>;
3225  def int_x86_avx512_rsqrt28_pd : GCCBuiltin<"__builtin_ia32_rsqrt28pd_mask">,
3226            Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3227                                        llvm_i8_ty, llvm_i32_ty],
3228                      [IntrNoMem]>;
3229  def int_x86_avx512_rsqrt28_ss : GCCBuiltin<"__builtin_ia32_rsqrt28ss_mask">,
3230            Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
3231                                        llvm_v4f32_ty, llvm_i8_ty, llvm_i32_ty],
3232                      [IntrNoMem]>;
3233  def int_x86_avx512_rsqrt28_sd : GCCBuiltin<"__builtin_ia32_rsqrt28sd_mask">,
3234            Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
3235                                        llvm_v2f64_ty, llvm_i8_ty, llvm_i32_ty],
3236                      [IntrNoMem]>;
3237}
3238
3239// Integer arithmetic ops
3240let TargetPrefix = "x86" in {
3241  def int_x86_avx512_mask_padd_d_512 : GCCBuiltin<"__builtin_ia32_paddd512_mask">,
3242          Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3243                     llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
3244  def int_x86_avx512_mask_padd_q_512 : GCCBuiltin<"__builtin_ia32_paddq512_mask">,
3245          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
3246                     llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
3247  def int_x86_avx512_mask_psub_d_512 : GCCBuiltin<"__builtin_ia32_psubd512_mask">,
3248          Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3249                     llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
3250  def int_x86_avx512_mask_psub_q_512 : GCCBuiltin<"__builtin_ia32_psubq512_mask">,
3251          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
3252                     llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
3253  def int_x86_avx512_mask_pmulu_dq_512 : GCCBuiltin<"__builtin_ia32_pmuludq512_mask">,
3254              Intrinsic<[llvm_v8i64_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3255                         llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
3256  def int_x86_avx512_mask_pmul_dq_512 : GCCBuiltin<"__builtin_ia32_pmuldq512_mask">,
3257              Intrinsic<[llvm_v8i64_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3258                         llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
3259}
3260// Gather and Scatter ops
3261let TargetPrefix = "x86" in {
3262  def int_x86_avx512_gather_dpd_512  : GCCBuiltin<"__builtin_ia32_gathersiv8df">,
3263          Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_ptr_ty,
3264                     llvm_v8i32_ty, llvm_i8_ty, llvm_i32_ty],
3265                    [IntrReadArgMem]>;
3266  def int_x86_avx512_gather_dps_512  : GCCBuiltin<"__builtin_ia32_gathersiv16sf">,
3267          Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_ptr_ty,
3268                     llvm_v16i32_ty, llvm_i16_ty, llvm_i32_ty],
3269                    [IntrReadArgMem]>;
3270  def int_x86_avx512_gather_qpd_512  : GCCBuiltin<"__builtin_ia32_gatherdiv8df">,
3271          Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_ptr_ty,
3272                     llvm_v8i64_ty, llvm_i8_ty, llvm_i32_ty],
3273                    [IntrReadArgMem]>;
3274  def int_x86_avx512_gather_qps_512  : GCCBuiltin<"__builtin_ia32_gatherdiv16sf">,
3275          Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_ptr_ty,
3276                     llvm_v8i64_ty, llvm_i8_ty, llvm_i32_ty],
3277                    [IntrReadArgMem]>;
3278
3279
3280  def int_x86_avx512_gather_dpq_512  : GCCBuiltin<"__builtin_ia32_gathersiv8di">,
3281          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_ptr_ty,
3282                     llvm_v8i32_ty, llvm_i8_ty, llvm_i32_ty],
3283                    [IntrReadArgMem]>;
3284  def int_x86_avx512_gather_dpi_512  : GCCBuiltin<"__builtin_ia32_gathersiv16si">,
3285          Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_ptr_ty,
3286                     llvm_v16i32_ty, llvm_i16_ty, llvm_i32_ty],
3287                    [IntrReadArgMem]>;
3288  def int_x86_avx512_gather_qpq_512  : GCCBuiltin<"__builtin_ia32_gatherdiv8di">,
3289          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_ptr_ty,
3290                     llvm_v8i64_ty, llvm_i8_ty, llvm_i32_ty],
3291                    [IntrReadArgMem]>;
3292  def int_x86_avx512_gather_qpi_512  : GCCBuiltin<"__builtin_ia32_gatherdiv16si">,
3293          Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_ptr_ty,
3294                     llvm_v8i64_ty, llvm_i8_ty, llvm_i32_ty],
3295                    [IntrReadArgMem]>;
3296
3297// scatter
3298  def int_x86_avx512_scatter_dpd_512  : GCCBuiltin<"__builtin_ia32_scattersiv8df">,
3299          Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty,
3300                        llvm_v8i32_ty, llvm_v8f64_ty, llvm_i32_ty],
3301                    [IntrReadWriteArgMem]>;
3302  def int_x86_avx512_scatter_dps_512  : GCCBuiltin<"__builtin_ia32_scattersiv16sf">,
3303          Intrinsic<[], [llvm_ptr_ty, llvm_i16_ty,
3304                       llvm_v16i32_ty, llvm_v16f32_ty, llvm_i32_ty],
3305                    [IntrReadWriteArgMem]>;
3306  def int_x86_avx512_scatter_qpd_512  : GCCBuiltin<"__builtin_ia32_scatterdiv8df">,
3307          Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty,
3308                     llvm_v8i64_ty, llvm_v8f64_ty, llvm_i32_ty],
3309                    [IntrReadWriteArgMem]>;
3310  def int_x86_avx512_scatter_qps_512  : GCCBuiltin<"__builtin_ia32_scatterdiv16sf">,
3311          Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty,
3312                     llvm_v8i64_ty, llvm_v8f32_ty, llvm_i32_ty],
3313                    [IntrReadWriteArgMem]>;
3314
3315
3316  def int_x86_avx512_scatter_dpq_512  : GCCBuiltin<"__builtin_ia32_scattersiv8di">,
3317          Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty,
3318                         llvm_v8i32_ty, llvm_v8i64_ty, llvm_i32_ty],
3319                    [IntrReadWriteArgMem]>;
3320  def int_x86_avx512_scatter_dpi_512  : GCCBuiltin<"__builtin_ia32_scattersiv16si">,
3321          Intrinsic<[], [llvm_ptr_ty, llvm_i16_ty,
3322                     llvm_v16i32_ty, llvm_v16i32_ty, llvm_i32_ty],
3323                    [IntrReadWriteArgMem]>;
3324  def int_x86_avx512_scatter_qpq_512  : GCCBuiltin<"__builtin_ia32_scatterdiv8di">,
3325          Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty,llvm_v8i64_ty, llvm_v8i64_ty,
3326                         llvm_i32_ty],
3327                    [IntrReadWriteArgMem]>;
3328  def int_x86_avx512_scatter_qpi_512  : GCCBuiltin<"__builtin_ia32_scatterdiv16si">,
3329          Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty, llvm_v8i64_ty, llvm_v8i32_ty,
3330                         llvm_i32_ty],
3331                    [IntrReadWriteArgMem]>;
3332
3333  // gather prefetch
3334  def int_x86_avx512_gatherpf_dpd_512  : GCCBuiltin<"__builtin_ia32_gatherpfdpd">,
3335          Intrinsic<[], [llvm_i8_ty, llvm_v8i32_ty, llvm_ptr_ty,
3336                     llvm_i32_ty, llvm_i32_ty], [IntrReadWriteArgMem]>;
3337  def int_x86_avx512_gatherpf_dps_512  : GCCBuiltin<"__builtin_ia32_gatherpfdps">,
3338          Intrinsic<[], [llvm_i16_ty, llvm_v16i32_ty, llvm_ptr_ty,
3339                     llvm_i32_ty, llvm_i32_ty], [IntrReadWriteArgMem]>;
3340  def int_x86_avx512_gatherpf_qpd_512  : GCCBuiltin<"__builtin_ia32_gatherpfqpd">,
3341          Intrinsic<[], [llvm_i8_ty, llvm_v8i64_ty, llvm_ptr_ty,
3342                     llvm_i32_ty, llvm_i32_ty], [IntrReadWriteArgMem]>;
3343  def int_x86_avx512_gatherpf_qps_512  : GCCBuiltin<"__builtin_ia32_gatherpfqps">,
3344          Intrinsic<[], [llvm_i8_ty, llvm_v8i64_ty, llvm_ptr_ty,
3345                     llvm_i32_ty, llvm_i32_ty], [IntrReadWriteArgMem]>;
3346
3347  // scatter prefetch
3348  def int_x86_avx512_scatterpf_dpd_512  : GCCBuiltin<"__builtin_ia32_scatterpfdpd">,
3349          Intrinsic<[], [llvm_i8_ty, llvm_v8i32_ty, llvm_ptr_ty,
3350                     llvm_i32_ty, llvm_i32_ty], [IntrReadWriteArgMem]>;
3351  def int_x86_avx512_scatterpf_dps_512  : GCCBuiltin<"__builtin_ia32_scatterpfdps">,
3352          Intrinsic<[], [llvm_i16_ty, llvm_v16i32_ty, llvm_ptr_ty,
3353                     llvm_i32_ty, llvm_i32_ty], [IntrReadWriteArgMem]>;
3354  def int_x86_avx512_scatterpf_qpd_512  : GCCBuiltin<"__builtin_ia32_scatterpfqpd">,
3355          Intrinsic<[], [llvm_i8_ty, llvm_v8i64_ty, llvm_ptr_ty,
3356                     llvm_i32_ty, llvm_i32_ty], [IntrReadWriteArgMem]>;
3357  def int_x86_avx512_scatterpf_qps_512  : GCCBuiltin<"__builtin_ia32_scatterpfqps">,
3358          Intrinsic<[], [llvm_i8_ty, llvm_v8i64_ty, llvm_ptr_ty,
3359                     llvm_i32_ty, llvm_i32_ty], [IntrReadWriteArgMem]>;
3360}
3361
3362// AVX-512 conflict detection
3363let TargetPrefix = "x86" in {
3364  def int_x86_avx512_mask_conflict_d_512 :
3365          GCCBuiltin<"__builtin_ia32_vpconflictsi_512_mask">,
3366          Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
3367                    llvm_v16i32_ty, llvm_i16_ty],
3368                    [IntrNoMem]>;
3369  def int_x86_avx512_mask_conflict_q_512 :
3370          GCCBuiltin<"__builtin_ia32_vpconflictdi_512_mask">,
3371          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
3372                    llvm_v8i64_ty, llvm_i8_ty],
3373                    [IntrNoMem]>;
3374  def int_x86_avx512_mask_lzcnt_d_512 :
3375          GCCBuiltin<"__builtin_ia32_vplzcntd_512_mask">,
3376          Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
3377                    llvm_v16i32_ty, llvm_i16_ty],
3378                    [IntrNoMem]>;
3379  def int_x86_avx512_mask_lzcnt_q_512 :
3380          GCCBuiltin<"__builtin_ia32_vplzcntq_512_mask">,
3381          Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
3382                    llvm_v8i64_ty, llvm_i8_ty],
3383                    [IntrNoMem]>;
3384}
3385
3386// Vector blend
3387let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
3388  def int_x86_avx512_mask_blend_ps_512 : GCCBuiltin<"__builtin_ia32_blendmps_512_mask">,
3389        Intrinsic<[llvm_v16f32_ty],
3390                  [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i16_ty],
3391                  [IntrNoMem]>;
3392  def int_x86_avx512_mask_blend_ps_256 : GCCBuiltin<"__builtin_ia32_blendmps_256_mask">,
3393        Intrinsic<[llvm_v8f32_ty],
3394                  [llvm_v8f32_ty, llvm_v8f32_ty, llvm_i8_ty],
3395                  [IntrNoMem]>;
3396  def int_x86_avx512_mask_blend_ps_128 : GCCBuiltin<"__builtin_ia32_blendmps_128_mask">,
3397        Intrinsic<[llvm_v4f32_ty],
3398                  [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
3399                  [IntrNoMem]>;
3400  def int_x86_avx512_mask_blend_pd_512 : GCCBuiltin<"__builtin_ia32_blendmpd_512_mask">,
3401        Intrinsic<[llvm_v8f64_ty],
3402                  [llvm_v8f64_ty, llvm_v8f64_ty, llvm_i8_ty],
3403                  [IntrNoMem]>;
3404  def int_x86_avx512_mask_blend_pd_256 : GCCBuiltin<"__builtin_ia32_blendmpd_256_mask">,
3405        Intrinsic<[llvm_v4f64_ty],
3406                  [llvm_v4f64_ty, llvm_v4f64_ty, llvm_i8_ty],
3407                  [IntrNoMem]>;
3408  def int_x86_avx512_mask_blend_pd_128 : GCCBuiltin<"__builtin_ia32_blendmpd_128_mask">,
3409        Intrinsic<[llvm_v2f64_ty],
3410                  [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
3411                  [IntrNoMem]>;
3412
3413  def int_x86_avx512_mask_blend_d_512 : GCCBuiltin<"__builtin_ia32_blendmd_512_mask">,
3414        Intrinsic<[llvm_v16i32_ty],
3415                  [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
3416                  [IntrNoMem]>;
3417  def int_x86_avx512_mask_blend_q_512 : GCCBuiltin<"__builtin_ia32_blendmq_512_mask">,
3418        Intrinsic<[llvm_v8i64_ty],
3419                  [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
3420                  [IntrNoMem]>;
3421  def int_x86_avx512_mask_blend_d_256 : GCCBuiltin<"__builtin_ia32_blendmd_256_mask">,
3422        Intrinsic<[llvm_v8i32_ty],
3423                  [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
3424                  [IntrNoMem]>;
3425  def int_x86_avx512_mask_blend_q_256 : GCCBuiltin<"__builtin_ia32_blendmq_256_mask">,
3426        Intrinsic<[llvm_v4i64_ty],
3427                  [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
3428                  [IntrNoMem]>;
3429  def int_x86_avx512_mask_blend_d_128 : GCCBuiltin<"__builtin_ia32_blendmd_128_mask">,
3430        Intrinsic<[llvm_v4i32_ty],
3431                  [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
3432                  [IntrNoMem]>;
3433  def int_x86_avx512_mask_blend_q_128 : GCCBuiltin<"__builtin_ia32_blendmq_128_mask">,
3434        Intrinsic<[llvm_v2i64_ty],
3435                  [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
3436                  [IntrNoMem]>;
3437
3438   def int_x86_avx512_mask_blend_w_512 : GCCBuiltin<"__builtin_ia32_blendmw_512_mask">,
3439        Intrinsic<[llvm_v32i16_ty],
3440                  [llvm_v32i16_ty, llvm_v32i16_ty, llvm_i32_ty],
3441                  [IntrNoMem]>;
3442   def int_x86_avx512_mask_blend_w_256 : GCCBuiltin<"__builtin_ia32_blendmw_256_mask">,
3443        Intrinsic<[llvm_v16i16_ty],
3444                  [llvm_v16i16_ty, llvm_v16i16_ty, llvm_i16_ty],
3445                  [IntrNoMem]>;
3446   def int_x86_avx512_mask_blend_w_128 : GCCBuiltin<"__builtin_ia32_blendmw_128_mask">,
3447        Intrinsic<[llvm_v8i16_ty],
3448                  [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty],
3449                  [IntrNoMem]>;
3450   def int_x86_avx512_mask_blend_b_512 : GCCBuiltin<"__builtin_ia32_blendmb_512_mask">,
3451        Intrinsic<[llvm_v64i8_ty],
3452                  [llvm_v64i8_ty, llvm_v64i8_ty, llvm_i64_ty],
3453                  [IntrNoMem]>;
3454   def int_x86_avx512_mask_blend_b_256 : GCCBuiltin<"__builtin_ia32_blendmb_256_mask">,
3455        Intrinsic<[llvm_v32i8_ty],
3456                  [llvm_v32i8_ty, llvm_v32i8_ty, llvm_i32_ty],
3457                  [IntrNoMem]>;
3458   def int_x86_avx512_mask_blend_b_128 : GCCBuiltin<"__builtin_ia32_blendmb_128_mask">,
3459        Intrinsic<[llvm_v16i8_ty],
3460                  [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i16_ty],
3461                  [IntrNoMem]>;
3462
3463}
3464
3465let TargetPrefix = "x86" in {
3466  def int_x86_avx512_mask_valign_q_512 : GCCBuiltin<"__builtin_ia32_alignq512_mask">,
3467        Intrinsic<[llvm_v8i64_ty],
3468                  [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty, llvm_v8i64_ty, llvm_i8_ty],
3469                  [IntrNoMem]>;
3470
3471  def int_x86_avx512_mask_valign_d_512 : GCCBuiltin<"__builtin_ia32_alignd512_mask">,
3472        Intrinsic<[llvm_v16i32_ty],
3473                  [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i8_ty, llvm_v16i32_ty, llvm_i16_ty],
3474                  [IntrNoMem]>;
3475}
3476
3477// Compares
3478let TargetPrefix = "x86" in {
3479  // 512-bit
3480  def int_x86_avx512_mask_pcmpeq_b_512 : GCCBuiltin<"__builtin_ia32_pcmpeqb512_mask">,
3481        Intrinsic<[llvm_i64_ty], [llvm_v64i8_ty, llvm_v64i8_ty, llvm_i64_ty],
3482                  [IntrNoMem]>;
3483  def int_x86_avx512_mask_pcmpeq_w_512 : GCCBuiltin<"__builtin_ia32_pcmpeqw512_mask">,
3484        Intrinsic<[llvm_i32_ty], [llvm_v32i16_ty, llvm_v32i16_ty, llvm_i32_ty],
3485                  [IntrNoMem]>;
3486  def int_x86_avx512_mask_pcmpeq_d_512 : GCCBuiltin<"__builtin_ia32_pcmpeqd512_mask">,
3487            Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
3488                      [IntrNoMem]>;
3489  def int_x86_avx512_mask_pcmpeq_q_512 : GCCBuiltin<"__builtin_ia32_pcmpeqq512_mask">,
3490            Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
3491                      [IntrNoMem]>;
3492
3493  def int_x86_avx512_mask_pcmpgt_b_512: GCCBuiltin<"__builtin_ia32_pcmpgtb512_mask">,
3494        Intrinsic<[llvm_i64_ty], [llvm_v64i8_ty, llvm_v64i8_ty, llvm_i64_ty],
3495                  [IntrNoMem]>;
3496  def int_x86_avx512_mask_pcmpgt_w_512: GCCBuiltin<"__builtin_ia32_pcmpgtw512_mask">,
3497        Intrinsic<[llvm_i32_ty], [llvm_v32i16_ty, llvm_v32i16_ty, llvm_i32_ty],
3498                  [IntrNoMem]>;
3499  def int_x86_avx512_mask_pcmpgt_d_512: GCCBuiltin<"__builtin_ia32_pcmpgtd512_mask">,
3500        Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
3501                  [IntrNoMem]>;
3502  def int_x86_avx512_mask_pcmpgt_q_512: GCCBuiltin<"__builtin_ia32_pcmpgtq512_mask">,
3503        Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
3504                  [IntrNoMem]>;
3505
3506  def int_x86_avx512_mask_cmp_b_512: GCCBuiltin<"__builtin_ia32_cmpb512_mask">,
3507        Intrinsic<[llvm_i64_ty], [llvm_v64i8_ty, llvm_v64i8_ty, llvm_i8_ty,
3508                  llvm_i64_ty], [IntrNoMem]>;
3509  def int_x86_avx512_mask_cmp_w_512: GCCBuiltin<"__builtin_ia32_cmpw512_mask">,
3510        Intrinsic<[llvm_i32_ty], [llvm_v32i16_ty, llvm_v32i16_ty, llvm_i8_ty,
3511                  llvm_i32_ty], [IntrNoMem]>;
3512  def int_x86_avx512_mask_cmp_d_512: GCCBuiltin<"__builtin_ia32_cmpd512_mask">,
3513        Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i8_ty,
3514                  llvm_i16_ty], [IntrNoMem ]>;
3515  def int_x86_avx512_mask_cmp_q_512: GCCBuiltin<"__builtin_ia32_cmpq512_mask">,
3516        Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty,
3517                  llvm_i8_ty], [IntrNoMem]>;
3518
3519  def int_x86_avx512_mask_ucmp_b_512: GCCBuiltin<"__builtin_ia32_ucmpb512_mask">,
3520        Intrinsic<[llvm_i64_ty], [llvm_v64i8_ty, llvm_v64i8_ty, llvm_i8_ty,
3521                  llvm_i64_ty], [IntrNoMem]>;
3522  def int_x86_avx512_mask_ucmp_w_512: GCCBuiltin<"__builtin_ia32_ucmpw512_mask">,
3523        Intrinsic<[llvm_i32_ty], [llvm_v32i16_ty, llvm_v32i16_ty, llvm_i8_ty,
3524                  llvm_i32_ty], [IntrNoMem]>;
3525  def int_x86_avx512_mask_ucmp_d_512: GCCBuiltin<"__builtin_ia32_ucmpd512_mask">,
3526        Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i8_ty,
3527                  llvm_i16_ty], [IntrNoMem]>;
3528  def int_x86_avx512_mask_ucmp_q_512: GCCBuiltin<"__builtin_ia32_ucmpq512_mask">,
3529        Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty,
3530                  llvm_i8_ty], [IntrNoMem]>;
3531
3532  // 256-bit
3533  def int_x86_avx512_mask_pcmpeq_b_256 : GCCBuiltin<"__builtin_ia32_pcmpeqb256_mask">,
3534        Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty, llvm_v32i8_ty, llvm_i32_ty],
3535                  [IntrNoMem]>;
3536  def int_x86_avx512_mask_pcmpeq_w_256 : GCCBuiltin<"__builtin_ia32_pcmpeqw256_mask">,
3537        Intrinsic<[llvm_i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, llvm_i16_ty],
3538                  [IntrNoMem]>;
3539  def int_x86_avx512_mask_pcmpeq_d_256 : GCCBuiltin<"__builtin_ia32_pcmpeqd256_mask">,
3540        Intrinsic<[llvm_i8_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
3541                  [IntrNoMem]>;
3542  def int_x86_avx512_mask_pcmpeq_q_256 : GCCBuiltin<"__builtin_ia32_pcmpeqq256_mask">,
3543        Intrinsic<[llvm_i8_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
3544                  [IntrNoMem]>;
3545
3546  def int_x86_avx512_mask_pcmpgt_b_256: GCCBuiltin<"__builtin_ia32_pcmpgtb256_mask">,
3547        Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty, llvm_v32i8_ty, llvm_i32_ty],
3548                  [IntrNoMem]>;
3549  def int_x86_avx512_mask_pcmpgt_w_256: GCCBuiltin<"__builtin_ia32_pcmpgtw256_mask">,
3550        Intrinsic<[llvm_i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, llvm_i16_ty],
3551                  [IntrNoMem]>;
3552  def int_x86_avx512_mask_pcmpgt_d_256: GCCBuiltin<"__builtin_ia32_pcmpgtd256_mask">,
3553        Intrinsic<[llvm_i8_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
3554                  [IntrNoMem]>;
3555  def int_x86_avx512_mask_pcmpgt_q_256: GCCBuiltin<"__builtin_ia32_pcmpgtq256_mask">,
3556        Intrinsic<[llvm_i8_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
3557                  [IntrNoMem]>;
3558
3559  def int_x86_avx512_mask_cmp_b_256: GCCBuiltin<"__builtin_ia32_cmpb256_mask">,
3560        Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty, llvm_v32i8_ty, llvm_i8_ty,
3561                  llvm_i32_ty], [IntrNoMem]>;
3562  def int_x86_avx512_mask_cmp_w_256: GCCBuiltin<"__builtin_ia32_cmpw256_mask">,
3563        Intrinsic<[llvm_i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, llvm_i8_ty,
3564                  llvm_i16_ty], [IntrNoMem]>;
3565  def int_x86_avx512_mask_cmp_d_256: GCCBuiltin<"__builtin_ia32_cmpd256_mask">,
3566        Intrinsic<[llvm_i8_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty,
3567                  llvm_i8_ty], [IntrNoMem]>;
3568  def int_x86_avx512_mask_cmp_q_256: GCCBuiltin<"__builtin_ia32_cmpq256_mask">,
3569        Intrinsic<[llvm_i8_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty,
3570                  llvm_i8_ty], [IntrNoMem]>;
3571
3572  def int_x86_avx512_mask_ucmp_b_256: GCCBuiltin<"__builtin_ia32_ucmpb256_mask">,
3573        Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty, llvm_v32i8_ty, llvm_i8_ty,
3574                  llvm_i32_ty], [IntrNoMem]>;
3575  def int_x86_avx512_mask_ucmp_w_256: GCCBuiltin<"__builtin_ia32_ucmpw256_mask">,
3576        Intrinsic<[llvm_i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, llvm_i8_ty,
3577                  llvm_i16_ty], [IntrNoMem]>;
3578  def int_x86_avx512_mask_ucmp_d_256: GCCBuiltin<"__builtin_ia32_ucmpd256_mask">,
3579        Intrinsic<[llvm_i8_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty,
3580                  llvm_i8_ty], [IntrNoMem]>;
3581  def int_x86_avx512_mask_ucmp_q_256: GCCBuiltin<"__builtin_ia32_ucmpq256_mask">,
3582        Intrinsic<[llvm_i8_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty,
3583                  llvm_i8_ty], [IntrNoMem]>;
3584
3585  // 128-bit
3586  def int_x86_avx512_mask_pcmpeq_b_128 : GCCBuiltin<"__builtin_ia32_pcmpeqb128_mask">,
3587        Intrinsic<[llvm_i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i16_ty],
3588                  [IntrNoMem]>;
3589  def int_x86_avx512_mask_pcmpeq_w_128 : GCCBuiltin<"__builtin_ia32_pcmpeqw128_mask">,
3590        Intrinsic<[llvm_i8_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty],
3591                  [IntrNoMem]>;
3592  def int_x86_avx512_mask_pcmpeq_d_128 : GCCBuiltin<"__builtin_ia32_pcmpeqd128_mask">,
3593        Intrinsic<[llvm_i8_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
3594                  [IntrNoMem]>;
3595  def int_x86_avx512_mask_pcmpeq_q_128 : GCCBuiltin<"__builtin_ia32_pcmpeqq128_mask">,
3596        Intrinsic<[llvm_i8_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
3597                  [IntrNoMem]>;
3598
3599  def int_x86_avx512_mask_pcmpgt_b_128: GCCBuiltin<"__builtin_ia32_pcmpgtb128_mask">,
3600        Intrinsic<[llvm_i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i16_ty],
3601                  [IntrNoMem]>;
3602  def int_x86_avx512_mask_pcmpgt_w_128: GCCBuiltin<"__builtin_ia32_pcmpgtw128_mask">,
3603        Intrinsic<[llvm_i8_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty],
3604                  [IntrNoMem]>;
3605  def int_x86_avx512_mask_pcmpgt_d_128: GCCBuiltin<"__builtin_ia32_pcmpgtd128_mask">,
3606        Intrinsic<[llvm_i8_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
3607                  [IntrNoMem]>;
3608  def int_x86_avx512_mask_pcmpgt_q_128: GCCBuiltin<"__builtin_ia32_pcmpgtq128_mask">,
3609        Intrinsic<[llvm_i8_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
3610                  [IntrNoMem]>;
3611
3612  def int_x86_avx512_mask_cmp_b_128: GCCBuiltin<"__builtin_ia32_cmpb128_mask">,
3613        Intrinsic<[llvm_i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty,
3614                  llvm_i16_ty], [IntrNoMem]>;
3615  def int_x86_avx512_mask_cmp_w_128: GCCBuiltin<"__builtin_ia32_cmpw128_mask">,
3616        Intrinsic<[llvm_i8_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty,
3617                  llvm_i8_ty], [IntrNoMem]>;
3618  def int_x86_avx512_mask_cmp_d_128: GCCBuiltin<"__builtin_ia32_cmpd128_mask">,
3619        Intrinsic<[llvm_i8_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty,
3620                  llvm_i8_ty], [IntrNoMem]>;
3621  def int_x86_avx512_mask_cmp_q_128: GCCBuiltin<"__builtin_ia32_cmpq128_mask">,
3622        Intrinsic<[llvm_i8_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty,
3623                  llvm_i8_ty], [IntrNoMem]>;
3624
3625  def int_x86_avx512_mask_ucmp_b_128: GCCBuiltin<"__builtin_ia32_ucmpb128_mask">,
3626        Intrinsic<[llvm_i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty,
3627                  llvm_i16_ty], [IntrNoMem]>;
3628  def int_x86_avx512_mask_ucmp_w_128: GCCBuiltin<"__builtin_ia32_ucmpw128_mask">,
3629        Intrinsic<[llvm_i8_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty,
3630                  llvm_i8_ty], [IntrNoMem]>;
3631  def int_x86_avx512_mask_ucmp_d_128: GCCBuiltin<"__builtin_ia32_ucmpd128_mask">,
3632        Intrinsic<[llvm_i8_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty,
3633                  llvm_i8_ty], [IntrNoMem]>;
3634  def int_x86_avx512_mask_ucmp_q_128: GCCBuiltin<"__builtin_ia32_ucmpq128_mask">,
3635        Intrinsic<[llvm_i8_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty,
3636                  llvm_i8_ty], [IntrNoMem]>;
3637}
3638
3639// Compress, Expand
3640let TargetPrefix = "x86" in {
3641  def int_x86_avx512_mask_compress_ps_512 :
3642                             GCCBuiltin<"__builtin_ia32_compresssf512_mask">,
3643        Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3644                   llvm_i16_ty], [IntrNoMem]>;
3645  def int_x86_avx512_mask_compress_pd_512 :
3646                             GCCBuiltin<"__builtin_ia32_compressdf512_mask">,
3647        Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3648                   llvm_i8_ty], [IntrNoMem]>;
3649  def int_x86_avx512_mask_compress_ps_256 :
3650                             GCCBuiltin<"__builtin_ia32_compresssf256_mask">,
3651        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty,
3652                   llvm_i8_ty], [IntrNoMem]>;
3653  def int_x86_avx512_mask_compress_pd_256 :
3654                             GCCBuiltin<"__builtin_ia32_compressdf256_mask">,
3655        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty,
3656                   llvm_i8_ty], [IntrNoMem]>;
3657  def int_x86_avx512_mask_compress_ps_128 :
3658                             GCCBuiltin<"__builtin_ia32_compresssf128_mask">,
3659        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
3660                   llvm_i8_ty], [IntrNoMem]>;
3661  def int_x86_avx512_mask_compress_pd_128 :
3662                             GCCBuiltin<"__builtin_ia32_compressdf128_mask">,
3663        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
3664                   llvm_i8_ty], [IntrNoMem]>;
3665
3666  def int_x86_avx512_mask_compress_store_ps_512 :
3667                            GCCBuiltin<"__builtin_ia32_compressstoresf512_mask">,
3668        Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty,
3669                   llvm_i16_ty], [IntrReadWriteArgMem]>;
3670  def int_x86_avx512_mask_compress_store_pd_512 :
3671                            GCCBuiltin<"__builtin_ia32_compressstoredf512_mask">,
3672        Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty,
3673                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3674  def int_x86_avx512_mask_compress_store_ps_256 :
3675                            GCCBuiltin<"__builtin_ia32_compressstoresf256_mask">,
3676        Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty,
3677                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3678  def int_x86_avx512_mask_compress_store_pd_256 :
3679                            GCCBuiltin<"__builtin_ia32_compressstoredf256_mask">,
3680        Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty,
3681                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3682  def int_x86_avx512_mask_compress_store_ps_128 :
3683                            GCCBuiltin<"__builtin_ia32_compressstoresf128_mask">,
3684        Intrinsic<[], [llvm_ptr_ty, llvm_v4f32_ty,
3685                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3686  def int_x86_avx512_mask_compress_store_pd_128 :
3687                            GCCBuiltin<"__builtin_ia32_compressstoredf128_mask">,
3688        Intrinsic<[], [llvm_ptr_ty, llvm_v2f64_ty,
3689                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3690
3691  def int_x86_avx512_mask_compress_d_512 :
3692                             GCCBuiltin<"__builtin_ia32_compresssi512_mask">,
3693        Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3694                   llvm_i16_ty], [IntrNoMem]>;
3695  def int_x86_avx512_mask_compress_q_512 :
3696                             GCCBuiltin<"__builtin_ia32_compressdi512_mask">,
3697        Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
3698                   llvm_i8_ty], [IntrNoMem]>;
3699  def int_x86_avx512_mask_compress_d_256 :
3700                             GCCBuiltin<"__builtin_ia32_compresssi256_mask">,
3701        Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
3702                   llvm_i8_ty], [IntrNoMem]>;
3703  def int_x86_avx512_mask_compress_q_256 :
3704                             GCCBuiltin<"__builtin_ia32_compressdi256_mask">,
3705        Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
3706                   llvm_i8_ty], [IntrNoMem]>;
3707  def int_x86_avx512_mask_compress_d_128 :
3708                             GCCBuiltin<"__builtin_ia32_compresssi128_mask">,
3709        Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
3710                   llvm_i8_ty], [IntrNoMem]>;
3711  def int_x86_avx512_mask_compress_q_128 :
3712                             GCCBuiltin<"__builtin_ia32_compressdi128_mask">,
3713        Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
3714                   llvm_i8_ty], [IntrNoMem]>;
3715
3716  def int_x86_avx512_mask_compress_store_d_512 :
3717                            GCCBuiltin<"__builtin_ia32_compressstoresi512_mask">,
3718        Intrinsic<[], [llvm_ptr_ty, llvm_v16i32_ty,
3719                   llvm_i16_ty], [IntrReadWriteArgMem]>;
3720  def int_x86_avx512_mask_compress_store_q_512 :
3721                            GCCBuiltin<"__builtin_ia32_compressstoredi512_mask">,
3722        Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty,
3723                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3724  def int_x86_avx512_mask_compress_store_d_256 :
3725                            GCCBuiltin<"__builtin_ia32_compressstoresi256_mask">,
3726        Intrinsic<[], [llvm_ptr_ty, llvm_v8i32_ty,
3727                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3728  def int_x86_avx512_mask_compress_store_q_256 :
3729                            GCCBuiltin<"__builtin_ia32_compressstoredi256_mask">,
3730        Intrinsic<[], [llvm_ptr_ty, llvm_v4i64_ty,
3731                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3732  def int_x86_avx512_mask_compress_store_d_128 :
3733                            GCCBuiltin<"__builtin_ia32_compressstoresi128_mask">,
3734        Intrinsic<[], [llvm_ptr_ty, llvm_v4i32_ty,
3735                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3736  def int_x86_avx512_mask_compress_store_q_128 :
3737                            GCCBuiltin<"__builtin_ia32_compressstoredi128_mask">,
3738        Intrinsic<[], [llvm_ptr_ty, llvm_v2i64_ty,
3739                   llvm_i8_ty], [IntrReadWriteArgMem]>;
3740
3741// expand
3742  def int_x86_avx512_mask_expand_ps_512 :
3743                             GCCBuiltin<"__builtin_ia32_expandsf512_mask">,
3744        Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_v16f32_ty,
3745                   llvm_i16_ty], [IntrNoMem]>;
3746  def int_x86_avx512_mask_expand_pd_512 :
3747                             GCCBuiltin<"__builtin_ia32_expanddf512_mask">,
3748        Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty,
3749                   llvm_i8_ty], [IntrNoMem]>;
3750  def int_x86_avx512_mask_expand_ps_256 :
3751                             GCCBuiltin<"__builtin_ia32_expandsf256_mask">,
3752        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty,
3753                   llvm_i8_ty], [IntrNoMem]>;
3754  def int_x86_avx512_mask_expand_pd_256 :
3755                             GCCBuiltin<"__builtin_ia32_expanddf256_mask">,
3756        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty,
3757                   llvm_i8_ty], [IntrNoMem]>;
3758  def int_x86_avx512_mask_expand_ps_128 :
3759                             GCCBuiltin<"__builtin_ia32_expandsf128_mask">,
3760        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
3761                   llvm_i8_ty], [IntrNoMem]>;
3762  def int_x86_avx512_mask_expand_pd_128 :
3763                             GCCBuiltin<"__builtin_ia32_expanddf128_mask">,
3764        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
3765                   llvm_i8_ty], [IntrNoMem]>;
3766
3767  def int_x86_avx512_mask_expand_load_ps_512 :
3768                            GCCBuiltin<"__builtin_ia32_expandloadsf512_mask">,
3769        Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty, llvm_v16f32_ty,
3770                   llvm_i16_ty], [IntrReadArgMem]>;
3771  def int_x86_avx512_mask_expand_load_pd_512 :
3772                            GCCBuiltin<"__builtin_ia32_expandloaddf512_mask">,
3773        Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty, llvm_v8f64_ty,
3774                   llvm_i8_ty], [IntrReadArgMem]>;
3775  def int_x86_avx512_mask_expand_load_ps_256 :
3776                            GCCBuiltin<"__builtin_ia32_expandloadsf256_mask">,
3777        Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty, llvm_v8f32_ty,
3778                   llvm_i8_ty], [IntrReadArgMem]>;
3779  def int_x86_avx512_mask_expand_load_pd_256 :
3780                            GCCBuiltin<"__builtin_ia32_expandloaddf256_mask">,
3781        Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty, llvm_v4f64_ty,
3782                   llvm_i8_ty], [IntrReadArgMem]>;
3783  def int_x86_avx512_mask_expand_load_ps_128 :
3784                            GCCBuiltin<"__builtin_ia32_expandloadsf128_mask">,
3785        Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty, llvm_v4f32_ty,
3786                   llvm_i8_ty], [IntrReadArgMem]>;
3787  def int_x86_avx512_mask_expand_load_pd_128 :
3788                            GCCBuiltin<"__builtin_ia32_expandloaddf128_mask">,
3789        Intrinsic<[llvm_v2f64_ty], [llvm_ptr_ty, llvm_v2f64_ty,
3790                   llvm_i8_ty], [IntrReadArgMem]>;
3791
3792  def int_x86_avx512_mask_expand_d_512 :
3793                             GCCBuiltin<"__builtin_ia32_expandsi512_mask">,
3794        Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
3795                   llvm_i16_ty], [IntrNoMem]>;
3796  def int_x86_avx512_mask_expand_q_512 :
3797                             GCCBuiltin<"__builtin_ia32_expanddi512_mask">,
3798        Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
3799                   llvm_i8_ty], [IntrNoMem]>;
3800  def int_x86_avx512_mask_expand_d_256 :
3801                             GCCBuiltin<"__builtin_ia32_expandsi256_mask">,
3802        Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
3803                   llvm_i8_ty], [IntrNoMem]>;
3804  def int_x86_avx512_mask_expand_q_256 :
3805                             GCCBuiltin<"__builtin_ia32_expanddi256_mask">,
3806        Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
3807                   llvm_i8_ty], [IntrNoMem]>;
3808  def int_x86_avx512_mask_expand_d_128 :
3809                             GCCBuiltin<"__builtin_ia32_expandsi128_mask">,
3810        Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
3811                   llvm_i8_ty], [IntrNoMem]>;
3812  def int_x86_avx512_mask_expand_q_128 :
3813                             GCCBuiltin<"__builtin_ia32_expanddi128_mask">,
3814        Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
3815                   llvm_i8_ty], [IntrNoMem]>;
3816
3817  def int_x86_avx512_mask_expand_load_d_512 :
3818                            GCCBuiltin<"__builtin_ia32_expandloadsi512_mask">,
3819        Intrinsic<[llvm_v16i32_ty], [llvm_ptr_ty, llvm_v16i32_ty,
3820                   llvm_i16_ty], [IntrReadArgMem]>;
3821  def int_x86_avx512_mask_expand_load_q_512 :
3822                            GCCBuiltin<"__builtin_ia32_expandloaddi512_mask">,
3823        Intrinsic<[llvm_v8i64_ty], [llvm_ptr_ty, llvm_v8i64_ty,
3824                   llvm_i8_ty], [IntrReadArgMem]>;
3825  def int_x86_avx512_mask_expand_load_d_256 :
3826                            GCCBuiltin<"__builtin_ia32_expandloadsi256_mask">,
3827        Intrinsic<[llvm_v8i32_ty], [llvm_ptr_ty, llvm_v8i32_ty,
3828                   llvm_i8_ty], [IntrReadArgMem]>;
3829  def int_x86_avx512_mask_expand_load_q_256 :
3830                            GCCBuiltin<"__builtin_ia32_expandloaddi256_mask">,
3831        Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty, llvm_v4i64_ty,
3832                   llvm_i8_ty], [IntrReadArgMem]>;
3833  def int_x86_avx512_mask_expand_load_d_128 :
3834                            GCCBuiltin<"__builtin_ia32_expandloadsi128_mask">,
3835        Intrinsic<[llvm_v4i32_ty], [llvm_ptr_ty, llvm_v4i32_ty,
3836                   llvm_i8_ty], [IntrReadArgMem]>;
3837  def int_x86_avx512_mask_expand_load_q_128 :
3838                            GCCBuiltin<"__builtin_ia32_expandloaddi128_mask">,
3839        Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_v2i64_ty,
3840                   llvm_i8_ty], [IntrReadArgMem]>;
3841
3842}
3843// Misc.
3844let TargetPrefix = "x86" in {
3845  def int_x86_avx512_mask_cmp_ps_512 : GCCBuiltin<"__builtin_ia32_cmpps512_mask">,
3846            Intrinsic<[llvm_i16_ty], [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i8_ty,
3847                                      llvm_i16_ty, llvm_i32_ty], [IntrNoMem]>;
3848  def int_x86_avx512_mask_cmp_pd_512 : GCCBuiltin<"__builtin_ia32_cmppd512_mask">,
3849            Intrinsic<[llvm_i8_ty], [llvm_v8f64_ty, llvm_v8f64_ty, llvm_i8_ty,
3850                                      llvm_i8_ty, llvm_i32_ty], [IntrNoMem]>;
3851  def int_x86_avx512_movntdqa : GCCBuiltin<"__builtin_ia32_movntdqa512">,
3852            Intrinsic<[llvm_v8i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
3853}
3854
3855//===----------------------------------------------------------------------===//
3856// SHA intrinsics
3857let TargetPrefix = "x86" in {
3858  def int_x86_sha1rnds4 : GCCBuiltin<"__builtin_ia32_sha1rnds4">,
3859        Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
3860                  [IntrNoMem]>;
3861  def int_x86_sha1nexte : GCCBuiltin<"__builtin_ia32_sha1nexte">,
3862      Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>;
3863  def int_x86_sha1msg1 : GCCBuiltin<"__builtin_ia32_sha1msg1">,
3864      Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>;
3865  def int_x86_sha1msg2 : GCCBuiltin<"__builtin_ia32_sha1msg2">,
3866      Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>;
3867  def int_x86_sha256rnds2 : GCCBuiltin<"__builtin_ia32_sha256rnds2">,
3868      Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
3869                [IntrNoMem]>;
3870  def int_x86_sha256msg1 : GCCBuiltin<"__builtin_ia32_sha256msg1">,
3871      Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>;
3872  def int_x86_sha256msg2 : GCCBuiltin<"__builtin_ia32_sha256msg2">,
3873      Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>;
3874}
3875