ARM: support TLS accesses on Darwin platforms
[oota-llvm.git] / include / llvm / IR / IntrinsicsX86.td
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
16 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
17   def int_x86_int : Intrinsic<[], [llvm_i8_ty]>;
18 }
19
20 //===----------------------------------------------------------------------===//
21 // SEH intrinsics for Windows
22 let TargetPrefix = "x86" in {
23   def int_x86_seh_lsda : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty], [IntrNoMem]>;
24
25   // Marks the EH registration node created in LLVM IR prior to code generation.
26   def int_x86_seh_ehregnode : Intrinsic<[], [llvm_ptr_ty], []>;
27
28   // Given a pointer to the end of an EH registration object, returns the true
29   // parent frame address that can be used with llvm.localrecover.
30   def int_x86_seh_recoverfp : Intrinsic<[llvm_ptr_ty],
31                                         [llvm_ptr_ty, llvm_ptr_ty],
32                                         [IntrNoMem]>;
33 }
34
35 //===----------------------------------------------------------------------===//
36 // FLAGS.
37 let TargetPrefix = "x86" in {
38   def int_x86_flags_read_u32 : GCCBuiltin<"__builtin_ia32_readeflags_u32">,
39         Intrinsic<[llvm_i32_ty], [], []>;
40   def int_x86_flags_read_u64 : GCCBuiltin<"__builtin_ia32_readeflags_u64">,
41         Intrinsic<[llvm_i64_ty], [], []>;
42   def int_x86_flags_write_u32 : GCCBuiltin<"__builtin_ia32_writeeflags_u32">,
43         Intrinsic<[], [llvm_i32_ty], []>;
44   def int_x86_flags_write_u64 : GCCBuiltin<"__builtin_ia32_writeeflags_u64">,
45         Intrinsic<[], [llvm_i64_ty], []>;
46 }
47
48 //===----------------------------------------------------------------------===//
49 // Read Time Stamp Counter.
50 let TargetPrefix = "x86" in {
51   def int_x86_rdtsc : GCCBuiltin<"__builtin_ia32_rdtsc">,
52               Intrinsic<[llvm_i64_ty], [], []>;
53   def int_x86_rdtscp : GCCBuiltin<"__builtin_ia32_rdtscp">,
54               Intrinsic<[llvm_i64_ty], [llvm_ptr_ty], [IntrReadWriteArgMem]>;
55 }
56
57 // Read Performance-Monitoring Counter.
58 let TargetPrefix = "x86" in {
59   def int_x86_rdpmc : GCCBuiltin<"__builtin_ia32_rdpmc">,
60               Intrinsic<[llvm_i64_ty], [llvm_i32_ty], []>;
61 }
62
63 //===----------------------------------------------------------------------===//
64 // 3DNow!
65
66 let TargetPrefix = "x86" in {
67   def int_x86_3dnow_pavgusb : GCCBuiltin<"__builtin_ia32_pavgusb">,
68               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
69                         [IntrNoMem]>;
70   def int_x86_3dnow_pf2id : GCCBuiltin<"__builtin_ia32_pf2id">,
71               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
72   def int_x86_3dnow_pfacc : GCCBuiltin<"__builtin_ia32_pfacc">,
73               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
74                         [IntrNoMem]>;
75   def int_x86_3dnow_pfadd : GCCBuiltin<"__builtin_ia32_pfadd">,
76               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
77                         [IntrNoMem]>;
78   def int_x86_3dnow_pfcmpeq : GCCBuiltin<"__builtin_ia32_pfcmpeq">,
79               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
80                         [IntrNoMem]>;
81   def int_x86_3dnow_pfcmpge : GCCBuiltin<"__builtin_ia32_pfcmpge">,
82               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
83                         [IntrNoMem]>;
84   def int_x86_3dnow_pfcmpgt : GCCBuiltin<"__builtin_ia32_pfcmpgt">,
85               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
86                         [IntrNoMem]>;
87   def int_x86_3dnow_pfmax : GCCBuiltin<"__builtin_ia32_pfmax">,
88               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
89                         [IntrNoMem]>;
90   def int_x86_3dnow_pfmin : GCCBuiltin<"__builtin_ia32_pfmin">,
91               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
92                         [IntrNoMem]>;
93   def int_x86_3dnow_pfmul : GCCBuiltin<"__builtin_ia32_pfmul">,
94               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
95                         [IntrNoMem]>;
96   def int_x86_3dnow_pfrcp : GCCBuiltin<"__builtin_ia32_pfrcp">,
97               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
98   def int_x86_3dnow_pfrcpit1 : GCCBuiltin<"__builtin_ia32_pfrcpit1">,
99               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
100                         [IntrNoMem]>;
101   def int_x86_3dnow_pfrcpit2 : GCCBuiltin<"__builtin_ia32_pfrcpit2">,
102               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
103                         [IntrNoMem]>;
104   def int_x86_3dnow_pfrsqrt : GCCBuiltin<"__builtin_ia32_pfrsqrt">,
105               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
106   def int_x86_3dnow_pfrsqit1 : GCCBuiltin<"__builtin_ia32_pfrsqit1">,
107               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
108                         [IntrNoMem]>;
109   def int_x86_3dnow_pfsub : GCCBuiltin<"__builtin_ia32_pfsub">,
110               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
111                         [IntrNoMem]>;
112   def int_x86_3dnow_pfsubr : GCCBuiltin<"__builtin_ia32_pfsubr">,
113               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
114                         [IntrNoMem]>;
115   def int_x86_3dnow_pi2fd : GCCBuiltin<"__builtin_ia32_pi2fd">,
116               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
117   def int_x86_3dnow_pmulhrw : GCCBuiltin<"__builtin_ia32_pmulhrw">,
118               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
119                         [IntrNoMem]>;
120 }
121
122 //===----------------------------------------------------------------------===//
123 // 3DNow! extensions
124
125 let TargetPrefix = "x86" in {
126   def int_x86_3dnowa_pf2iw : GCCBuiltin<"__builtin_ia32_pf2iw">,
127               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
128   def int_x86_3dnowa_pfnacc : GCCBuiltin<"__builtin_ia32_pfnacc">,
129               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
130                         [IntrNoMem]>;
131   def int_x86_3dnowa_pfpnacc : GCCBuiltin<"__builtin_ia32_pfpnacc">,
132               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
133                         [IntrNoMem]>;
134   def int_x86_3dnowa_pi2fw : GCCBuiltin<"__builtin_ia32_pi2fw">,
135               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
136   def int_x86_3dnowa_pswapd :
137               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
138 }
139
140 //===----------------------------------------------------------------------===//
141 // SSE1
142
143 // Arithmetic ops
144 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
145   def int_x86_sse_add_ss : GCCBuiltin<"__builtin_ia32_addss">,
146               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
147                          llvm_v4f32_ty], [IntrNoMem]>;
148   def int_x86_sse_sub_ss : GCCBuiltin<"__builtin_ia32_subss">,
149               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
150                          llvm_v4f32_ty], [IntrNoMem]>;
151   def int_x86_sse_mul_ss : GCCBuiltin<"__builtin_ia32_mulss">,
152               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
153                          llvm_v4f32_ty], [IntrNoMem]>;
154   def int_x86_sse_div_ss : GCCBuiltin<"__builtin_ia32_divss">,
155               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
156                          llvm_v4f32_ty], [IntrNoMem]>;
157   def int_x86_sse_sqrt_ss : GCCBuiltin<"__builtin_ia32_sqrtss">,
158               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
159                         [IntrNoMem]>;
160   def int_x86_sse_sqrt_ps : GCCBuiltin<"__builtin_ia32_sqrtps">,
161               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
162                         [IntrNoMem]>;
163   def int_x86_sse_rcp_ss : GCCBuiltin<"__builtin_ia32_rcpss">,
164               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
165                         [IntrNoMem]>;
166   def int_x86_sse_rcp_ps : GCCBuiltin<"__builtin_ia32_rcpps">,
167               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
168                         [IntrNoMem]>;
169   def int_x86_sse_rsqrt_ss : GCCBuiltin<"__builtin_ia32_rsqrtss">,
170               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
171                         [IntrNoMem]>;
172   def int_x86_sse_rsqrt_ps : GCCBuiltin<"__builtin_ia32_rsqrtps">,
173               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
174                         [IntrNoMem]>;
175   def int_x86_sse_min_ss : GCCBuiltin<"__builtin_ia32_minss">,
176               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
177                          llvm_v4f32_ty], [IntrNoMem]>;
178   def int_x86_sse_min_ps : GCCBuiltin<"__builtin_ia32_minps">,
179               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
180                          llvm_v4f32_ty], [IntrNoMem]>;
181   def int_x86_sse_max_ss : GCCBuiltin<"__builtin_ia32_maxss">,
182               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
183                          llvm_v4f32_ty], [IntrNoMem]>;
184   def int_x86_sse_max_ps : GCCBuiltin<"__builtin_ia32_maxps">,
185               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
186                          llvm_v4f32_ty], [IntrNoMem]>;
187 }
188
189 // Comparison ops
190 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
191   def int_x86_sse_cmp_ss : GCCBuiltin<"__builtin_ia32_cmpss">,
192               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
193                          llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
194   def int_x86_sse_cmp_ps : GCCBuiltin<"__builtin_ia32_cmpps">,
195               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
196                          llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
197   def int_x86_sse_comieq_ss : GCCBuiltin<"__builtin_ia32_comieq">,
198               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
199                          llvm_v4f32_ty], [IntrNoMem]>;
200   def int_x86_sse_comilt_ss : GCCBuiltin<"__builtin_ia32_comilt">,
201               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
202                          llvm_v4f32_ty], [IntrNoMem]>;
203   def int_x86_sse_comile_ss : GCCBuiltin<"__builtin_ia32_comile">,
204               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
205                          llvm_v4f32_ty], [IntrNoMem]>;
206   def int_x86_sse_comigt_ss : GCCBuiltin<"__builtin_ia32_comigt">,
207               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
208                          llvm_v4f32_ty], [IntrNoMem]>;
209   def int_x86_sse_comige_ss : GCCBuiltin<"__builtin_ia32_comige">,
210               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
211                          llvm_v4f32_ty], [IntrNoMem]>;
212   def int_x86_sse_comineq_ss : GCCBuiltin<"__builtin_ia32_comineq">,
213               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
214                          llvm_v4f32_ty], [IntrNoMem]>;
215   def int_x86_sse_ucomieq_ss : GCCBuiltin<"__builtin_ia32_ucomieq">,
216               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
217                          llvm_v4f32_ty], [IntrNoMem]>;
218   def int_x86_sse_ucomilt_ss : GCCBuiltin<"__builtin_ia32_ucomilt">,
219               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
220                          llvm_v4f32_ty], [IntrNoMem]>;
221   def int_x86_sse_ucomile_ss : GCCBuiltin<"__builtin_ia32_ucomile">,
222               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
223                          llvm_v4f32_ty], [IntrNoMem]>;
224   def int_x86_sse_ucomigt_ss : GCCBuiltin<"__builtin_ia32_ucomigt">,
225               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
226                          llvm_v4f32_ty], [IntrNoMem]>;
227   def int_x86_sse_ucomige_ss : GCCBuiltin<"__builtin_ia32_ucomige">,
228               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
229                          llvm_v4f32_ty], [IntrNoMem]>;
230   def int_x86_sse_ucomineq_ss : GCCBuiltin<"__builtin_ia32_ucomineq">,
231               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
232                          llvm_v4f32_ty], [IntrNoMem]>;
233 }
234
235
236 // Conversion ops
237 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
238   def int_x86_sse_cvtss2si : GCCBuiltin<"__builtin_ia32_cvtss2si">,
239               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
240   def int_x86_sse_cvtss2si64 : GCCBuiltin<"__builtin_ia32_cvtss2si64">,
241               Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
242   def int_x86_sse_cvttss2si : GCCBuiltin<"__builtin_ia32_cvttss2si">,
243               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
244   def int_x86_sse_cvttss2si64 : GCCBuiltin<"__builtin_ia32_cvttss2si64">,
245               Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
246   def int_x86_sse_cvtsi2ss : GCCBuiltin<"__builtin_ia32_cvtsi2ss">,
247               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
248                          llvm_i32_ty], [IntrNoMem]>;
249   def int_x86_sse_cvtsi642ss : GCCBuiltin<"__builtin_ia32_cvtsi642ss">,
250               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
251                          llvm_i64_ty], [IntrNoMem]>;
252
253   def int_x86_sse_cvtps2pi : GCCBuiltin<"__builtin_ia32_cvtps2pi">,
254               Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>;
255   def int_x86_sse_cvttps2pi: GCCBuiltin<"__builtin_ia32_cvttps2pi">,
256               Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>;
257   def int_x86_sse_cvtpi2ps : GCCBuiltin<"__builtin_ia32_cvtpi2ps">,
258               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
259                          llvm_x86mmx_ty], [IntrNoMem]>;
260 }
261
262 // SIMD store ops
263 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
264   def int_x86_sse_storeu_ps : GCCBuiltin<"__builtin_ia32_storeups">,
265               Intrinsic<[], [llvm_ptr_ty,
266                          llvm_v4f32_ty], [IntrReadWriteArgMem]>;
267 }
268
269 // Cacheability support ops
270 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
271   def int_x86_sse_sfence : GCCBuiltin<"__builtin_ia32_sfence">,
272               Intrinsic<[], [], []>;
273 }
274
275 // Control register.
276 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
277   def int_x86_sse_stmxcsr :
278               Intrinsic<[], [llvm_ptr_ty], []>;
279   def int_x86_sse_ldmxcsr :
280               Intrinsic<[], [llvm_ptr_ty], []>;
281 }
282
283 // Misc.
284 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
285   def int_x86_sse_movmsk_ps : GCCBuiltin<"__builtin_ia32_movmskps">,
286               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
287 }
288
289 //===----------------------------------------------------------------------===//
290 // SSE2
291
292 // FP arithmetic ops
293 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
294   def int_x86_sse2_add_sd : GCCBuiltin<"__builtin_ia32_addsd">,
295               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
296                          llvm_v2f64_ty], [IntrNoMem]>;
297   def int_x86_sse2_sub_sd : GCCBuiltin<"__builtin_ia32_subsd">,
298               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
299                          llvm_v2f64_ty], [IntrNoMem]>;
300   def int_x86_sse2_mul_sd : GCCBuiltin<"__builtin_ia32_mulsd">,
301               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
302                          llvm_v2f64_ty], [IntrNoMem]>;
303   def int_x86_sse2_div_sd : GCCBuiltin<"__builtin_ia32_divsd">,
304               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
305                          llvm_v2f64_ty], [IntrNoMem]>;
306   def int_x86_sse2_sqrt_sd : GCCBuiltin<"__builtin_ia32_sqrtsd">,
307               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty],
308                         [IntrNoMem]>;
309   def int_x86_sse2_sqrt_pd : GCCBuiltin<"__builtin_ia32_sqrtpd">,
310               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty],
311                         [IntrNoMem]>;
312   def int_x86_sse2_min_sd : GCCBuiltin<"__builtin_ia32_minsd">,
313               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
314                          llvm_v2f64_ty], [IntrNoMem]>;
315   def int_x86_sse2_min_pd : GCCBuiltin<"__builtin_ia32_minpd">,
316               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
317                          llvm_v2f64_ty], [IntrNoMem]>;
318   def int_x86_sse2_max_sd : GCCBuiltin<"__builtin_ia32_maxsd">,
319               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
320                          llvm_v2f64_ty], [IntrNoMem]>;
321   def int_x86_sse2_max_pd : GCCBuiltin<"__builtin_ia32_maxpd">,
322               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
323                          llvm_v2f64_ty], [IntrNoMem]>;
324 }
325
326 // FP comparison ops
327 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
328   def int_x86_sse2_cmp_sd : GCCBuiltin<"__builtin_ia32_cmpsd">,
329               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
330                          llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
331   def int_x86_sse2_cmp_pd : GCCBuiltin<"__builtin_ia32_cmppd">,
332               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
333                          llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
334   def int_x86_sse2_comieq_sd : GCCBuiltin<"__builtin_ia32_comisdeq">,
335               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
336                          llvm_v2f64_ty], [IntrNoMem]>;
337   def int_x86_sse2_comilt_sd : GCCBuiltin<"__builtin_ia32_comisdlt">,
338               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
339                          llvm_v2f64_ty], [IntrNoMem]>;
340   def int_x86_sse2_comile_sd : GCCBuiltin<"__builtin_ia32_comisdle">,
341               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
342                          llvm_v2f64_ty], [IntrNoMem]>;
343   def int_x86_sse2_comigt_sd : GCCBuiltin<"__builtin_ia32_comisdgt">,
344               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
345                          llvm_v2f64_ty], [IntrNoMem]>;
346   def int_x86_sse2_comige_sd : GCCBuiltin<"__builtin_ia32_comisdge">,
347               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
348                          llvm_v2f64_ty], [IntrNoMem]>;
349   def int_x86_sse2_comineq_sd : GCCBuiltin<"__builtin_ia32_comisdneq">,
350               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
351                          llvm_v2f64_ty], [IntrNoMem]>;
352   def int_x86_sse2_ucomieq_sd : GCCBuiltin<"__builtin_ia32_ucomisdeq">,
353               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
354                          llvm_v2f64_ty], [IntrNoMem]>;
355   def int_x86_sse2_ucomilt_sd : GCCBuiltin<"__builtin_ia32_ucomisdlt">,
356               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
357                          llvm_v2f64_ty], [IntrNoMem]>;
358   def int_x86_sse2_ucomile_sd : GCCBuiltin<"__builtin_ia32_ucomisdle">,
359               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
360                          llvm_v2f64_ty], [IntrNoMem]>;
361   def int_x86_sse2_ucomigt_sd : GCCBuiltin<"__builtin_ia32_ucomisdgt">,
362               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
363                          llvm_v2f64_ty], [IntrNoMem]>;
364   def int_x86_sse2_ucomige_sd : GCCBuiltin<"__builtin_ia32_ucomisdge">,
365               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
366                          llvm_v2f64_ty], [IntrNoMem]>;
367   def int_x86_sse2_ucomineq_sd : GCCBuiltin<"__builtin_ia32_ucomisdneq">,
368               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
369                          llvm_v2f64_ty], [IntrNoMem]>;
370 }
371
372 // Integer arithmetic ops.
373 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
374   def int_x86_sse2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb128">,
375               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
376                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
377   def int_x86_sse2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw128">,
378               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
379                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
380   def int_x86_sse2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb128">,
381               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
382                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
383   def int_x86_sse2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw128">,
384               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
385                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
386   def int_x86_sse2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb128">,
387               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
388                          llvm_v16i8_ty], [IntrNoMem]>;
389   def int_x86_sse2_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw128">,
390               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
391                          llvm_v8i16_ty], [IntrNoMem]>;
392   def int_x86_sse2_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb128">,
393               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
394                          llvm_v16i8_ty], [IntrNoMem]>;
395   def int_x86_sse2_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw128">,
396               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
397                          llvm_v8i16_ty], [IntrNoMem]>;
398   def int_x86_sse2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw128">,
399               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
400                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
401   def int_x86_sse2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw128">,
402               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
403                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
404   def int_x86_sse2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq128">,
405               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty,
406                          llvm_v4i32_ty], [IntrNoMem, Commutative]>;
407   def int_x86_sse2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd128">,
408               Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty,
409                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
410   def int_x86_sse2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb128">,
411               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
412                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
413   def int_x86_sse2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw128">,
414               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
415                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
416   def int_x86_sse2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub128">,
417               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
418                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
419   def int_x86_sse2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw128">,
420               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
421                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
422   def int_x86_sse2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub128">,
423               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
424                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
425   def int_x86_sse2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw128">,
426               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
427                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
428   def int_x86_sse2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw128">,
429               Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty,
430                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
431 }
432
433 // Integer shift ops.
434 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
435   def int_x86_sse2_psll_w : GCCBuiltin<"__builtin_ia32_psllw128">,
436               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
437                          llvm_v8i16_ty], [IntrNoMem]>;
438   def int_x86_sse2_psll_d : GCCBuiltin<"__builtin_ia32_pslld128">,
439               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
440                          llvm_v4i32_ty], [IntrNoMem]>;
441   def int_x86_sse2_psll_q : GCCBuiltin<"__builtin_ia32_psllq128">,
442               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
443                          llvm_v2i64_ty], [IntrNoMem]>;
444   def int_x86_sse2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw128">,
445               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
446                          llvm_v8i16_ty], [IntrNoMem]>;
447   def int_x86_sse2_psrl_d : GCCBuiltin<"__builtin_ia32_psrld128">,
448               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
449                          llvm_v4i32_ty], [IntrNoMem]>;
450   def int_x86_sse2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq128">,
451               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
452                          llvm_v2i64_ty], [IntrNoMem]>;
453   def int_x86_sse2_psra_w : GCCBuiltin<"__builtin_ia32_psraw128">,
454               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
455                          llvm_v8i16_ty], [IntrNoMem]>;
456   def int_x86_sse2_psra_d : GCCBuiltin<"__builtin_ia32_psrad128">,
457               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
458                          llvm_v4i32_ty], [IntrNoMem]>;
459
460   def int_x86_sse2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi128">,
461               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
462                          llvm_i32_ty], [IntrNoMem]>;
463   def int_x86_sse2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi128">,
464               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
465                          llvm_i32_ty], [IntrNoMem]>;
466   def int_x86_sse2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi128">,
467               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
468                          llvm_i32_ty], [IntrNoMem]>;
469   def int_x86_sse2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi128">,
470               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
471                          llvm_i32_ty], [IntrNoMem]>;
472   def int_x86_sse2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi128">,
473               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
474                          llvm_i32_ty], [IntrNoMem]>;
475   def int_x86_sse2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi128">,
476               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
477                          llvm_i32_ty], [IntrNoMem]>;
478   def int_x86_sse2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi128">,
479               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
480                          llvm_i32_ty], [IntrNoMem]>;
481   def int_x86_sse2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi128">,
482               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
483                          llvm_i32_ty], [IntrNoMem]>;
484 }
485
486 // Conversion ops
487 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
488   def int_x86_sse2_cvtdq2pd : GCCBuiltin<"__builtin_ia32_cvtdq2pd">,
489               Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
490   def int_x86_sse2_cvtdq2ps : GCCBuiltin<"__builtin_ia32_cvtdq2ps">,
491               Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
492   def int_x86_sse2_cvtpd2dq : GCCBuiltin<"__builtin_ia32_cvtpd2dq">,
493               Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
494   def int_x86_sse2_cvttpd2dq : GCCBuiltin<"__builtin_ia32_cvttpd2dq">,
495               Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
496   def int_x86_sse2_cvtpd2ps : GCCBuiltin<"__builtin_ia32_cvtpd2ps">,
497               Intrinsic<[llvm_v4f32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
498   def int_x86_sse2_cvtps2dq : GCCBuiltin<"__builtin_ia32_cvtps2dq">,
499               Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
500   def int_x86_sse2_cvttps2dq : GCCBuiltin<"__builtin_ia32_cvttps2dq">,
501               Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
502   def int_x86_sse2_cvtps2pd : GCCBuiltin<"__builtin_ia32_cvtps2pd">,
503               Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
504   def int_x86_sse2_cvtsd2si : GCCBuiltin<"__builtin_ia32_cvtsd2si">,
505               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
506   def int_x86_sse2_cvtsd2si64 : GCCBuiltin<"__builtin_ia32_cvtsd2si64">,
507               Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
508   def int_x86_sse2_cvttsd2si : GCCBuiltin<"__builtin_ia32_cvttsd2si">,
509               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
510   def int_x86_sse2_cvttsd2si64 : GCCBuiltin<"__builtin_ia32_cvttsd2si64">,
511               Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
512   def int_x86_sse2_cvtsi2sd : GCCBuiltin<"__builtin_ia32_cvtsi2sd">,
513               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
514                          llvm_i32_ty], [IntrNoMem]>;
515   def int_x86_sse2_cvtsi642sd : GCCBuiltin<"__builtin_ia32_cvtsi642sd">,
516               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
517                          llvm_i64_ty], [IntrNoMem]>;
518   def int_x86_sse2_cvtsd2ss : GCCBuiltin<"__builtin_ia32_cvtsd2ss">,
519               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
520                          llvm_v2f64_ty], [IntrNoMem]>;
521   def int_x86_sse2_cvtss2sd : GCCBuiltin<"__builtin_ia32_cvtss2sd">,
522               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
523                          llvm_v4f32_ty], [IntrNoMem]>;
524   def int_x86_sse_cvtpd2pi : GCCBuiltin<"__builtin_ia32_cvtpd2pi">,
525               Intrinsic<[llvm_x86mmx_ty], [llvm_v2f64_ty], [IntrNoMem]>;
526   def int_x86_sse_cvttpd2pi: GCCBuiltin<"__builtin_ia32_cvttpd2pi">,
527               Intrinsic<[llvm_x86mmx_ty], [llvm_v2f64_ty], [IntrNoMem]>;
528   def int_x86_sse_cvtpi2pd : GCCBuiltin<"__builtin_ia32_cvtpi2pd">,
529               Intrinsic<[llvm_v2f64_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
530 }
531
532 // SIMD store ops
533 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
534   def int_x86_sse2_storeu_pd : GCCBuiltin<"__builtin_ia32_storeupd">,
535               Intrinsic<[], [llvm_ptr_ty,
536                          llvm_v2f64_ty], [IntrReadWriteArgMem]>;
537   def int_x86_sse2_storeu_dq : GCCBuiltin<"__builtin_ia32_storedqu">,
538               Intrinsic<[], [llvm_ptr_ty,
539                          llvm_v16i8_ty], [IntrReadWriteArgMem]>;
540   def int_x86_sse2_storel_dq : GCCBuiltin<"__builtin_ia32_storelv4si">,
541               Intrinsic<[], [llvm_ptr_ty,
542                          llvm_v4i32_ty], [IntrReadWriteArgMem]>;
543 }
544
545 // Misc.
546 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
547   def int_x86_sse2_packsswb_128 : GCCBuiltin<"__builtin_ia32_packsswb128">,
548               Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty,
549                          llvm_v8i16_ty], [IntrNoMem]>;
550   def int_x86_sse2_packssdw_128 : GCCBuiltin<"__builtin_ia32_packssdw128">,
551               Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty,
552                          llvm_v4i32_ty], [IntrNoMem]>;
553   def int_x86_sse2_packuswb_128 : GCCBuiltin<"__builtin_ia32_packuswb128">,
554               Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty,
555                          llvm_v8i16_ty], [IntrNoMem]>;
556   def int_x86_sse2_movmsk_pd : GCCBuiltin<"__builtin_ia32_movmskpd">,
557               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
558   def int_x86_sse2_pmovmskb_128 : GCCBuiltin<"__builtin_ia32_pmovmskb128">,
559               Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>;
560   def int_x86_sse2_maskmov_dqu : GCCBuiltin<"__builtin_ia32_maskmovdqu">,
561               Intrinsic<[], [llvm_v16i8_ty,
562                          llvm_v16i8_ty, llvm_ptr_ty], []>;
563   def int_x86_sse2_clflush : GCCBuiltin<"__builtin_ia32_clflush">,
564               Intrinsic<[], [llvm_ptr_ty], []>;
565   def int_x86_sse2_lfence : GCCBuiltin<"__builtin_ia32_lfence">,
566               Intrinsic<[], [], []>;
567   def int_x86_sse2_mfence : GCCBuiltin<"__builtin_ia32_mfence">,
568               Intrinsic<[], [], []>;
569   def int_x86_sse2_pause : GCCBuiltin<"__builtin_ia32_pause">,
570               Intrinsic<[], [], []>;
571 }
572
573 //===----------------------------------------------------------------------===//
574 // SSE3
575
576 // Addition / subtraction ops.
577 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
578   def int_x86_sse3_addsub_ps : GCCBuiltin<"__builtin_ia32_addsubps">,
579               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
580                          llvm_v4f32_ty], [IntrNoMem]>;
581   def int_x86_sse3_addsub_pd : GCCBuiltin<"__builtin_ia32_addsubpd">,
582               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
583                          llvm_v2f64_ty], [IntrNoMem]>;
584 }
585
586 // Horizontal ops.
587 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
588   def int_x86_sse3_hadd_ps : GCCBuiltin<"__builtin_ia32_haddps">,
589               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
590                          llvm_v4f32_ty], [IntrNoMem]>;
591   def int_x86_sse3_hadd_pd : GCCBuiltin<"__builtin_ia32_haddpd">,
592               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
593                          llvm_v2f64_ty], [IntrNoMem]>;
594   def int_x86_sse3_hsub_ps : GCCBuiltin<"__builtin_ia32_hsubps">,
595               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
596                          llvm_v4f32_ty], [IntrNoMem]>;
597   def int_x86_sse3_hsub_pd : GCCBuiltin<"__builtin_ia32_hsubpd">,
598               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
599                          llvm_v2f64_ty], [IntrNoMem]>;
600 }
601
602 // Specialized unaligned load.
603 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
604   def int_x86_sse3_ldu_dq : GCCBuiltin<"__builtin_ia32_lddqu">,
605               Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
606 }
607
608 // Thread synchronization ops.
609 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
610   def int_x86_sse3_monitor : GCCBuiltin<"__builtin_ia32_monitor">,
611               Intrinsic<[], [llvm_ptr_ty,
612                          llvm_i32_ty, llvm_i32_ty], []>;
613   def int_x86_sse3_mwait : GCCBuiltin<"__builtin_ia32_mwait">,
614               Intrinsic<[], [llvm_i32_ty,
615                          llvm_i32_ty], []>;
616 }
617
618 //===----------------------------------------------------------------------===//
619 // SSSE3
620
621 // Horizontal arithmetic ops
622 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
623   def int_x86_ssse3_phadd_w         : GCCBuiltin<"__builtin_ia32_phaddw">,
624               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
625                          llvm_x86mmx_ty], [IntrNoMem]>;
626   def int_x86_ssse3_phadd_w_128     : GCCBuiltin<"__builtin_ia32_phaddw128">,
627               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
628                          llvm_v8i16_ty], [IntrNoMem]>;
629
630   def int_x86_ssse3_phadd_d         : GCCBuiltin<"__builtin_ia32_phaddd">,
631               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
632                          llvm_x86mmx_ty], [IntrNoMem]>;
633   def int_x86_ssse3_phadd_d_128     : GCCBuiltin<"__builtin_ia32_phaddd128">,
634               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
635                          llvm_v4i32_ty], [IntrNoMem]>;
636
637   def int_x86_ssse3_phadd_sw        : GCCBuiltin<"__builtin_ia32_phaddsw">,
638               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
639                          llvm_x86mmx_ty], [IntrNoMem]>;
640   def int_x86_ssse3_phadd_sw_128    : GCCBuiltin<"__builtin_ia32_phaddsw128">,
641               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
642                          llvm_v8i16_ty], [IntrNoMem]>;
643
644   def int_x86_ssse3_phsub_w         : GCCBuiltin<"__builtin_ia32_phsubw">,
645               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
646                          llvm_x86mmx_ty], [IntrNoMem]>;
647   def int_x86_ssse3_phsub_w_128     : GCCBuiltin<"__builtin_ia32_phsubw128">,
648               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
649                          llvm_v8i16_ty], [IntrNoMem]>;
650
651   def int_x86_ssse3_phsub_d         : GCCBuiltin<"__builtin_ia32_phsubd">,
652               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
653                          llvm_x86mmx_ty], [IntrNoMem]>;
654   def int_x86_ssse3_phsub_d_128     : GCCBuiltin<"__builtin_ia32_phsubd128">,
655               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
656                          llvm_v4i32_ty], [IntrNoMem]>;
657
658   def int_x86_ssse3_phsub_sw        : GCCBuiltin<"__builtin_ia32_phsubsw">,
659               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
660                          llvm_x86mmx_ty], [IntrNoMem]>;
661   def int_x86_ssse3_phsub_sw_128    : GCCBuiltin<"__builtin_ia32_phsubsw128">,
662               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
663                          llvm_v8i16_ty], [IntrNoMem]>;
664
665   def int_x86_ssse3_pmadd_ub_sw     : GCCBuiltin<"__builtin_ia32_pmaddubsw">,
666               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
667                          llvm_x86mmx_ty], [IntrNoMem]>;
668   def int_x86_ssse3_pmadd_ub_sw_128 : GCCBuiltin<"__builtin_ia32_pmaddubsw128">,
669               Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty,
670                          llvm_v16i8_ty], [IntrNoMem]>;
671 }
672
673 // Packed multiply high with round and scale
674 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
675   def int_x86_ssse3_pmul_hr_sw      : GCCBuiltin<"__builtin_ia32_pmulhrsw">,
676               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
677                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
678   def int_x86_ssse3_pmul_hr_sw_128  : GCCBuiltin<"__builtin_ia32_pmulhrsw128">,
679               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
680                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
681 }
682
683 // Shuffle ops
684 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
685   def int_x86_ssse3_pshuf_b         : GCCBuiltin<"__builtin_ia32_pshufb">,
686               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
687                          llvm_x86mmx_ty], [IntrNoMem]>;
688   def int_x86_ssse3_pshuf_b_128     : GCCBuiltin<"__builtin_ia32_pshufb128">,
689               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
690                          llvm_v16i8_ty], [IntrNoMem]>;
691   def int_x86_sse2_pshuf_d          : GCCBuiltin<"__builtin_ia32_pshufd">,
692               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i8_ty],
693                          [IntrNoMem]>;
694   def int_x86_sse2_pshufl_w         : GCCBuiltin<"__builtin_ia32_pshuflw">,
695               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i8_ty],
696                          [IntrNoMem]>;
697   def int_x86_sse2_pshufh_w         : GCCBuiltin<"__builtin_ia32_pshufhw">,
698               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i8_ty],
699                          [IntrNoMem]>;
700   def int_x86_sse_pshuf_w           : GCCBuiltin<"__builtin_ia32_pshufw">,
701               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_i8_ty],
702                          [IntrNoMem]>;
703 }
704
705 // Sign ops
706 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
707   def int_x86_ssse3_psign_b         : GCCBuiltin<"__builtin_ia32_psignb">,
708               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
709                          llvm_x86mmx_ty], [IntrNoMem]>;
710   def int_x86_ssse3_psign_b_128     : GCCBuiltin<"__builtin_ia32_psignb128">,
711               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
712                          llvm_v16i8_ty], [IntrNoMem]>;
713
714   def int_x86_ssse3_psign_w         : GCCBuiltin<"__builtin_ia32_psignw">,
715               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
716                          llvm_x86mmx_ty], [IntrNoMem]>;
717   def int_x86_ssse3_psign_w_128     : GCCBuiltin<"__builtin_ia32_psignw128">,
718               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
719                          llvm_v8i16_ty], [IntrNoMem]>;
720
721   def int_x86_ssse3_psign_d         : GCCBuiltin<"__builtin_ia32_psignd">,
722               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
723                          llvm_x86mmx_ty], [IntrNoMem]>;
724   def int_x86_ssse3_psign_d_128     : GCCBuiltin<"__builtin_ia32_psignd128">,
725               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
726                          llvm_v4i32_ty], [IntrNoMem]>;
727 }
728
729 // Absolute value ops
730 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
731   def int_x86_ssse3_pabs_b     : GCCBuiltin<"__builtin_ia32_pabsb">,
732               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
733   def int_x86_ssse3_pabs_b_128 : GCCBuiltin<"__builtin_ia32_pabsb128">,
734               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>;
735
736   def int_x86_ssse3_pabs_w     : GCCBuiltin<"__builtin_ia32_pabsw">,
737               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
738   def int_x86_ssse3_pabs_w_128 : GCCBuiltin<"__builtin_ia32_pabsw128">,
739               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>;
740
741   def int_x86_ssse3_pabs_d     : GCCBuiltin<"__builtin_ia32_pabsd">,
742               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
743   def int_x86_ssse3_pabs_d_128 : GCCBuiltin<"__builtin_ia32_pabsd128">,
744               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
745 }
746
747 //===----------------------------------------------------------------------===//
748 // SSE4.1
749
750 // FP rounding ops
751 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
752   def int_x86_sse41_round_ss        : GCCBuiltin<"__builtin_ia32_roundss">,
753               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
754                          llvm_i32_ty], [IntrNoMem]>;
755   def int_x86_sse41_round_ps        : GCCBuiltin<"__builtin_ia32_roundps">,
756               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
757                          llvm_i32_ty], [IntrNoMem]>;
758   def int_x86_sse41_round_sd        : GCCBuiltin<"__builtin_ia32_roundsd">,
759               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
760                          llvm_i32_ty], [IntrNoMem]>;
761   def int_x86_sse41_round_pd        : GCCBuiltin<"__builtin_ia32_roundpd">,
762               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
763                          llvm_i32_ty], [IntrNoMem]>;
764 }
765
766 // Vector sign and zero extend
767 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
768   def int_x86_sse41_pmovsxbd        : GCCBuiltin<"__builtin_ia32_pmovsxbd128">,
769               Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty],
770                         [IntrNoMem]>;
771   def int_x86_sse41_pmovsxbq        : GCCBuiltin<"__builtin_ia32_pmovsxbq128">,
772               Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty],
773                         [IntrNoMem]>;
774   def int_x86_sse41_pmovsxbw        : GCCBuiltin<"__builtin_ia32_pmovsxbw128">,
775               Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty],
776                         [IntrNoMem]>;
777   def int_x86_sse41_pmovsxdq        : GCCBuiltin<"__builtin_ia32_pmovsxdq128">,
778               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty],
779                         [IntrNoMem]>;
780   def int_x86_sse41_pmovsxwd        : GCCBuiltin<"__builtin_ia32_pmovsxwd128">,
781               Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty],
782                         [IntrNoMem]>;
783   def int_x86_sse41_pmovsxwq        : GCCBuiltin<"__builtin_ia32_pmovsxwq128">,
784               Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty],
785                         [IntrNoMem]>;
786   def int_x86_sse41_pmovzxbd        : GCCBuiltin<"__builtin_ia32_pmovzxbd128">,
787               Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty],
788                         [IntrNoMem]>;
789   def int_x86_sse41_pmovzxbq        : GCCBuiltin<"__builtin_ia32_pmovzxbq128">,
790               Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty],
791                         [IntrNoMem]>;
792   def int_x86_sse41_pmovzxbw        : GCCBuiltin<"__builtin_ia32_pmovzxbw128">,
793               Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty],
794                         [IntrNoMem]>;
795   def int_x86_sse41_pmovzxdq        : GCCBuiltin<"__builtin_ia32_pmovzxdq128">,
796               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty],
797                         [IntrNoMem]>;
798   def int_x86_sse41_pmovzxwd        : GCCBuiltin<"__builtin_ia32_pmovzxwd128">,
799               Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty],
800                         [IntrNoMem]>;
801   def int_x86_sse41_pmovzxwq        : GCCBuiltin<"__builtin_ia32_pmovzxwq128">,
802               Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty],
803                         [IntrNoMem]>;
804 }
805
806 // Vector min element
807 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
808   def int_x86_sse41_phminposuw     : GCCBuiltin<"__builtin_ia32_phminposuw128">,
809               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty],
810                         [IntrNoMem]>;
811 }
812
813 // Vector compare, min, max
814 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
815   def int_x86_sse41_pmaxsb          : GCCBuiltin<"__builtin_ia32_pmaxsb128">,
816               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
817                         [IntrNoMem, Commutative]>;
818   def int_x86_sse41_pmaxsd          : GCCBuiltin<"__builtin_ia32_pmaxsd128">,
819               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
820                         [IntrNoMem, Commutative]>;
821   def int_x86_sse41_pmaxud          : GCCBuiltin<"__builtin_ia32_pmaxud128">,
822               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
823                         [IntrNoMem, Commutative]>;
824   def int_x86_sse41_pmaxuw          : GCCBuiltin<"__builtin_ia32_pmaxuw128">,
825               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
826                         [IntrNoMem, Commutative]>;
827   def int_x86_sse41_pminsb          : GCCBuiltin<"__builtin_ia32_pminsb128">,
828               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
829                         [IntrNoMem, Commutative]>;
830   def int_x86_sse41_pminsd          : GCCBuiltin<"__builtin_ia32_pminsd128">,
831               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
832                         [IntrNoMem, Commutative]>;
833   def int_x86_sse41_pminud          : GCCBuiltin<"__builtin_ia32_pminud128">,
834               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
835                         [IntrNoMem, Commutative]>;
836   def int_x86_sse41_pminuw          : GCCBuiltin<"__builtin_ia32_pminuw128">,
837               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
838                         [IntrNoMem, Commutative]>;
839 }
840
841 // Advanced Encryption Standard (AES) Instructions
842 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
843   def int_x86_aesni_aesimc          : GCCBuiltin<"__builtin_ia32_aesimc128">,
844               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty],
845                         [IntrNoMem]>;
846   def int_x86_aesni_aesenc          : GCCBuiltin<"__builtin_ia32_aesenc128">,
847               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
848                         [IntrNoMem]>;
849   def int_x86_aesni_aesenclast : GCCBuiltin<"__builtin_ia32_aesenclast128">,
850               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
851                         [IntrNoMem]>;
852   def int_x86_aesni_aesdec          : GCCBuiltin<"__builtin_ia32_aesdec128">,
853               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
854                         [IntrNoMem]>;
855   def int_x86_aesni_aesdeclast : GCCBuiltin<"__builtin_ia32_aesdeclast128">,
856               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
857                         [IntrNoMem]>;
858   def int_x86_aesni_aeskeygenassist :
859               GCCBuiltin<"__builtin_ia32_aeskeygenassist128">,
860               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty],
861                         [IntrNoMem]>;
862 }
863
864 // PCLMUL instruction
865 let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
866   def int_x86_pclmulqdq : GCCBuiltin<"__builtin_ia32_pclmulqdq128">,
867           Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
868                     [IntrNoMem]>;
869 }
870
871 // Vector pack
872 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
873   def int_x86_sse41_packusdw        : GCCBuiltin<"__builtin_ia32_packusdw128">,
874               Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
875                         [IntrNoMem]>;
876 }
877
878 // Vector multiply
879 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
880   def int_x86_sse41_pmuldq          : GCCBuiltin<"__builtin_ia32_pmuldq128">,
881               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
882                         [IntrNoMem, Commutative]>;
883 }
884
885 // Vector extract
886 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
887   def int_x86_sse41_pextrb         :
888               Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
889                         [IntrNoMem]>;
890   def int_x86_sse41_pextrd         :
891               Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty],
892                         [IntrNoMem]>;
893   def int_x86_sse41_pextrq         :
894               Intrinsic<[llvm_i64_ty], [llvm_v2i64_ty, llvm_i32_ty],
895                         [IntrNoMem]>;
896   def int_x86_sse41_extractps      : GCCBuiltin<"__builtin_ia32_extractps128">,
897               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, llvm_i32_ty],
898                         [IntrNoMem]>;
899 }
900
901 // Vector insert
902 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
903   def int_x86_sse41_insertps       : GCCBuiltin<"__builtin_ia32_insertps128">,
904           Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
905                     [IntrNoMem]>;
906 }
907
908 // Vector blend
909 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
910   def int_x86_sse41_pblendvb         : GCCBuiltin<"__builtin_ia32_pblendvb128">,
911         Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,llvm_v16i8_ty],
912                   [IntrNoMem]>;
913   def int_x86_sse41_blendvpd         : GCCBuiltin<"__builtin_ia32_blendvpd">,
914         Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,llvm_v2f64_ty],
915                   [IntrNoMem]>;
916   def int_x86_sse41_blendvps         : GCCBuiltin<"__builtin_ia32_blendvps">,
917         Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,llvm_v4f32_ty],
918                   [IntrNoMem]>;
919 }
920
921 // Vector dot product
922 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
923   def int_x86_sse41_dppd            : GCCBuiltin<"__builtin_ia32_dppd">,
924           Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
925                     [IntrNoMem, Commutative]>;
926   def int_x86_sse41_dpps            : GCCBuiltin<"__builtin_ia32_dpps">,
927           Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
928                     [IntrNoMem, Commutative]>;
929 }
930
931 // Vector sum of absolute differences
932 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
933   def int_x86_sse41_mpsadbw         : GCCBuiltin<"__builtin_ia32_mpsadbw128">,
934           Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty,llvm_i8_ty],
935                     [IntrNoMem, Commutative]>;
936 }
937
938 // Cacheability support ops
939 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
940   def int_x86_sse41_movntdqa        : GCCBuiltin<"__builtin_ia32_movntdqa">,
941           Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
942 }
943
944 // Test instruction with bitwise comparison.
945 let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
946   def int_x86_sse41_ptestz          : GCCBuiltin<"__builtin_ia32_ptestz128">,
947           Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
948                     [IntrNoMem]>;
949   def int_x86_sse41_ptestc          : GCCBuiltin<"__builtin_ia32_ptestc128">,
950           Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
951                     [IntrNoMem]>;
952   def int_x86_sse41_ptestnzc        : GCCBuiltin<"__builtin_ia32_ptestnzc128">,
953           Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
954                     [IntrNoMem]>;
955 }
956
957 //===----------------------------------------------------------------------===//
958 // SSE4.2
959
960 // Miscellaneous
961 // CRC Instruction
962 let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
963   def int_x86_sse42_crc32_32_8       : GCCBuiltin<"__builtin_ia32_crc32qi">,
964           Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i8_ty],
965                     [IntrNoMem]>;
966   def int_x86_sse42_crc32_32_16      : GCCBuiltin<"__builtin_ia32_crc32hi">,
967           Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i16_ty],
968                     [IntrNoMem]>;
969   def int_x86_sse42_crc32_32_32      : GCCBuiltin<"__builtin_ia32_crc32si">,
970           Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
971                     [IntrNoMem]>;
972   def int_x86_sse42_crc32_64_64      : GCCBuiltin<"__builtin_ia32_crc32di">,
973           Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty],
974                     [IntrNoMem]>;
975 }
976
977 // String/text processing ops.
978 let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
979   def int_x86_sse42_pcmpistrm128  : GCCBuiltin<"__builtin_ia32_pcmpistrm128">,
980     Intrinsic<[llvm_v16i8_ty],
981         [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
982         [IntrNoMem]>;
983   def int_x86_sse42_pcmpistri128  : GCCBuiltin<"__builtin_ia32_pcmpistri128">,
984     Intrinsic<[llvm_i32_ty],
985         [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
986         [IntrNoMem]>;
987   def int_x86_sse42_pcmpistria128 : GCCBuiltin<"__builtin_ia32_pcmpistria128">,
988     Intrinsic<[llvm_i32_ty],
989         [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
990         [IntrNoMem]>;
991   def int_x86_sse42_pcmpistric128 : GCCBuiltin<"__builtin_ia32_pcmpistric128">,
992     Intrinsic<[llvm_i32_ty],
993         [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
994         [IntrNoMem]>;
995   def int_x86_sse42_pcmpistrio128 : GCCBuiltin<"__builtin_ia32_pcmpistrio128">,
996     Intrinsic<[llvm_i32_ty],
997         [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
998         [IntrNoMem]>;
999   def int_x86_sse42_pcmpistris128 : GCCBuiltin<"__builtin_ia32_pcmpistris128">,
1000     Intrinsic<[llvm_i32_ty],
1001         [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
1002         [IntrNoMem]>;
1003   def int_x86_sse42_pcmpistriz128 : GCCBuiltin<"__builtin_ia32_pcmpistriz128">,
1004     Intrinsic<[llvm_i32_ty],
1005         [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
1006         [IntrNoMem]>;
1007   def int_x86_sse42_pcmpestrm128  : GCCBuiltin<"__builtin_ia32_pcmpestrm128">,
1008     Intrinsic<[llvm_v16i8_ty],
1009         [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1010          llvm_i8_ty],
1011         [IntrNoMem]>;
1012   def int_x86_sse42_pcmpestri128  : GCCBuiltin<"__builtin_ia32_pcmpestri128">,
1013     Intrinsic<[llvm_i32_ty],
1014         [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1015          llvm_i8_ty],
1016         [IntrNoMem]>;
1017   def int_x86_sse42_pcmpestria128 : GCCBuiltin<"__builtin_ia32_pcmpestria128">,
1018     Intrinsic<[llvm_i32_ty],
1019         [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1020          llvm_i8_ty],
1021         [IntrNoMem]>;
1022   def int_x86_sse42_pcmpestric128 : GCCBuiltin<"__builtin_ia32_pcmpestric128">,
1023     Intrinsic<[llvm_i32_ty],
1024         [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1025          llvm_i8_ty],
1026         [IntrNoMem]>;
1027   def int_x86_sse42_pcmpestrio128 : GCCBuiltin<"__builtin_ia32_pcmpestrio128">,
1028     Intrinsic<[llvm_i32_ty],
1029         [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1030          llvm_i8_ty],
1031         [IntrNoMem]>;
1032   def int_x86_sse42_pcmpestris128 : GCCBuiltin<"__builtin_ia32_pcmpestris128">,
1033     Intrinsic<[llvm_i32_ty],
1034         [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1035          llvm_i8_ty],
1036         [IntrNoMem]>;
1037   def int_x86_sse42_pcmpestriz128 : GCCBuiltin<"__builtin_ia32_pcmpestriz128">,
1038     Intrinsic<[llvm_i32_ty],
1039         [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1040          llvm_i8_ty],
1041         [IntrNoMem]>;
1042 }
1043
1044 //===----------------------------------------------------------------------===//
1045 // SSE4A
1046
1047 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1048   def int_x86_sse4a_extrqi : GCCBuiltin<"__builtin_ia32_extrqi">,
1049     Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty, llvm_i8_ty],
1050               [IntrNoMem]>;
1051   def int_x86_sse4a_extrq  : GCCBuiltin<"__builtin_ia32_extrq">,
1052     Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v16i8_ty], [IntrNoMem]>;
1053
1054   def int_x86_sse4a_insertqi : GCCBuiltin<"__builtin_ia32_insertqi">,
1055     Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
1056                                 llvm_i8_ty, llvm_i8_ty], [IntrNoMem]>;
1057   def int_x86_sse4a_insertq  : GCCBuiltin<"__builtin_ia32_insertq">,
1058     Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>;
1059
1060   def int_x86_sse4a_movnt_ss : GCCBuiltin<"__builtin_ia32_movntss">,
1061     Intrinsic<[], [llvm_ptr_ty, llvm_v4f32_ty], []>;
1062   def int_x86_sse4a_movnt_sd : GCCBuiltin<"__builtin_ia32_movntsd">,
1063     Intrinsic<[], [llvm_ptr_ty, llvm_v2f64_ty], []>;
1064 }
1065
1066 //===----------------------------------------------------------------------===//
1067 // AVX
1068
1069 // Arithmetic ops
1070 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1071   def int_x86_avx_addsub_pd_256 : GCCBuiltin<"__builtin_ia32_addsubpd256">,
1072         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1073                   llvm_v4f64_ty], [IntrNoMem]>;
1074   def int_x86_avx_addsub_ps_256 : GCCBuiltin<"__builtin_ia32_addsubps256">,
1075         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1076                   llvm_v8f32_ty], [IntrNoMem]>;
1077   def int_x86_avx_max_pd_256 : GCCBuiltin<"__builtin_ia32_maxpd256">,
1078         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1079                   llvm_v4f64_ty], [IntrNoMem]>;
1080   def int_x86_avx_max_ps_256 : GCCBuiltin<"__builtin_ia32_maxps256">,
1081         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1082                   llvm_v8f32_ty], [IntrNoMem]>;
1083   def int_x86_avx_min_pd_256 : GCCBuiltin<"__builtin_ia32_minpd256">,
1084         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1085                   llvm_v4f64_ty], [IntrNoMem]>;
1086   def int_x86_avx_min_ps_256 : GCCBuiltin<"__builtin_ia32_minps256">,
1087         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1088                   llvm_v8f32_ty], [IntrNoMem]>;
1089
1090   def int_x86_avx_sqrt_pd_256 : GCCBuiltin<"__builtin_ia32_sqrtpd256">,
1091         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1092   def int_x86_avx_sqrt_ps_256 : GCCBuiltin<"__builtin_ia32_sqrtps256">,
1093         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1094
1095   def int_x86_avx_rsqrt_ps_256 : GCCBuiltin<"__builtin_ia32_rsqrtps256">,
1096         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1097
1098   def int_x86_avx_rcp_ps_256 : GCCBuiltin<"__builtin_ia32_rcpps256">,
1099         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1100
1101   def int_x86_avx_round_pd_256 : GCCBuiltin<"__builtin_ia32_roundpd256">,
1102         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1103                   llvm_i32_ty], [IntrNoMem]>;
1104   def int_x86_avx_round_ps_256 : GCCBuiltin<"__builtin_ia32_roundps256">,
1105         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1106                   llvm_i32_ty], [IntrNoMem]>;
1107 }
1108
1109 // Horizontal ops
1110 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1111   def int_x86_avx_hadd_pd_256 : GCCBuiltin<"__builtin_ia32_haddpd256">,
1112         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1113                   llvm_v4f64_ty], [IntrNoMem]>;
1114   def int_x86_avx_hsub_ps_256 : GCCBuiltin<"__builtin_ia32_hsubps256">,
1115         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1116                   llvm_v8f32_ty], [IntrNoMem]>;
1117   def int_x86_avx_hsub_pd_256 : GCCBuiltin<"__builtin_ia32_hsubpd256">,
1118         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1119                   llvm_v4f64_ty], [IntrNoMem]>;
1120   def int_x86_avx_hadd_ps_256 : GCCBuiltin<"__builtin_ia32_haddps256">,
1121         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1122                   llvm_v8f32_ty], [IntrNoMem]>;
1123 }
1124
1125 // Vector permutation
1126 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1127   def int_x86_avx_vpermilvar_pd : GCCBuiltin<"__builtin_ia32_vpermilvarpd">,
1128         Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
1129                   llvm_v2i64_ty], [IntrNoMem]>;
1130   def int_x86_avx_vpermilvar_ps : GCCBuiltin<"__builtin_ia32_vpermilvarps">,
1131         Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
1132                   llvm_v4i32_ty], [IntrNoMem]>;
1133
1134   def int_x86_avx_vpermilvar_pd_256 :
1135         GCCBuiltin<"__builtin_ia32_vpermilvarpd256">,
1136         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4i64_ty], [IntrNoMem]>;
1137   def int_x86_avx_vpermilvar_ps_256 :
1138         GCCBuiltin<"__builtin_ia32_vpermilvarps256">,
1139         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8i32_ty], [IntrNoMem]>;
1140
1141   def int_x86_avx_vperm2f128_pd_256 :
1142         GCCBuiltin<"__builtin_ia32_vperm2f128_pd256">,
1143         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1144                   llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1145   def int_x86_avx_vperm2f128_ps_256 :
1146         GCCBuiltin<"__builtin_ia32_vperm2f128_ps256">,
1147         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1148                   llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1149   def int_x86_avx_vperm2f128_si_256 :
1150         GCCBuiltin<"__builtin_ia32_vperm2f128_si256">,
1151         Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1152                   llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
1153
1154   def int_x86_avx512_mask_vpermi2var_d_128 : 
1155        GCCBuiltin<"__builtin_ia32_vpermi2vard128_mask">,
1156         Intrinsic<[llvm_v4i32_ty],
1157         [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
1158         [IntrNoMem]>;
1159
1160   def int_x86_avx512_mask_vpermi2var_d_256 : 
1161         GCCBuiltin<"__builtin_ia32_vpermi2vard256_mask">,
1162           Intrinsic<[llvm_v8i32_ty],
1163           [llvm_v8i32_ty, llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
1164           [IntrNoMem]>;
1165
1166   def int_x86_avx512_mask_vpermi2var_d_512 : 
1167         GCCBuiltin<"__builtin_ia32_vpermi2vard512_mask">,
1168           Intrinsic<[llvm_v16i32_ty],
1169           [llvm_v16i32_ty, llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
1170           [IntrNoMem]>;
1171
1172   def int_x86_avx512_mask_vpermi2var_hi_128 : 
1173         GCCBuiltin<"__builtin_ia32_vpermi2varhi128_mask">,
1174           Intrinsic<[llvm_v8i16_ty],
1175           [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty],
1176           [IntrNoMem]>;
1177
1178   def int_x86_avx512_mask_vpermi2var_hi_256 : 
1179         GCCBuiltin<"__builtin_ia32_vpermi2varhi256_mask">,
1180           Intrinsic<[llvm_v16i16_ty],
1181           [llvm_v16i16_ty, llvm_v16i16_ty, llvm_v16i16_ty, llvm_i16_ty],
1182           [IntrNoMem]>;
1183
1184   def int_x86_avx512_mask_vpermi2var_hi_512 : 
1185         GCCBuiltin<"__builtin_ia32_vpermi2varhi512_mask">,
1186           Intrinsic<[llvm_v32i16_ty],
1187           [llvm_v32i16_ty, llvm_v32i16_ty, llvm_v32i16_ty, llvm_i32_ty],
1188           [IntrNoMem]>;
1189
1190   def int_x86_avx512_mask_vpermi2var_pd_128 : 
1191         GCCBuiltin<"__builtin_ia32_vpermi2varpd128_mask">,
1192           Intrinsic<[llvm_v2f64_ty],
1193           [llvm_v2f64_ty, llvm_v2i64_ty, llvm_v2f64_ty, llvm_i8_ty],
1194           [IntrNoMem]>;
1195
1196   def int_x86_avx512_mask_vpermi2var_pd_256 : 
1197         GCCBuiltin<"__builtin_ia32_vpermi2varpd256_mask">,
1198           Intrinsic<[llvm_v4f64_ty],
1199           [llvm_v4f64_ty, llvm_v4i64_ty, llvm_v4f64_ty, llvm_i8_ty],
1200           [IntrNoMem]>;
1201
1202   def int_x86_avx512_mask_vpermi2var_pd_512 : 
1203         GCCBuiltin<"__builtin_ia32_vpermi2varpd512_mask">,
1204           Intrinsic<[llvm_v8f64_ty],
1205           [llvm_v8f64_ty, llvm_v8i64_ty, llvm_v8f64_ty, llvm_i8_ty],
1206           [IntrNoMem]>;
1207
1208   def int_x86_avx512_mask_vpermi2var_ps_128 : 
1209         GCCBuiltin<"__builtin_ia32_vpermi2varps128_mask">,
1210           Intrinsic<[llvm_v4f32_ty],
1211           [llvm_v4f32_ty, llvm_v4i32_ty, llvm_v4f32_ty, llvm_i8_ty],
1212           [IntrNoMem]>;
1213
1214   def int_x86_avx512_mask_vpermi2var_ps_256 : 
1215         GCCBuiltin<"__builtin_ia32_vpermi2varps256_mask">,
1216           Intrinsic<[llvm_v8f32_ty],
1217           [llvm_v8f32_ty, llvm_v8i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1218           [IntrNoMem]>;
1219
1220   def int_x86_avx512_mask_vpermi2var_ps_512 : 
1221         GCCBuiltin<"__builtin_ia32_vpermi2varps512_mask">,
1222           Intrinsic<[llvm_v16f32_ty],
1223           [llvm_v16f32_ty, llvm_v16i32_ty, llvm_v16f32_ty, llvm_i16_ty],
1224           [IntrNoMem]>;
1225
1226   def int_x86_avx512_mask_vpermi2var_q_128 : 
1227         GCCBuiltin<"__builtin_ia32_vpermi2varq128_mask">,
1228           Intrinsic<[llvm_v2i64_ty],
1229           [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
1230           [IntrNoMem]>;
1231
1232   def int_x86_avx512_mask_vpermi2var_q_256 : 
1233         GCCBuiltin<"__builtin_ia32_vpermi2varq256_mask">,
1234           Intrinsic<[llvm_v4i64_ty],
1235           [llvm_v4i64_ty, llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
1236           [IntrNoMem]>;
1237
1238   def int_x86_avx512_mask_vpermi2var_q_512 : 
1239         GCCBuiltin<"__builtin_ia32_vpermi2varq512_mask">,
1240           Intrinsic<[llvm_v8i64_ty],
1241           [llvm_v8i64_ty, llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
1242           [IntrNoMem]>;
1243
1244   def int_x86_avx512_mask_vpermt2var_d_512:
1245         GCCBuiltin<"__builtin_ia32_vpermt2vard512_mask">,
1246         Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
1247                   llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
1248
1249   def int_x86_avx512_mask_vpermt2var_q_512:
1250         GCCBuiltin<"__builtin_ia32_vpermt2varq512_mask">,
1251         Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
1252                   llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
1253
1254   def int_x86_avx512_mask_vpermt2var_ps_512:
1255         GCCBuiltin<"__builtin_ia32_vpermt2varps512_mask">,
1256         Intrinsic<[llvm_v16f32_ty], [llvm_v16i32_ty,
1257                   llvm_v16f32_ty, llvm_v16f32_ty, llvm_i16_ty], [IntrNoMem]>;
1258
1259   def int_x86_avx512_mask_vpermt2var_pd_512:
1260         GCCBuiltin<"__builtin_ia32_vpermt2varpd512_mask">,
1261         Intrinsic<[llvm_v8f64_ty], [llvm_v8i64_ty,
1262                   llvm_v8f64_ty, llvm_v8f64_ty, llvm_i8_ty], [IntrNoMem]>;
1263
1264   def int_x86_avx512_mask_vpermt2var_d_128 : 
1265         GCCBuiltin<"__builtin_ia32_vpermt2vard128_mask">,
1266           Intrinsic<[llvm_v4i32_ty],
1267           [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
1268           [IntrNoMem]>;
1269
1270   def int_x86_avx512_maskz_vpermt2var_d_128 : 
1271         GCCBuiltin<"__builtin_ia32_vpermt2vard128_maskz">,
1272           Intrinsic<[llvm_v4i32_ty],
1273           [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
1274           [IntrNoMem]>;
1275
1276   def int_x86_avx512_mask_vpermt2var_d_256 : 
1277         GCCBuiltin<"__builtin_ia32_vpermt2vard256_mask">,
1278           Intrinsic<[llvm_v8i32_ty],
1279           [llvm_v8i32_ty, llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
1280           [IntrNoMem]>;
1281
1282   def int_x86_avx512_maskz_vpermt2var_d_256 : 
1283         GCCBuiltin<"__builtin_ia32_vpermt2vard256_maskz">,
1284           Intrinsic<[llvm_v8i32_ty],
1285           [llvm_v8i32_ty, llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
1286           [IntrNoMem]>;
1287
1288   def int_x86_avx512_maskz_vpermt2var_d_512 : 
1289         GCCBuiltin<"__builtin_ia32_vpermt2vard512_maskz">,
1290           Intrinsic<[llvm_v16i32_ty],
1291           [llvm_v16i32_ty, llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
1292           [IntrNoMem]>;
1293
1294   def int_x86_avx512_mask_vpermt2var_hi_128 : 
1295         GCCBuiltin<"__builtin_ia32_vpermt2varhi128_mask">,
1296           Intrinsic<[llvm_v8i16_ty],
1297           [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty],
1298           [IntrNoMem]>;
1299
1300   def int_x86_avx512_maskz_vpermt2var_hi_128 : 
1301         GCCBuiltin<"__builtin_ia32_vpermt2varhi128_maskz">,
1302           Intrinsic<[llvm_v8i16_ty],
1303           [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty],
1304           [IntrNoMem]>;
1305
1306   def int_x86_avx512_mask_vpermt2var_hi_256 : 
1307         GCCBuiltin<"__builtin_ia32_vpermt2varhi256_mask">,
1308           Intrinsic<[llvm_v16i16_ty],
1309           [llvm_v16i16_ty, llvm_v16i16_ty, llvm_v16i16_ty, llvm_i16_ty],
1310           [IntrNoMem]>;
1311
1312   def int_x86_avx512_maskz_vpermt2var_hi_256 : 
1313         GCCBuiltin<"__builtin_ia32_vpermt2varhi256_maskz">,
1314           Intrinsic<[llvm_v16i16_ty],
1315           [llvm_v16i16_ty, llvm_v16i16_ty, llvm_v16i16_ty, llvm_i16_ty],
1316           [IntrNoMem]>;
1317
1318   def int_x86_avx512_mask_vpermt2var_hi_512 : 
1319         GCCBuiltin<"__builtin_ia32_vpermt2varhi512_mask">,
1320           Intrinsic<[llvm_v32i16_ty],
1321           [llvm_v32i16_ty, llvm_v32i16_ty, llvm_v32i16_ty, llvm_i32_ty],
1322           [IntrNoMem]>;
1323
1324   def int_x86_avx512_maskz_vpermt2var_hi_512 : 
1325         GCCBuiltin<"__builtin_ia32_vpermt2varhi512_maskz">,
1326           Intrinsic<[llvm_v32i16_ty],
1327           [llvm_v32i16_ty, llvm_v32i16_ty, llvm_v32i16_ty, llvm_i32_ty],
1328           [IntrNoMem]>;
1329
1330   def int_x86_avx512_mask_vpermt2var_pd_128 : 
1331         GCCBuiltin<"__builtin_ia32_vpermt2varpd128_mask">,
1332           Intrinsic<[llvm_v2f64_ty],
1333           [llvm_v2i64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
1334           [IntrNoMem]>;
1335
1336   def int_x86_avx512_maskz_vpermt2var_pd_128 : 
1337         GCCBuiltin<"__builtin_ia32_vpermt2varpd128_maskz">,
1338           Intrinsic<[llvm_v2f64_ty],
1339           [llvm_v2i64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
1340           [IntrNoMem]>;
1341
1342   def int_x86_avx512_mask_vpermt2var_pd_256 : 
1343         GCCBuiltin<"__builtin_ia32_vpermt2varpd256_mask">,
1344           Intrinsic<[llvm_v4f64_ty],
1345           [llvm_v4i64_ty, llvm_v4f64_ty, llvm_v4f64_ty, llvm_i8_ty],
1346           [IntrNoMem]>;
1347
1348   def int_x86_avx512_maskz_vpermt2var_pd_256 : 
1349         GCCBuiltin<"__builtin_ia32_vpermt2varpd256_maskz">,
1350           Intrinsic<[llvm_v4f64_ty],
1351           [llvm_v4i64_ty, llvm_v4f64_ty, llvm_v4f64_ty, llvm_i8_ty],
1352           [IntrNoMem]>;
1353
1354   def int_x86_avx512_maskz_vpermt2var_pd_512 : 
1355         GCCBuiltin<"__builtin_ia32_vpermt2varpd512_maskz">,
1356           Intrinsic<[llvm_v8f64_ty],
1357           [llvm_v8i64_ty, llvm_v8f64_ty, llvm_v8f64_ty, llvm_i8_ty],
1358           [IntrNoMem]>;
1359
1360   def int_x86_avx512_mask_vpermt2var_ps_128 : 
1361         GCCBuiltin<"__builtin_ia32_vpermt2varps128_mask">,
1362           Intrinsic<[llvm_v4f32_ty],
1363           [llvm_v4i32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
1364           [IntrNoMem]>;
1365
1366   def int_x86_avx512_maskz_vpermt2var_ps_128 : 
1367         GCCBuiltin<"__builtin_ia32_vpermt2varps128_maskz">,
1368           Intrinsic<[llvm_v4f32_ty],
1369           [llvm_v4i32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
1370           [IntrNoMem]>;
1371
1372   def int_x86_avx512_mask_vpermt2var_ps_256 : 
1373         GCCBuiltin<"__builtin_ia32_vpermt2varps256_mask">,
1374           Intrinsic<[llvm_v8f32_ty],
1375           [llvm_v8i32_ty, llvm_v8f32_ty, llvm_v8f32_ty, llvm_i8_ty],
1376           [IntrNoMem]>;
1377
1378   def int_x86_avx512_maskz_vpermt2var_ps_256 : 
1379         GCCBuiltin<"__builtin_ia32_vpermt2varps256_maskz">,
1380           Intrinsic<[llvm_v8f32_ty],
1381           [llvm_v8i32_ty, llvm_v8f32_ty, llvm_v8f32_ty, llvm_i8_ty],
1382           [IntrNoMem]>;
1383
1384   def int_x86_avx512_maskz_vpermt2var_ps_512 : 
1385         GCCBuiltin<"__builtin_ia32_vpermt2varps512_maskz">,
1386           Intrinsic<[llvm_v16f32_ty],
1387           [llvm_v16i32_ty, llvm_v16f32_ty, llvm_v16f32_ty, llvm_i16_ty],
1388           [IntrNoMem]>;
1389
1390   def int_x86_avx512_mask_vpermt2var_q_128 : 
1391         GCCBuiltin<"__builtin_ia32_vpermt2varq128_mask">,
1392           Intrinsic<[llvm_v2i64_ty],
1393           [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
1394           [IntrNoMem]>;
1395
1396   def int_x86_avx512_maskz_vpermt2var_q_128 : 
1397         GCCBuiltin<"__builtin_ia32_vpermt2varq128_maskz">,
1398           Intrinsic<[llvm_v2i64_ty],
1399           [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
1400           [IntrNoMem]>;
1401
1402   def int_x86_avx512_mask_vpermt2var_q_256 : 
1403         GCCBuiltin<"__builtin_ia32_vpermt2varq256_mask">,
1404           Intrinsic<[llvm_v4i64_ty],
1405           [llvm_v4i64_ty, llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
1406           [IntrNoMem]>;
1407
1408   def int_x86_avx512_maskz_vpermt2var_q_256 : 
1409         GCCBuiltin<"__builtin_ia32_vpermt2varq256_maskz">,
1410           Intrinsic<[llvm_v4i64_ty],
1411           [llvm_v4i64_ty, llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
1412           [IntrNoMem]>;
1413
1414   def int_x86_avx512_maskz_vpermt2var_q_512 : 
1415         GCCBuiltin<"__builtin_ia32_vpermt2varq512_maskz">,
1416           Intrinsic<[llvm_v8i64_ty],
1417           [llvm_v8i64_ty, llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
1418           [IntrNoMem]>;
1419
1420   def int_x86_avx512_mask_vpermil_pd_128 :
1421         GCCBuiltin<"__builtin_ia32_vpermilpd_mask">,
1422           Intrinsic<[llvm_v2f64_ty],
1423           [llvm_v2f64_ty, llvm_i32_ty, llvm_v2f64_ty, llvm_i8_ty],
1424           [IntrNoMem]>;
1425
1426   def int_x86_avx512_mask_vpermil_pd_256 :
1427         GCCBuiltin<"__builtin_ia32_vpermilpd256_mask">,
1428           Intrinsic<[llvm_v4f64_ty],
1429           [llvm_v4f64_ty, llvm_i32_ty, llvm_v4f64_ty, llvm_i8_ty],
1430           [IntrNoMem]>;
1431
1432   def int_x86_avx512_mask_vpermil_pd_512 :
1433         GCCBuiltin<"__builtin_ia32_vpermilpd512_mask">,
1434           Intrinsic<[llvm_v8f64_ty],
1435           [llvm_v8f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
1436           [IntrNoMem]>;
1437
1438   def int_x86_avx512_mask_vpermil_ps_128 :
1439         GCCBuiltin<"__builtin_ia32_vpermilps_mask">,
1440           Intrinsic<[llvm_v4f32_ty],
1441           [llvm_v4f32_ty, llvm_i32_ty, llvm_v4f32_ty, llvm_i8_ty],
1442           [IntrNoMem]>;
1443
1444   def int_x86_avx512_mask_vpermil_ps_256 :
1445         GCCBuiltin<"__builtin_ia32_vpermilps256_mask">,
1446           Intrinsic<[llvm_v8f32_ty],
1447           [llvm_v8f32_ty, llvm_i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1448           [IntrNoMem]>;
1449
1450   def int_x86_avx512_mask_vpermil_ps_512 :
1451         GCCBuiltin<"__builtin_ia32_vpermilps512_mask">,
1452           Intrinsic<[llvm_v16f32_ty],
1453           [llvm_v16f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i16_ty],
1454           [IntrNoMem]>;
1455
1456   def int_x86_avx512_mask_vpermilvar_pd_256 :
1457         GCCBuiltin<"__builtin_ia32_vpermilvarpd256_mask">,
1458           Intrinsic<[llvm_v4f64_ty],
1459           [llvm_v4f64_ty, llvm_v4i64_ty, llvm_v4f64_ty, llvm_i8_ty],
1460           [IntrNoMem]>;
1461
1462   def int_x86_avx512_mask_vpermilvar_pd_512 :
1463         GCCBuiltin<"__builtin_ia32_vpermilvarpd512_mask">,
1464           Intrinsic<[llvm_v8f64_ty],
1465           [llvm_v8f64_ty, llvm_v8i64_ty, llvm_v8f64_ty, llvm_i8_ty],
1466           [IntrNoMem]>;
1467
1468   def int_x86_avx512_mask_vpermilvar_pd_128 :
1469         GCCBuiltin<"__builtin_ia32_vpermilvarpd_mask">,
1470           Intrinsic<[llvm_v2f64_ty],
1471           [llvm_v2f64_ty, llvm_v2i64_ty, llvm_v2f64_ty, llvm_i8_ty],
1472           [IntrNoMem]>;
1473
1474   def int_x86_avx512_mask_vpermilvar_ps_256 :
1475         GCCBuiltin<"__builtin_ia32_vpermilvarps256_mask">,
1476           Intrinsic<[llvm_v8f32_ty],
1477           [llvm_v8f32_ty, llvm_v8i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1478           [IntrNoMem]>;
1479
1480   def int_x86_avx512_mask_vpermilvar_ps_512 :
1481         GCCBuiltin<"__builtin_ia32_vpermilvarps512_mask">,
1482           Intrinsic<[llvm_v16f32_ty],
1483           [llvm_v16f32_ty, llvm_v16i32_ty, llvm_v16f32_ty, llvm_i16_ty],
1484           [IntrNoMem]>;
1485
1486   def int_x86_avx512_mask_vpermilvar_ps_128 :
1487         GCCBuiltin<"__builtin_ia32_vpermilvarps_mask">,
1488           Intrinsic<[llvm_v4f32_ty],
1489           [llvm_v4f32_ty, llvm_v4i32_ty, llvm_v4f32_ty, llvm_i8_ty],
1490           [IntrNoMem]>;
1491
1492   def int_x86_avx512_mask_pshuf_b_128 : 
1493         GCCBuiltin<"__builtin_ia32_pshufb128_mask">,
1494           Intrinsic<[llvm_v16i8_ty],
1495           [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty,  llvm_i16_ty],
1496           [IntrNoMem]>;
1497
1498   def int_x86_avx512_mask_pshuf_b_256 : 
1499         GCCBuiltin<"__builtin_ia32_pshufb256_mask">,
1500           Intrinsic<[llvm_v32i8_ty],
1501           [llvm_v32i8_ty, llvm_v32i8_ty, llvm_v32i8_ty,  llvm_i32_ty],
1502           [IntrNoMem]>;
1503
1504   def int_x86_avx512_mask_pshuf_b_512 : 
1505         GCCBuiltin<"__builtin_ia32_pshufb512_mask">,
1506           Intrinsic<[llvm_v64i8_ty],
1507           [llvm_v64i8_ty, llvm_v64i8_ty, llvm_v64i8_ty,  llvm_i64_ty],
1508           [IntrNoMem]>;
1509
1510   def int_x86_avx512_mask_shuf_f32x4_256 :
1511          GCCBuiltin<"__builtin_ia32_shuf_f32x4_256_mask">,
1512           Intrinsic<[llvm_v8f32_ty],
1513           [llvm_v8f32_ty, llvm_v8f32_ty, llvm_i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1514           [IntrNoMem]>;
1515
1516   def int_x86_avx512_mask_shuf_f32x4 :
1517          GCCBuiltin<"__builtin_ia32_shuf_f32x4_mask">,
1518           Intrinsic<[llvm_v16f32_ty],
1519           [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i16_ty],
1520           [IntrNoMem]>;
1521
1522   def int_x86_avx512_mask_shuf_f64x2_256 :
1523          GCCBuiltin<"__builtin_ia32_shuf_f64x2_256_mask">,
1524           Intrinsic<[llvm_v4f64_ty],
1525           [llvm_v4f64_ty, llvm_v4f64_ty, llvm_i32_ty, llvm_v4f64_ty, llvm_i8_ty],
1526           [IntrNoMem]>;
1527
1528   def int_x86_avx512_mask_shuf_f64x2 :
1529          GCCBuiltin<"__builtin_ia32_shuf_f64x2_mask">,
1530           Intrinsic<[llvm_v8f64_ty],
1531           [llvm_v8f64_ty, llvm_v8f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
1532           [IntrNoMem]>;
1533
1534   def int_x86_avx512_mask_shuf_i32x4_256 :
1535          GCCBuiltin<"__builtin_ia32_shuf_i32x4_256_mask">,
1536           Intrinsic<[llvm_v8i32_ty],
1537           [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i32_ty, llvm_v8i32_ty, llvm_i8_ty],
1538           [IntrNoMem]>;
1539
1540   def int_x86_avx512_mask_shuf_i32x4 :
1541          GCCBuiltin<"__builtin_ia32_shuf_i32x4_mask">,
1542           Intrinsic<[llvm_v16i32_ty],
1543           [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty],
1544           [IntrNoMem]>;
1545
1546   def int_x86_avx512_mask_shuf_i64x2_256 :
1547          GCCBuiltin<"__builtin_ia32_shuf_i64x2_256_mask">,
1548           Intrinsic<[llvm_v4i64_ty],
1549           [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i32_ty, llvm_v4i64_ty, llvm_i8_ty],
1550           [IntrNoMem]>;
1551
1552   def int_x86_avx512_mask_shuf_i64x2 :
1553          GCCBuiltin<"__builtin_ia32_shuf_i64x2_mask">,
1554           Intrinsic<[llvm_v8i64_ty],
1555           [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty],
1556           [IntrNoMem]>;
1557
1558   def int_x86_avx512_mask_shuf_pd_128 :
1559          GCCBuiltin<"__builtin_ia32_shufpd128_mask">,
1560           Intrinsic<[llvm_v2f64_ty],
1561           [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty, llvm_v2f64_ty, llvm_i8_ty],
1562           [IntrNoMem]>;
1563
1564   def int_x86_avx512_mask_shuf_pd_256 :
1565          GCCBuiltin<"__builtin_ia32_shufpd256_mask">,
1566           Intrinsic<[llvm_v4f64_ty],
1567           [llvm_v4f64_ty, llvm_v4f64_ty, llvm_i32_ty, llvm_v4f64_ty, llvm_i8_ty],
1568           [IntrNoMem]>;
1569
1570   def int_x86_avx512_mask_shuf_pd_512 :
1571          GCCBuiltin<"__builtin_ia32_shufpd512_mask">,
1572           Intrinsic<[llvm_v8f64_ty],
1573           [llvm_v8f64_ty, llvm_v8f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
1574           [IntrNoMem]>;
1575
1576   def int_x86_avx512_mask_shuf_ps_128 :
1577          GCCBuiltin<"__builtin_ia32_shufps128_mask">,
1578           Intrinsic<[llvm_v4f32_ty],
1579           [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty, llvm_v4f32_ty, llvm_i8_ty],
1580           [IntrNoMem]>;
1581
1582   def int_x86_avx512_mask_shuf_ps_256 :
1583          GCCBuiltin<"__builtin_ia32_shufps256_mask">,
1584           Intrinsic<[llvm_v8f32_ty],
1585           [llvm_v8f32_ty, llvm_v8f32_ty, llvm_i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1586           [IntrNoMem]>;
1587
1588   def int_x86_avx512_mask_shuf_ps_512 :
1589          GCCBuiltin<"__builtin_ia32_shufps512_mask">,
1590           Intrinsic<[llvm_v16f32_ty],
1591           [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i16_ty],
1592           [IntrNoMem]>;
1593
1594   def int_x86_avx512_mask_movshdup_128 :
1595          GCCBuiltin<"__builtin_ia32_movshdup128_mask">,
1596           Intrinsic<[llvm_v4f32_ty],
1597           [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
1598           [IntrNoMem]>;
1599
1600   def int_x86_avx512_mask_movshdup_256 :
1601          GCCBuiltin<"__builtin_ia32_movshdup256_mask">,
1602           Intrinsic<[llvm_v8f32_ty],
1603           [llvm_v8f32_ty, llvm_v8f32_ty, llvm_i8_ty],
1604           [IntrNoMem]>;
1605
1606   def int_x86_avx512_mask_movshdup_512 :
1607          GCCBuiltin<"__builtin_ia32_movshdup512_mask">,
1608           Intrinsic<[llvm_v16f32_ty],
1609           [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i16_ty],
1610           [IntrNoMem]>;
1611
1612   def int_x86_avx512_mask_movsldup_128 :
1613          GCCBuiltin<"__builtin_ia32_movsldup128_mask">,
1614           Intrinsic<[llvm_v4f32_ty],
1615           [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
1616           [IntrNoMem]>;
1617
1618   def int_x86_avx512_mask_movsldup_256 :
1619          GCCBuiltin<"__builtin_ia32_movsldup256_mask">,
1620           Intrinsic<[llvm_v8f32_ty],
1621           [llvm_v8f32_ty, llvm_v8f32_ty, llvm_i8_ty],
1622           [IntrNoMem]>;
1623
1624   def int_x86_avx512_mask_movsldup_512 :
1625          GCCBuiltin<"__builtin_ia32_movsldup512_mask">,
1626           Intrinsic<[llvm_v16f32_ty],
1627           [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i16_ty],
1628           [IntrNoMem]>;
1629
1630   def int_x86_avx512_mask_movddup_128 :
1631          GCCBuiltin<"__builtin_ia32_movddup128_mask">,
1632           Intrinsic<[llvm_v2f64_ty],
1633           [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
1634           [IntrNoMem]>;
1635
1636   def int_x86_avx512_mask_movddup_256 :
1637          GCCBuiltin<"__builtin_ia32_movddup256_mask">,
1638           Intrinsic<[llvm_v4f64_ty],
1639           [llvm_v4f64_ty, llvm_v4f64_ty, llvm_i8_ty],
1640           [IntrNoMem]>;
1641
1642   def int_x86_avx512_mask_movddup_512 :
1643          GCCBuiltin<"__builtin_ia32_movddup512_mask">,
1644           Intrinsic<[llvm_v8f64_ty],
1645           [llvm_v8f64_ty, llvm_v8f64_ty, llvm_i8_ty],
1646           [IntrNoMem]>;
1647 }
1648
1649 // Vector blend
1650 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1651   def int_x86_avx_blendv_pd_256 : GCCBuiltin<"__builtin_ia32_blendvpd256">,
1652         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1653                   llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>;
1654   def int_x86_avx_blendv_ps_256 : GCCBuiltin<"__builtin_ia32_blendvps256">,
1655         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1656                   llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>;
1657 }
1658
1659 // Vector dot product
1660 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1661   def int_x86_avx_dp_ps_256 : GCCBuiltin<"__builtin_ia32_dpps256">,
1662         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1663                   llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1664 }
1665
1666 // Vector compare
1667 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1668   def int_x86_avx_cmp_pd_256 : GCCBuiltin<"__builtin_ia32_cmppd256">,
1669         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1670                   llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1671   def int_x86_avx_cmp_ps_256 : GCCBuiltin<"__builtin_ia32_cmpps256">,
1672         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1673                   llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1674 }
1675
1676 // Vector convert
1677 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1678   def int_x86_avx_cvtdq2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtdq2pd256">,
1679         Intrinsic<[llvm_v4f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1680   def int_x86_avx_cvtdq2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtdq2ps256">,
1681         Intrinsic<[llvm_v8f32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
1682   def int_x86_avx_cvt_pd2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtpd2ps256">,
1683         Intrinsic<[llvm_v4f32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1684   def int_x86_avx_cvt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvtps2dq256">,
1685         Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1686   def int_x86_avx_cvt_ps2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtps2pd256">,
1687         Intrinsic<[llvm_v4f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1688   def int_x86_avx_cvtt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvttpd2dq256">,
1689         Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1690   def int_x86_avx_cvt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvtpd2dq256">,
1691         Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1692   def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">,
1693         Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1694 }
1695
1696 // Vector bit test
1697 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1698   def int_x86_avx_vtestz_pd : GCCBuiltin<"__builtin_ia32_vtestzpd">,
1699         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1700                   llvm_v2f64_ty], [IntrNoMem]>;
1701   def int_x86_avx_vtestc_pd : GCCBuiltin<"__builtin_ia32_vtestcpd">,
1702         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1703                   llvm_v2f64_ty], [IntrNoMem]>;
1704   def int_x86_avx_vtestnzc_pd : GCCBuiltin<"__builtin_ia32_vtestnzcpd">,
1705         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1706                   llvm_v2f64_ty], [IntrNoMem]>;
1707   def int_x86_avx_vtestz_ps : GCCBuiltin<"__builtin_ia32_vtestzps">,
1708         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1709                   llvm_v4f32_ty], [IntrNoMem]>;
1710   def int_x86_avx_vtestc_ps : GCCBuiltin<"__builtin_ia32_vtestcps">,
1711         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1712                   llvm_v4f32_ty], [IntrNoMem]>;
1713   def int_x86_avx_vtestnzc_ps : GCCBuiltin<"__builtin_ia32_vtestnzcps">,
1714         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1715                   llvm_v4f32_ty], [IntrNoMem]>;
1716   def int_x86_avx_vtestz_pd_256 : GCCBuiltin<"__builtin_ia32_vtestzpd256">,
1717         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1718                   llvm_v4f64_ty], [IntrNoMem]>;
1719   def int_x86_avx_vtestc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestcpd256">,
1720         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1721                   llvm_v4f64_ty], [IntrNoMem]>;
1722   def int_x86_avx_vtestnzc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestnzcpd256">,
1723         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1724                   llvm_v4f64_ty], [IntrNoMem]>;
1725   def int_x86_avx_vtestz_ps_256 : GCCBuiltin<"__builtin_ia32_vtestzps256">,
1726         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1727                   llvm_v8f32_ty], [IntrNoMem]>;
1728   def int_x86_avx_vtestc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestcps256">,
1729         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1730                   llvm_v8f32_ty], [IntrNoMem]>;
1731   def int_x86_avx_vtestnzc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestnzcps256">,
1732         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1733                   llvm_v8f32_ty], [IntrNoMem]>;
1734   def int_x86_avx_ptestz_256 : GCCBuiltin<"__builtin_ia32_ptestz256">,
1735         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1736                   llvm_v4i64_ty], [IntrNoMem]>;
1737   def int_x86_avx_ptestc_256 : GCCBuiltin<"__builtin_ia32_ptestc256">,
1738         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1739                   llvm_v4i64_ty], [IntrNoMem]>;
1740   def int_x86_avx_ptestnzc_256 : GCCBuiltin<"__builtin_ia32_ptestnzc256">,
1741         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1742                   llvm_v4i64_ty], [IntrNoMem]>;
1743   def int_x86_avx512_mask_ptestm_d_512 : GCCBuiltin<"__builtin_ia32_ptestmd512">,
1744         Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
1745                   llvm_i16_ty], [IntrNoMem]>;
1746   def int_x86_avx512_mask_ptestm_q_512 : GCCBuiltin<"__builtin_ia32_ptestmq512">,
1747         Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
1748                   llvm_i8_ty], [IntrNoMem]>;
1749   def int_x86_avx512_mask_fpclass_pd_128 : 
1750          GCCBuiltin<"__builtin_ia32_fpclasspd128_mask">,
1751           Intrinsic<[llvm_i8_ty], [llvm_v2f64_ty, llvm_i32_ty, llvm_i8_ty],
1752           [IntrNoMem]>;
1753   def int_x86_avx512_mask_fpclass_pd_256 : 
1754          GCCBuiltin<"__builtin_ia32_fpclasspd256_mask">,
1755           Intrinsic<[llvm_i8_ty], [llvm_v4f64_ty, llvm_i32_ty, llvm_i8_ty],
1756           [IntrNoMem]>;
1757   def int_x86_avx512_mask_fpclass_pd_512 : 
1758          GCCBuiltin<"__builtin_ia32_fpclasspd512_mask">,
1759           Intrinsic<[llvm_i8_ty], [llvm_v8f64_ty, llvm_i32_ty, llvm_i8_ty],
1760           [IntrNoMem]>;
1761   def int_x86_avx512_mask_fpclass_ps_128 : 
1762          GCCBuiltin<"__builtin_ia32_fpclassps128_mask">,
1763           Intrinsic<[llvm_i8_ty], [llvm_v4f32_ty, llvm_i32_ty, llvm_i8_ty],
1764           [IntrNoMem]>;
1765   def int_x86_avx512_mask_fpclass_ps_256 : 
1766          GCCBuiltin<"__builtin_ia32_fpclassps256_mask">,
1767           Intrinsic<[llvm_i8_ty], [llvm_v8f32_ty, llvm_i32_ty, llvm_i8_ty],
1768           [IntrNoMem]>;
1769   def int_x86_avx512_mask_fpclass_ps_512 : 
1770          GCCBuiltin<"__builtin_ia32_fpclassps512_mask">,
1771           Intrinsic<[llvm_i16_ty], [llvm_v16f32_ty, llvm_i32_ty, llvm_i16_ty],
1772           [IntrNoMem]>;
1773   def int_x86_avx512_mask_fpclass_sd : 
1774          GCCBuiltin<"__builtin_ia32_fpclasssd">,
1775           Intrinsic<[llvm_i8_ty], [llvm_v2f64_ty, llvm_i32_ty, llvm_i8_ty],
1776           [IntrNoMem]>;
1777   def int_x86_avx512_mask_fpclass_ss : 
1778          GCCBuiltin<"__builtin_ia32_fpclassss">,
1779           Intrinsic<[llvm_i8_ty], [llvm_v4f32_ty, llvm_i32_ty, llvm_i8_ty],
1780           [IntrNoMem]>;
1781 }
1782
1783 // Vector extract sign mask
1784 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1785   def int_x86_avx_movmsk_pd_256 : GCCBuiltin<"__builtin_ia32_movmskpd256">,
1786         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1787   def int_x86_avx_movmsk_ps_256 : GCCBuiltin<"__builtin_ia32_movmskps256">,
1788         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1789 }
1790
1791 // Vector zero
1792 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1793   def int_x86_avx_vzeroall : GCCBuiltin<"__builtin_ia32_vzeroall">,
1794         Intrinsic<[], [], []>;
1795   def int_x86_avx_vzeroupper : GCCBuiltin<"__builtin_ia32_vzeroupper">,
1796         Intrinsic<[], [], []>;
1797 }
1798
1799 // Vector load with broadcast
1800 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1801   def int_x86_avx_vbroadcastf128_pd_256 :
1802         GCCBuiltin<"__builtin_ia32_vbroadcastf128_pd256">,
1803         Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1804   def int_x86_avx_vbroadcastf128_ps_256 :
1805         GCCBuiltin<"__builtin_ia32_vbroadcastf128_ps256">,
1806         Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1807 }
1808
1809 // SIMD load ops
1810 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1811   def int_x86_avx_ldu_dq_256 : GCCBuiltin<"__builtin_ia32_lddqu256">,
1812         Intrinsic<[llvm_v32i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
1813 }
1814
1815 // SIMD store ops
1816 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1817   def int_x86_avx_storeu_pd_256 : GCCBuiltin<"__builtin_ia32_storeupd256">,
1818         Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty], [IntrReadWriteArgMem]>;
1819   def int_x86_avx_storeu_ps_256 : GCCBuiltin<"__builtin_ia32_storeups256">,
1820         Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty], [IntrReadWriteArgMem]>;
1821   def int_x86_avx_storeu_dq_256 : GCCBuiltin<"__builtin_ia32_storedqu256">,
1822         Intrinsic<[], [llvm_ptr_ty, llvm_v32i8_ty], [IntrReadWriteArgMem]>;
1823 }
1824
1825 // Conditional load ops
1826 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1827   def int_x86_avx_maskload_pd : GCCBuiltin<"__builtin_ia32_maskloadpd">,
1828         Intrinsic<[llvm_v2f64_ty], [llvm_ptr_ty, llvm_v2i64_ty],
1829                   [IntrReadArgMem]>;
1830   def int_x86_avx_maskload_ps : GCCBuiltin<"__builtin_ia32_maskloadps">,
1831         Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty, llvm_v4i32_ty],
1832                   [IntrReadArgMem]>;
1833   def int_x86_avx_maskload_pd_256 : GCCBuiltin<"__builtin_ia32_maskloadpd256">,
1834         Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty, llvm_v4i64_ty],
1835                   [IntrReadArgMem]>;
1836   def int_x86_avx_maskload_ps_256 : GCCBuiltin<"__builtin_ia32_maskloadps256">,
1837         Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty, llvm_v8i32_ty],
1838                   [IntrReadArgMem]>;
1839   def int_x86_avx512_mask_loadu_ps_512 : GCCBuiltin<"__builtin_ia32_loadups512_mask">,
1840         Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1841                   [IntrReadArgMem]>;
1842   def int_x86_avx512_mask_loadu_pd_512 : GCCBuiltin<"__builtin_ia32_loadupd512_mask">,
1843         Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1844                   [IntrReadArgMem]>;
1845   def int_x86_avx512_mask_load_ps_512 : GCCBuiltin<"__builtin_ia32_loadaps512_mask">,
1846         Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1847                   [IntrReadArgMem]>;
1848   def int_x86_avx512_mask_load_pd_512 : GCCBuiltin<"__builtin_ia32_loadapd512_mask">,
1849         Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1850                   [IntrReadArgMem]>;
1851
1852   def int_x86_avx512_mask_move_ss : GCCBuiltin<"__builtin_ia32_movss_mask">,
1853         Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
1854                   [IntrNoMem]>;
1855   def int_x86_avx512_mask_move_sd : GCCBuiltin<"__builtin_ia32_movsd_mask">,
1856         Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
1857                   [IntrNoMem]>;
1858 }
1859
1860 // Conditional store ops
1861 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1862   def int_x86_avx_maskstore_pd : GCCBuiltin<"__builtin_ia32_maskstorepd">,
1863         Intrinsic<[], [llvm_ptr_ty,
1864                   llvm_v2i64_ty, llvm_v2f64_ty], [IntrReadWriteArgMem]>;
1865   def int_x86_avx_maskstore_ps : GCCBuiltin<"__builtin_ia32_maskstoreps">,
1866         Intrinsic<[], [llvm_ptr_ty,
1867                   llvm_v4i32_ty, llvm_v4f32_ty], [IntrReadWriteArgMem]>;
1868   def int_x86_avx_maskstore_pd_256 :
1869         GCCBuiltin<"__builtin_ia32_maskstorepd256">,
1870         Intrinsic<[], [llvm_ptr_ty,
1871                   llvm_v4i64_ty, llvm_v4f64_ty], [IntrReadWriteArgMem]>;
1872   def int_x86_avx_maskstore_ps_256 :
1873         GCCBuiltin<"__builtin_ia32_maskstoreps256">,
1874         Intrinsic<[], [llvm_ptr_ty,
1875                   llvm_v8i32_ty, llvm_v8f32_ty], [IntrReadWriteArgMem]>;
1876   def int_x86_avx512_mask_storeu_ps_512 :
1877         GCCBuiltin<"__builtin_ia32_storeups512_mask">,
1878         Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1879                   [IntrReadWriteArgMem]>;
1880   def int_x86_avx512_mask_storeu_pd_512 :
1881         GCCBuiltin<"__builtin_ia32_storeupd512_mask">,
1882         Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1883                   [IntrReadWriteArgMem]>;
1884   def int_x86_avx512_mask_store_ps_512 :
1885         GCCBuiltin<"__builtin_ia32_storeaps512_mask">,
1886         Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1887                   [IntrReadWriteArgMem]>;
1888   def int_x86_avx512_mask_store_pd_512 :
1889         GCCBuiltin<"__builtin_ia32_storeapd512_mask">,
1890         Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1891                   [IntrReadWriteArgMem]>;
1892   def int_x86_avx512_mask_store_ss :
1893         GCCBuiltin<"__builtin_ia32_storess_mask">,
1894         Intrinsic<[], [llvm_ptr_ty, llvm_v4f32_ty, llvm_i8_ty],
1895                   [IntrReadWriteArgMem]>;
1896 }
1897
1898 //===----------------------------------------------------------------------===//
1899 // AVX2
1900
1901 // Integer arithmetic ops.
1902 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1903   def int_x86_avx2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb256">,
1904               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1905                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1906   def int_x86_avx2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw256">,
1907               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1908                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1909   def int_x86_avx2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb256">,
1910               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1911                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1912   def int_x86_avx2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw256">,
1913               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1914                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1915   def int_x86_avx2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb256">,
1916               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1917                          llvm_v32i8_ty], [IntrNoMem]>;
1918   def int_x86_avx2_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw256">,
1919               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1920                          llvm_v16i16_ty], [IntrNoMem]>;
1921   def int_x86_avx2_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb256">,
1922               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1923                          llvm_v32i8_ty], [IntrNoMem]>;
1924   def int_x86_avx2_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw256">,
1925               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1926                          llvm_v16i16_ty], [IntrNoMem]>;
1927   def int_x86_avx2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw256">,
1928               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1929                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1930   def int_x86_avx2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw256">,
1931               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1932                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1933   def int_x86_avx2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq256">,
1934               Intrinsic<[llvm_v4i64_ty], [llvm_v8i32_ty,
1935                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1936   def int_x86_avx2_pmul_dq : GCCBuiltin<"__builtin_ia32_pmuldq256">,
1937               Intrinsic<[llvm_v4i64_ty], [llvm_v8i32_ty,
1938                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1939   def int_x86_avx2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd256">,
1940               Intrinsic<[llvm_v8i32_ty], [llvm_v16i16_ty,
1941                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1942   def int_x86_avx2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb256">,
1943               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1944                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1945   def int_x86_avx2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw256">,
1946               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1947                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1948   def int_x86_avx2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw256">,
1949               Intrinsic<[llvm_v4i64_ty], [llvm_v32i8_ty,
1950                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1951 }
1952
1953 // Vector min, max
1954 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1955   def int_x86_avx2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub256">,
1956               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1957                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1958   def int_x86_avx2_pmaxu_w : GCCBuiltin<"__builtin_ia32_pmaxuw256">,
1959               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1960                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1961   def int_x86_avx2_pmaxu_d : GCCBuiltin<"__builtin_ia32_pmaxud256">,
1962               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1963                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1964   def int_x86_avx2_pmaxs_b : GCCBuiltin<"__builtin_ia32_pmaxsb256">,
1965               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1966                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1967   def int_x86_avx2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw256">,
1968               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1969                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1970   def int_x86_avx2_pmaxs_d : GCCBuiltin<"__builtin_ia32_pmaxsd256">,
1971               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1972                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1973   def int_x86_avx2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub256">,
1974               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1975                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1976   def int_x86_avx2_pminu_w : GCCBuiltin<"__builtin_ia32_pminuw256">,
1977               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1978                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1979   def int_x86_avx2_pminu_d : GCCBuiltin<"__builtin_ia32_pminud256">,
1980               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1981                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1982   def int_x86_avx2_pmins_b : GCCBuiltin<"__builtin_ia32_pminsb256">,
1983               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1984                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1985   def int_x86_avx2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw256">,
1986               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1987                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1988   def int_x86_avx2_pmins_d : GCCBuiltin<"__builtin_ia32_pminsd256">,
1989               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1990                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1991   def int_x86_avx512_mask_pmaxs_b_128 : GCCBuiltin<"__builtin_ia32_pmaxsb128_mask">,
1992               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, 
1993                          llvm_v16i8_ty, llvm_i16_ty], [IntrNoMem]>;
1994   def int_x86_avx512_mask_pmaxs_b_256 : GCCBuiltin<"__builtin_ia32_pmaxsb256_mask">,
1995               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty, 
1996                          llvm_v32i8_ty,  llvm_i32_ty], [IntrNoMem]>;
1997   def int_x86_avx512_mask_pmaxs_b_512 : GCCBuiltin<"__builtin_ia32_pmaxsb512_mask">,
1998               Intrinsic<[llvm_v64i8_ty], [llvm_v64i8_ty, llvm_v64i8_ty, 
1999                          llvm_v64i8_ty,  llvm_i64_ty], [IntrNoMem]>;
2000   def int_x86_avx512_mask_pmaxu_b_128 : GCCBuiltin<"__builtin_ia32_pmaxub128_mask">,
2001               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, 
2002                          llvm_v16i8_ty, llvm_i16_ty], [IntrNoMem]>;
2003   def int_x86_avx512_mask_pmaxu_b_256 : GCCBuiltin<"__builtin_ia32_pmaxub256_mask">,
2004               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty, 
2005                          llvm_v32i8_ty,  llvm_i32_ty], [IntrNoMem]>;
2006   def int_x86_avx512_mask_pmaxu_b_512 : GCCBuiltin<"__builtin_ia32_pmaxub512_mask">,
2007               Intrinsic<[llvm_v64i8_ty], [llvm_v64i8_ty, llvm_v64i8_ty, 
2008                          llvm_v64i8_ty,  llvm_i64_ty], [IntrNoMem]>;
2009   def int_x86_avx512_mask_pmaxs_w_128 : GCCBuiltin<"__builtin_ia32_pmaxsw128_mask">,
2010               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2011                          llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2012   def int_x86_avx512_mask_pmaxs_w_256 : GCCBuiltin<"__builtin_ia32_pmaxsw256_mask">,
2013               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2014                          llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2015   def int_x86_avx512_mask_pmaxs_w_512 : GCCBuiltin<"__builtin_ia32_pmaxsw512_mask">,
2016               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty, 
2017                    llvm_v32i16_ty,  llvm_i32_ty],[IntrNoMem]>;
2018   def int_x86_avx512_mask_pmaxu_w_128 : GCCBuiltin<"__builtin_ia32_pmaxuw128_mask">,
2019               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2020                          llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2021   def int_x86_avx512_mask_pmaxu_w_256 : GCCBuiltin<"__builtin_ia32_pmaxuw256_mask">,
2022               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2023                          llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2024   def int_x86_avx512_mask_pmaxu_w_512 : GCCBuiltin<"__builtin_ia32_pmaxuw512_mask">,
2025               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty,
2026                          llvm_v32i16_ty,  llvm_i32_ty],[IntrNoMem]>;
2027   def int_x86_avx512_mask_pmins_b_128 : GCCBuiltin<"__builtin_ia32_pminsb128_mask">,
2028               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, 
2029                          llvm_v16i8_ty,llvm_i16_ty], [IntrNoMem]>;
2030   def int_x86_avx512_mask_pmins_b_256 : GCCBuiltin<"__builtin_ia32_pminsb256_mask">,
2031               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty, 
2032                          llvm_v32i8_ty, llvm_i32_ty], [IntrNoMem]>;
2033   def int_x86_avx512_mask_pmins_b_512 : GCCBuiltin<"__builtin_ia32_pminsb512_mask">,
2034               Intrinsic<[llvm_v64i8_ty], [llvm_v64i8_ty, llvm_v64i8_ty,
2035                          llvm_v64i8_ty, llvm_i64_ty], [IntrNoMem]>;
2036   def int_x86_avx512_mask_pminu_b_128 : GCCBuiltin<"__builtin_ia32_pminub128_mask">,
2037               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,
2038                          llvm_v16i8_ty, llvm_i16_ty], [IntrNoMem]>;
2039   def int_x86_avx512_mask_pminu_b_256 : GCCBuiltin<"__builtin_ia32_pminub256_mask">,
2040               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty, 
2041                          llvm_v32i8_ty, llvm_i32_ty], [IntrNoMem]>;
2042   def int_x86_avx512_mask_pminu_b_512 : GCCBuiltin<"__builtin_ia32_pminub512_mask">,
2043               Intrinsic<[llvm_v64i8_ty], [llvm_v64i8_ty, llvm_v64i8_ty, 
2044                          llvm_v64i8_ty,  llvm_i64_ty], [IntrNoMem]>;
2045   def int_x86_avx512_mask_pmins_w_128 : GCCBuiltin<"__builtin_ia32_pminsw128_mask">,
2046               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2047                          llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2048   def int_x86_avx512_mask_pmins_w_256 : GCCBuiltin<"__builtin_ia32_pminsw256_mask">,
2049               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2050                          llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2051   def int_x86_avx512_mask_pmins_w_512 : GCCBuiltin<"__builtin_ia32_pminsw512_mask">,
2052               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty,
2053                          llvm_v32i16_ty,  llvm_i32_ty],[IntrNoMem]>;
2054   def int_x86_avx512_mask_pminu_w_128 : GCCBuiltin<"__builtin_ia32_pminuw128_mask">,
2055               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2056                          llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2057   def int_x86_avx512_mask_pminu_w_256 : GCCBuiltin<"__builtin_ia32_pminuw256_mask">,
2058               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2059                          llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2060   def int_x86_avx512_mask_pminu_w_512 : GCCBuiltin<"__builtin_ia32_pminuw512_mask">,
2061               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty, 
2062                          llvm_v32i16_ty,  llvm_i32_ty], [IntrNoMem]>;
2063   def int_x86_avx512_mask_pmaxu_d_512 : GCCBuiltin<"__builtin_ia32_pmaxud512_mask">,
2064               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
2065                          llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2066   def int_x86_avx512_mask_pmaxu_d_256 : GCCBuiltin<"__builtin_ia32_pmaxud256_mask">,
2067               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
2068                          llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2069   def int_x86_avx512_mask_pmaxu_d_128 : GCCBuiltin<"__builtin_ia32_pmaxud128_mask">,
2070               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2071                          llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2072   def int_x86_avx512_mask_pmaxs_d_512 : GCCBuiltin<"__builtin_ia32_pmaxsd512_mask">,
2073               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
2074                          llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2075   def int_x86_avx512_mask_pmaxs_d_256 : GCCBuiltin<"__builtin_ia32_pmaxsd256_mask">,
2076               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
2077                          llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2078   def int_x86_avx512_mask_pmaxs_d_128 : GCCBuiltin<"__builtin_ia32_pmaxsd128_mask">,
2079               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2080                          llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2081   def int_x86_avx512_mask_pmaxu_q_512 : GCCBuiltin<"__builtin_ia32_pmaxuq512_mask">,
2082               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
2083                          llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2084   def int_x86_avx512_mask_pmaxu_q_256 : GCCBuiltin<"__builtin_ia32_pmaxuq256_mask">,
2085               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
2086                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2087   def int_x86_avx512_mask_pmaxu_q_128 : GCCBuiltin<"__builtin_ia32_pmaxuq128_mask">,
2088               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2089                          llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2090   def int_x86_avx512_mask_pmaxs_q_512 : GCCBuiltin<"__builtin_ia32_pmaxsq512_mask">,
2091               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
2092                          llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2093   def int_x86_avx512_mask_pmaxs_q_256 : GCCBuiltin<"__builtin_ia32_pmaxsq256_mask">,
2094               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
2095                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2096   def int_x86_avx512_mask_pmaxs_q_128 : GCCBuiltin<"__builtin_ia32_pmaxsq128_mask">,
2097               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2098                          llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2099   def int_x86_avx512_mask_pminu_d_512 : GCCBuiltin<"__builtin_ia32_pminud512_mask">,
2100               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
2101                          llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2102   def int_x86_avx512_mask_pminu_d_256 : GCCBuiltin<"__builtin_ia32_pminud256_mask">,
2103               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
2104                          llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2105   def int_x86_avx512_mask_pminu_d_128 : GCCBuiltin<"__builtin_ia32_pminud128_mask">,
2106               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2107                          llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2108   def int_x86_avx512_mask_pmins_d_512 : GCCBuiltin<"__builtin_ia32_pminsd512_mask">,
2109               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
2110                          llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2111   def int_x86_avx512_mask_pmins_d_256 : GCCBuiltin<"__builtin_ia32_pminsd256_mask">,
2112               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
2113                          llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2114   def int_x86_avx512_mask_pmins_d_128 : GCCBuiltin<"__builtin_ia32_pminsd128_mask">,
2115               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2116                          llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2117   def int_x86_avx512_mask_pminu_q_512 : GCCBuiltin<"__builtin_ia32_pminuq512_mask">,
2118               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
2119                          llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2120   def int_x86_avx512_mask_pminu_q_256 : GCCBuiltin<"__builtin_ia32_pminuq256_mask">,
2121               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
2122                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2123   def int_x86_avx512_mask_pminu_q_128 : GCCBuiltin<"__builtin_ia32_pminuq128_mask">,
2124               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2125                          llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2126   def int_x86_avx512_mask_pmins_q_512 : GCCBuiltin<"__builtin_ia32_pminsq512_mask">,
2127               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
2128                          llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2129   def int_x86_avx512_mask_pmins_q_256 : GCCBuiltin<"__builtin_ia32_pminsq256_mask">,
2130               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
2131                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2132   def int_x86_avx512_mask_pmins_q_128 : GCCBuiltin<"__builtin_ia32_pminsq128_mask">,
2133               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2134                          llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2135 }
2136
2137 // Integer shift ops.
2138 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2139   def int_x86_avx2_psll_w : GCCBuiltin<"__builtin_ia32_psllw256">,
2140               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2141                          llvm_v8i16_ty], [IntrNoMem]>;
2142   def int_x86_avx2_psll_d : GCCBuiltin<"__builtin_ia32_pslld256">,
2143               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2144                          llvm_v4i32_ty], [IntrNoMem]>;
2145   def int_x86_avx2_psll_q : GCCBuiltin<"__builtin_ia32_psllq256">,
2146               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2147                          llvm_v2i64_ty], [IntrNoMem]>;
2148   def int_x86_avx2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw256">,
2149               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2150                          llvm_v8i16_ty], [IntrNoMem]>;
2151   def int_x86_avx2_psrl_d : GCCBuiltin<"__builtin_ia32_psrld256">,
2152               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2153                          llvm_v4i32_ty], [IntrNoMem]>;
2154   def int_x86_avx2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq256">,
2155               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2156                          llvm_v2i64_ty], [IntrNoMem]>;
2157   def int_x86_avx2_psra_w : GCCBuiltin<"__builtin_ia32_psraw256">,
2158               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2159                          llvm_v8i16_ty], [IntrNoMem]>;
2160   def int_x86_avx2_psra_d : GCCBuiltin<"__builtin_ia32_psrad256">,
2161               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2162                          llvm_v4i32_ty], [IntrNoMem]>;
2163
2164   def int_x86_avx2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi256">,
2165               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2166                          llvm_i32_ty], [IntrNoMem]>;
2167   def int_x86_avx2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi256">,
2168               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2169                          llvm_i32_ty], [IntrNoMem]>;
2170   def int_x86_avx2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi256">,
2171               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2172                          llvm_i32_ty], [IntrNoMem]>;
2173   def int_x86_avx2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi256">,
2174               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2175                          llvm_i32_ty], [IntrNoMem]>;
2176   def int_x86_avx2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi256">,
2177               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2178                          llvm_i32_ty], [IntrNoMem]>;
2179   def int_x86_avx2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi256">,
2180               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2181                          llvm_i32_ty], [IntrNoMem]>;
2182   def int_x86_avx2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi256">,
2183               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2184                          llvm_i32_ty], [IntrNoMem]>;
2185   def int_x86_avx2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi256">,
2186               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2187                          llvm_i32_ty], [IntrNoMem]>;
2188
2189   def int_x86_avx512_mask_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi512">,
2190               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2191                          llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2192   def int_x86_avx512_mask_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi512">,
2193               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2194                          llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2195   def int_x86_avx512_mask_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi512">,
2196               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2197                          llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2198   def int_x86_avx512_mask_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi512">,
2199               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2200                          llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2201   def int_x86_avx512_mask_psrai_d : GCCBuiltin<"__builtin_ia32_psradi512">,
2202               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2203                          llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2204   def int_x86_avx512_mask_psrai_q : GCCBuiltin<"__builtin_ia32_psraqi512">,
2205               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2206                          llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2207
2208   def int_x86_avx512_mask_psrl_w_128 : GCCBuiltin<"__builtin_ia32_psrlw128_mask">,
2209               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
2210                          llvm_v8i16_ty, llvm_v8i16_ty,  llvm_i8_ty], [IntrNoMem]>;
2211   def int_x86_avx512_mask_psrl_w_256 : GCCBuiltin<"__builtin_ia32_psrlw256_mask">,
2212               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2213                          llvm_v8i16_ty, llvm_v16i16_ty,  llvm_i16_ty], [IntrNoMem]>;
2214   def int_x86_avx512_mask_psrl_w_512 : GCCBuiltin<"__builtin_ia32_psrlw512_mask">,
2215               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty,
2216                          llvm_v8i16_ty, llvm_v32i16_ty,  llvm_i32_ty], [IntrNoMem]>;
2217   def int_x86_avx512_mask_psrl_wi_128 : GCCBuiltin<"__builtin_ia32_psrlwi128_mask">,
2218               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
2219                          llvm_i8_ty, llvm_v8i16_ty,  llvm_i8_ty], [IntrNoMem]>;
2220   def int_x86_avx512_mask_psrl_wi_256 : GCCBuiltin<"__builtin_ia32_psrlwi256_mask">,
2221               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2222                          llvm_i8_ty, llvm_v16i16_ty,  llvm_i16_ty], [IntrNoMem]>;
2223   def int_x86_avx512_mask_psrl_wi_512 : GCCBuiltin<"__builtin_ia32_psrlwi512_mask">,
2224               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty,
2225                          llvm_i8_ty, llvm_v32i16_ty,  llvm_i32_ty], [IntrNoMem]>;
2226
2227   def int_x86_avx512_mask_psra_w_128 : GCCBuiltin<"__builtin_ia32_psraw128_mask">,
2228               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
2229                          llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2230   def int_x86_avx512_mask_psra_w_256 : GCCBuiltin<"__builtin_ia32_psraw256_mask">,
2231               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2232                          llvm_v8i16_ty, llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2233   def int_x86_avx512_mask_psra_w_512 : GCCBuiltin<"__builtin_ia32_psraw512_mask">,
2234               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty,
2235                          llvm_v8i16_ty, llvm_v32i16_ty, llvm_i32_ty], [IntrNoMem]>;
2236   def int_x86_avx512_mask_psra_wi_128 : GCCBuiltin<"__builtin_ia32_psrawi128_mask">,
2237               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
2238                          llvm_i8_ty, llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2239   def int_x86_avx512_mask_psra_wi_256 : GCCBuiltin<"__builtin_ia32_psrawi256_mask">,
2240               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2241                          llvm_i8_ty, llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2242   def int_x86_avx512_mask_psra_wi_512 : GCCBuiltin<"__builtin_ia32_psrawi512_mask">,
2243               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty,
2244                          llvm_i8_ty, llvm_v32i16_ty, llvm_i32_ty], [IntrNoMem]>;
2245
2246   def int_x86_avx512_mask_psll_d : GCCBuiltin<"__builtin_ia32_pslld512_mask">,
2247               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2248                          llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2249   def int_x86_avx512_mask_psll_q : GCCBuiltin<"__builtin_ia32_psllq512_mask">,
2250               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2251                          llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2252   def int_x86_avx512_mask_psrl_d : GCCBuiltin<"__builtin_ia32_psrld512_mask">,
2253               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2254                          llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2255   def int_x86_avx512_mask_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq512_mask">,
2256               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2257                          llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2258   def int_x86_avx512_mask_psra_d : GCCBuiltin<"__builtin_ia32_psrad512_mask">,
2259               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2260                          llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2261   def int_x86_avx512_mask_psra_q : GCCBuiltin<"__builtin_ia32_psraq512_mask">,
2262               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2263                          llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2264
2265   def int_x86_avx512_mask_psra_d_128 : GCCBuiltin<"__builtin_ia32_psrad128_mask">,
2266               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
2267                          llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2268   def int_x86_avx512_mask_psra_d_256 : GCCBuiltin<"__builtin_ia32_psrad256_mask">,
2269              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2270                          llvm_v4i32_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2271   def int_x86_avx512_mask_psra_di_128 : GCCBuiltin<"__builtin_ia32_psradi128_mask">,
2272               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, 
2273                          llvm_i8_ty, llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2274   def int_x86_avx512_mask_psra_di_256 : GCCBuiltin<"__builtin_ia32_psradi256_mask">,
2275               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2276                         llvm_i8_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2277   def int_x86_avx512_mask_psra_di_512 : GCCBuiltin<"__builtin_ia32_psradi512_mask">,
2278               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2279                          llvm_i8_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2280   def int_x86_avx512_mask_psra_q_128 : GCCBuiltin<"__builtin_ia32_psraq128_mask">,
2281               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, 
2282                          llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2283   def int_x86_avx512_mask_psra_q_256 : GCCBuiltin<"__builtin_ia32_psraq256_mask">,
2284              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2285                          llvm_v2i64_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2286   def int_x86_avx512_mask_psra_qi_128 : GCCBuiltin<"__builtin_ia32_psraqi128_mask">,
2287               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, 
2288                          llvm_i8_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2289   def int_x86_avx512_mask_psra_qi_256 : GCCBuiltin<"__builtin_ia32_psraqi256_mask">,
2290              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2291                          llvm_i8_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2292   def int_x86_avx512_mask_psra_qi_512 : GCCBuiltin<"__builtin_ia32_psraqi512_mask">,
2293               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, 
2294                          llvm_i8_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2295
2296   def int_x86_avx512_mask_psrl_d_128: GCCBuiltin<"__builtin_ia32_psrld128_mask">,
2297               Intrinsic<[llvm_v4i32_ty], [ llvm_v4i32_ty,
2298                          llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty ], [IntrNoMem]>;
2299   def int_x86_avx512_mask_psrl_d_256: GCCBuiltin<"__builtin_ia32_psrld256_mask">,
2300               Intrinsic<[llvm_v8i32_ty], [ llvm_v8i32_ty, 
2301                          llvm_v4i32_ty, llvm_v8i32_ty, llvm_i8_ty ], [IntrNoMem]>;
2302   def int_x86_avx512_mask_psrl_di_128: GCCBuiltin<"__builtin_ia32_psrldi128_mask">,
2303               Intrinsic<[llvm_v4i32_ty], [ llvm_v4i32_ty, 
2304                          llvm_i8_ty, llvm_v4i32_ty, llvm_i8_ty ], [IntrNoMem]>;
2305   def int_x86_avx512_mask_psrl_di_256: GCCBuiltin<"__builtin_ia32_psrldi256_mask">,
2306               Intrinsic<[llvm_v8i32_ty], [ llvm_v8i32_ty, 
2307                          llvm_i8_ty, llvm_v8i32_ty, llvm_i8_ty ], [IntrNoMem]>;
2308   def int_x86_avx512_mask_psrl_di_512: GCCBuiltin<"__builtin_ia32_psrldi512_mask">,
2309               Intrinsic<[llvm_v16i32_ty], [ llvm_v16i32_ty, 
2310                          llvm_i8_ty, llvm_v16i32_ty, llvm_i16_ty ], [IntrNoMem]>;
2311
2312   def int_x86_avx512_mask_psrl_q_128:  GCCBuiltin<"__builtin_ia32_psrlq128_mask">,
2313         Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, 
2314                    llvm_v2i64_ty, llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2315   def int_x86_avx512_mask_psrl_q_256: GCCBuiltin<"__builtin_ia32_psrlq256_mask">,
2316         Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,  
2317                    llvm_v2i64_ty, llvm_v4i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2318   def int_x86_avx512_mask_psrl_qi_128: GCCBuiltin<"__builtin_ia32_psrlqi128_mask">,
2319         Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
2320                    llvm_i8_ty, llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2321   def int_x86_avx512_mask_psrl_qi_256: GCCBuiltin<"__builtin_ia32_psrlqi256_mask">,
2322         Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2323                    llvm_i8_ty, llvm_v4i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2324   def int_x86_avx512_mask_psrl_qi_512: GCCBuiltin<"__builtin_ia32_psrlqi512_mask">,
2325         Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, 
2326                    llvm_i8_ty, llvm_v8i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2327 }
2328
2329 // Pack ops.
2330 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2331   def int_x86_avx2_packsswb : GCCBuiltin<"__builtin_ia32_packsswb256">,
2332               Intrinsic<[llvm_v32i8_ty], [llvm_v16i16_ty,
2333                          llvm_v16i16_ty], [IntrNoMem]>;
2334   def int_x86_avx2_packssdw : GCCBuiltin<"__builtin_ia32_packssdw256">,
2335               Intrinsic<[llvm_v16i16_ty], [llvm_v8i32_ty,
2336                          llvm_v8i32_ty], [IntrNoMem]>;
2337   def int_x86_avx2_packuswb : GCCBuiltin<"__builtin_ia32_packuswb256">,
2338               Intrinsic<[llvm_v32i8_ty], [llvm_v16i16_ty,
2339                          llvm_v16i16_ty], [IntrNoMem]>;
2340   def int_x86_avx2_packusdw : GCCBuiltin<"__builtin_ia32_packusdw256">,
2341               Intrinsic<[llvm_v16i16_ty], [llvm_v8i32_ty,
2342                          llvm_v8i32_ty], [IntrNoMem]>;
2343 }
2344
2345 // Absolute value ops
2346 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2347   def int_x86_avx2_pabs_b : GCCBuiltin<"__builtin_ia32_pabsb256">,
2348               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty], [IntrNoMem]>;
2349   def int_x86_avx2_pabs_w : GCCBuiltin<"__builtin_ia32_pabsw256">,
2350               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty], [IntrNoMem]>;
2351   def int_x86_avx2_pabs_d : GCCBuiltin<"__builtin_ia32_pabsd256">,
2352               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
2353
2354   def int_x86_avx512_mask_pabs_b_128 : 
2355        GCCBuiltin<"__builtin_ia32_pabsb128_mask">,
2356         Intrinsic<[llvm_v16i8_ty],
2357         [llvm_v16i8_ty, llvm_v16i8_ty,  llvm_i16_ty],
2358         [IntrNoMem]>;
2359
2360   def int_x86_avx512_mask_pabs_b_256 : 
2361         GCCBuiltin<"__builtin_ia32_pabsb256_mask">,
2362           Intrinsic<[llvm_v32i8_ty],
2363           [llvm_v32i8_ty, llvm_v32i8_ty,  llvm_i32_ty],
2364           [IntrNoMem]>;
2365
2366   def int_x86_avx512_mask_pabs_b_512 : 
2367         GCCBuiltin<"__builtin_ia32_pabsb512_mask">,
2368           Intrinsic<[llvm_v64i8_ty],
2369           [llvm_v64i8_ty, llvm_v64i8_ty,  llvm_i64_ty],
2370           [IntrNoMem]>;
2371
2372   def int_x86_avx512_mask_pabs_d_128 : 
2373         GCCBuiltin<"__builtin_ia32_pabsd128_mask">,
2374           Intrinsic<[llvm_v4i32_ty],
2375           [llvm_v4i32_ty, llvm_v4i32_ty,  llvm_i8_ty],
2376           [IntrNoMem]>;
2377
2378   def int_x86_avx512_mask_pabs_d_256 : 
2379         GCCBuiltin<"__builtin_ia32_pabsd256_mask">,
2380           Intrinsic<[llvm_v8i32_ty],
2381           [llvm_v8i32_ty, llvm_v8i32_ty,  llvm_i8_ty],
2382           [IntrNoMem]>;
2383
2384   def int_x86_avx512_mask_pabs_d_512 : 
2385         GCCBuiltin<"__builtin_ia32_pabsd512_mask">,
2386           Intrinsic<[llvm_v16i32_ty],
2387           [llvm_v16i32_ty, llvm_v16i32_ty,  llvm_i16_ty],
2388           [IntrNoMem]>;
2389
2390   def int_x86_avx512_mask_pabs_q_128 : 
2391         GCCBuiltin<"__builtin_ia32_pabsq128_mask">,
2392           Intrinsic<[llvm_v2i64_ty],
2393           [llvm_v2i64_ty, llvm_v2i64_ty,  llvm_i8_ty],
2394           [IntrNoMem]>;
2395
2396   def int_x86_avx512_mask_pabs_q_256 : 
2397         GCCBuiltin<"__builtin_ia32_pabsq256_mask">,
2398           Intrinsic<[llvm_v4i64_ty],
2399           [llvm_v4i64_ty, llvm_v4i64_ty,  llvm_i8_ty],
2400           [IntrNoMem]>;
2401
2402   def int_x86_avx512_mask_pabs_q_512 : 
2403         GCCBuiltin<"__builtin_ia32_pabsq512_mask">,
2404           Intrinsic<[llvm_v8i64_ty],
2405           [llvm_v8i64_ty, llvm_v8i64_ty,  llvm_i8_ty],
2406           [IntrNoMem]>;
2407
2408   def int_x86_avx512_mask_pabs_w_128 : 
2409         GCCBuiltin<"__builtin_ia32_pabsw128_mask">,
2410           Intrinsic<[llvm_v8i16_ty],
2411           [llvm_v8i16_ty, llvm_v8i16_ty,  llvm_i8_ty],
2412           [IntrNoMem]>;
2413
2414   def int_x86_avx512_mask_pabs_w_256 : 
2415         GCCBuiltin<"__builtin_ia32_pabsw256_mask">,
2416           Intrinsic<[llvm_v16i16_ty],
2417           [llvm_v16i16_ty, llvm_v16i16_ty,  llvm_i16_ty],
2418           [IntrNoMem]>;
2419
2420   def int_x86_avx512_mask_pabs_w_512 : 
2421         GCCBuiltin<"__builtin_ia32_pabsw512_mask">,
2422           Intrinsic<[llvm_v32i16_ty],
2423           [llvm_v32i16_ty, llvm_v32i16_ty,  llvm_i32_ty],
2424           [IntrNoMem]>;
2425 }
2426
2427 // Horizontal arithmetic ops
2428 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2429   def int_x86_avx2_phadd_w : GCCBuiltin<"__builtin_ia32_phaddw256">,
2430               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2431                          llvm_v16i16_ty], [IntrNoMem]>;
2432   def int_x86_avx2_phadd_d : GCCBuiltin<"__builtin_ia32_phaddd256">,
2433               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2434                          llvm_v8i32_ty], [IntrNoMem]>;
2435   def int_x86_avx2_phadd_sw : GCCBuiltin<"__builtin_ia32_phaddsw256">,
2436               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2437                          llvm_v16i16_ty], [IntrNoMem]>;
2438   def int_x86_avx2_phsub_w : GCCBuiltin<"__builtin_ia32_phsubw256">,
2439               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2440                          llvm_v16i16_ty], [IntrNoMem]>;
2441   def int_x86_avx2_phsub_d : GCCBuiltin<"__builtin_ia32_phsubd256">,
2442               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2443                          llvm_v8i32_ty], [IntrNoMem]>;
2444   def int_x86_avx2_phsub_sw : GCCBuiltin<"__builtin_ia32_phsubsw256">,
2445               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2446                          llvm_v16i16_ty], [IntrNoMem]>;
2447   def int_x86_avx2_pmadd_ub_sw : GCCBuiltin<"__builtin_ia32_pmaddubsw256">,
2448               Intrinsic<[llvm_v16i16_ty], [llvm_v32i8_ty,
2449                          llvm_v32i8_ty], [IntrNoMem]>;
2450 }
2451
2452 // Sign ops
2453 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2454   def int_x86_avx2_psign_b : GCCBuiltin<"__builtin_ia32_psignb256">,
2455               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
2456                          llvm_v32i8_ty], [IntrNoMem]>;
2457   def int_x86_avx2_psign_w : GCCBuiltin<"__builtin_ia32_psignw256">,
2458               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2459                          llvm_v16i16_ty], [IntrNoMem]>;
2460   def int_x86_avx2_psign_d : GCCBuiltin<"__builtin_ia32_psignd256">,
2461               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2462                          llvm_v8i32_ty], [IntrNoMem]>;
2463 }
2464
2465 // Packed multiply high with round and scale
2466 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2467   def int_x86_avx2_pmul_hr_sw : GCCBuiltin<"__builtin_ia32_pmulhrsw256">,
2468               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2469                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
2470   def int_x86_avx512_mask_pmul_hr_sw_128 : GCCBuiltin<"__builtin_ia32_pmulhrsw128_mask">,
2471               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2472                      llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2473   def int_x86_avx512_mask_pmul_hr_sw_256 : GCCBuiltin<"__builtin_ia32_pmulhrsw256_mask">,
2474               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2475                      llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2476   def int_x86_avx512_mask_pmul_hr_sw_512 : GCCBuiltin<"__builtin_ia32_pmulhrsw512_mask">,
2477               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty, 
2478                      llvm_v32i16_ty, llvm_i32_ty], [IntrNoMem]>;
2479 }
2480
2481 // Vector sign and zero extend
2482 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2483   def int_x86_avx2_pmovsxbd : GCCBuiltin<"__builtin_ia32_pmovsxbd256">,
2484               Intrinsic<[llvm_v8i32_ty], [llvm_v16i8_ty],
2485                         [IntrNoMem]>;
2486   def int_x86_avx2_pmovsxbq : GCCBuiltin<"__builtin_ia32_pmovsxbq256">,
2487               Intrinsic<[llvm_v4i64_ty], [llvm_v16i8_ty],
2488                         [IntrNoMem]>;
2489   def int_x86_avx2_pmovsxbw : GCCBuiltin<"__builtin_ia32_pmovsxbw256">,
2490               Intrinsic<[llvm_v16i16_ty], [llvm_v16i8_ty],
2491                         [IntrNoMem]>;
2492   def int_x86_avx2_pmovsxdq : GCCBuiltin<"__builtin_ia32_pmovsxdq256">,
2493               Intrinsic<[llvm_v4i64_ty], [llvm_v4i32_ty],
2494                         [IntrNoMem]>;
2495   def int_x86_avx2_pmovsxwd : GCCBuiltin<"__builtin_ia32_pmovsxwd256">,
2496               Intrinsic<[llvm_v8i32_ty], [llvm_v8i16_ty],
2497                         [IntrNoMem]>;
2498   def int_x86_avx2_pmovsxwq : GCCBuiltin<"__builtin_ia32_pmovsxwq256">,
2499               Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty],
2500                         [IntrNoMem]>;
2501   def int_x86_avx2_pmovzxbd : GCCBuiltin<"__builtin_ia32_pmovzxbd256">,
2502               Intrinsic<[llvm_v8i32_ty], [llvm_v16i8_ty],
2503                         [IntrNoMem]>;
2504   def int_x86_avx2_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq256">,
2505               Intrinsic<[llvm_v4i64_ty], [llvm_v16i8_ty],
2506                         [IntrNoMem]>;
2507   def int_x86_avx2_pmovzxbw : GCCBuiltin<"__builtin_ia32_pmovzxbw256">,
2508               Intrinsic<[llvm_v16i16_ty], [llvm_v16i8_ty],
2509                         [IntrNoMem]>;
2510   def int_x86_avx2_pmovzxdq : GCCBuiltin<"__builtin_ia32_pmovzxdq256">,
2511               Intrinsic<[llvm_v4i64_ty], [llvm_v4i32_ty],
2512                         [IntrNoMem]>;
2513   def int_x86_avx2_pmovzxwd : GCCBuiltin<"__builtin_ia32_pmovzxwd256">,
2514               Intrinsic<[llvm_v8i32_ty], [llvm_v8i16_ty],
2515                         [IntrNoMem]>;
2516   def int_x86_avx2_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq256">,
2517               Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty],
2518                         [IntrNoMem]>;
2519 }
2520
2521 // Vector blend
2522 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2523   def int_x86_avx2_pblendvb : GCCBuiltin<"__builtin_ia32_pblendvb256">,
2524               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty,
2525                          llvm_v32i8_ty], [IntrNoMem]>;
2526 }
2527
2528 // Vector load with broadcast
2529 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2530   def int_x86_avx512_mask_pbroadcast_d_gpr_512 :
2531               GCCBuiltin<"__builtin_ia32_pbroadcastd512_gpr_mask">,
2532               Intrinsic<[llvm_v16i32_ty], [llvm_i32_ty, llvm_v16i32_ty,
2533               llvm_i16_ty], [IntrNoMem]>;
2534   def int_x86_avx512_mask_pbroadcast_q_gpr_512 :
2535               GCCBuiltin<"__builtin_ia32_pbroadcastq512_gpr_mask">,
2536               Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty, llvm_v8i64_ty,
2537               llvm_i8_ty], [IntrNoMem]>;
2538   def int_x86_avx512_mask_pbroadcast_q_mem_512 :
2539               GCCBuiltin<"__builtin_ia32_pbroadcastq512_mem_mask">,
2540               Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty, llvm_v8i64_ty,
2541               llvm_i8_ty], [IntrNoMem]>;
2542 }
2543
2544 // Vector permutation
2545 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2546   def int_x86_avx2_permd : GCCBuiltin<"__builtin_ia32_permvarsi256">,
2547               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
2548                         [IntrNoMem]>;
2549   def int_x86_avx2_permps : GCCBuiltin<"__builtin_ia32_permvarsf256">,
2550               Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8i32_ty],
2551                         [IntrNoMem]>;
2552   def int_x86_avx2_vperm2i128 : GCCBuiltin<"__builtin_ia32_permti256">,
2553               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2554                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2555 }
2556
2557 // Vector extract and insert
2558 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2559   def int_x86_avx512_mask_vextractf32x4_512 :
2560       GCCBuiltin<"__builtin_ia32_extractf32x4_mask">,
2561                  Intrinsic<[llvm_v4f32_ty], [llvm_v16f32_ty, llvm_i32_ty,
2562                             llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
2563   def int_x86_avx512_mask_vextracti32x4_512 :
2564       GCCBuiltin<"__builtin_ia32_extracti32x4_mask">,
2565                  Intrinsic<[llvm_v4i32_ty], [llvm_v16i32_ty, llvm_i32_ty,
2566                             llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2567   def int_x86_avx512_mask_vextractf32x4_256 :
2568       GCCBuiltin<"__builtin_ia32_extractf32x4_256_mask">,
2569                  Intrinsic<[llvm_v4f32_ty], [llvm_v8f32_ty, llvm_i32_ty,
2570                             llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
2571   def int_x86_avx512_mask_vextracti32x4_256 :
2572       GCCBuiltin<"__builtin_ia32_extracti32x4_256_mask">,
2573                  Intrinsic<[llvm_v4i32_ty], [llvm_v8i32_ty, llvm_i32_ty,
2574                             llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2575   def int_x86_avx512_mask_vextractf64x2_256 :
2576       GCCBuiltin<"__builtin_ia32_extractf64x2_256_mask">,
2577                  Intrinsic<[llvm_v2f64_ty], [llvm_v4f64_ty, llvm_i32_ty,
2578                             llvm_v2f64_ty,  llvm_i8_ty], [IntrNoMem]>;
2579   def int_x86_avx512_mask_vextracti64x2_256 :
2580       GCCBuiltin<"__builtin_ia32_extracti64x2_256_mask">,
2581                  Intrinsic<[llvm_v2i64_ty], [llvm_v4i64_ty, llvm_i32_ty,
2582                             llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2583   def int_x86_avx512_mask_vextractf64x2_512 :
2584       GCCBuiltin<"__builtin_ia32_extractf64x2_512_mask">,
2585                  Intrinsic<[llvm_v2f64_ty], [llvm_v8f64_ty, llvm_i32_ty,
2586                             llvm_v2f64_ty,  llvm_i8_ty], [IntrNoMem]>;
2587   def int_x86_avx512_mask_vextracti64x2_512 :
2588       GCCBuiltin<"__builtin_ia32_extracti64x2_512_mask">,
2589                  Intrinsic<[llvm_v2i64_ty], [llvm_v8i64_ty, llvm_i32_ty,
2590                             llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2591   def int_x86_avx512_mask_vextractf32x8_512 :
2592       GCCBuiltin<"__builtin_ia32_extractf32x8_mask">,
2593                  Intrinsic<[llvm_v8f32_ty], [llvm_v16f32_ty, llvm_i32_ty,
2594                             llvm_v8f32_ty,  llvm_i8_ty], [IntrNoMem]>;
2595   def int_x86_avx512_mask_vextracti32x8_512 :
2596       GCCBuiltin<"__builtin_ia32_extracti32x8_mask">,
2597                  Intrinsic<[llvm_v8i32_ty],[llvm_v16i32_ty, llvm_i32_ty,
2598                             llvm_v8i32_ty,  llvm_i8_ty], [IntrNoMem]>;
2599   def int_x86_avx512_mask_vextractf64x4_512 :
2600       GCCBuiltin<"__builtin_ia32_extractf64x4_mask">,
2601                  Intrinsic<[llvm_v4f64_ty], [llvm_v8f64_ty, llvm_i32_ty,
2602                             llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
2603   def int_x86_avx512_mask_vextracti64x4_512 :
2604       GCCBuiltin<"__builtin_ia32_extracti64x4_mask">,
2605                  Intrinsic<[llvm_v4i64_ty], [llvm_v8i64_ty, llvm_i32_ty,
2606                             llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2607
2608   def int_x86_avx512_mask_insertf32x4_256 :
2609         GCCBuiltin<"__builtin_ia32_insertf32x4_256_mask">,
2610           Intrinsic<[llvm_v8f32_ty],
2611           [llvm_v8f32_ty, llvm_v4f32_ty, llvm_i32_ty, llvm_v8f32_ty, llvm_i8_ty],
2612           [IntrNoMem]>;
2613
2614   def int_x86_avx512_mask_insertf32x4_512 :
2615         GCCBuiltin<"__builtin_ia32_insertf32x4_512_mask">,
2616           Intrinsic<[llvm_v16f32_ty],
2617           [llvm_v16f32_ty, llvm_v4f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i8_ty],
2618           [IntrNoMem]>;
2619
2620   def int_x86_avx512_mask_insertf32x8_512 :
2621         GCCBuiltin<"__builtin_ia32_insertf32x8_mask">,
2622           Intrinsic<[llvm_v16f32_ty],
2623           [llvm_v16f32_ty, llvm_v8f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i16_ty],
2624           [IntrNoMem]>;
2625
2626   def int_x86_avx512_mask_insertf64x2_256 :
2627         GCCBuiltin<"__builtin_ia32_insertf64x2_256_mask">,
2628           Intrinsic<[llvm_v4f64_ty],
2629           [llvm_v4f64_ty, llvm_v2f64_ty, llvm_i32_ty, llvm_v4f64_ty, llvm_i8_ty],
2630           [IntrNoMem]>;
2631
2632   def int_x86_avx512_mask_insertf64x2_512 :
2633         GCCBuiltin<"__builtin_ia32_insertf64x2_512_mask">,
2634           Intrinsic<[llvm_v8f64_ty],
2635           [llvm_v8f64_ty, llvm_v2f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
2636           [IntrNoMem]>;
2637
2638   def int_x86_avx512_mask_insertf64x4_512 :
2639         GCCBuiltin<"__builtin_ia32_insertf64x4_mask">,
2640           Intrinsic<[llvm_v8f64_ty],
2641           [llvm_v8f64_ty, llvm_v4f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
2642           [IntrNoMem]>;
2643
2644   def int_x86_avx512_mask_inserti32x4_256 :
2645         GCCBuiltin<"__builtin_ia32_inserti32x4_256_mask">,
2646           Intrinsic<[llvm_v8i32_ty],
2647           [llvm_v8i32_ty, llvm_v4i32_ty, llvm_i32_ty, llvm_v8i32_ty, llvm_i8_ty],
2648           [IntrNoMem]>;
2649
2650   def int_x86_avx512_mask_inserti32x4_512 :
2651         GCCBuiltin<"__builtin_ia32_inserti32x4_512_mask">,
2652           Intrinsic<[llvm_v16i32_ty],
2653           [llvm_v16i32_ty, llvm_v4i32_ty, llvm_i32_ty, llvm_v16i32_ty, llvm_i8_ty],
2654           [IntrNoMem]>;
2655
2656   def int_x86_avx512_mask_inserti32x8_512 :
2657         GCCBuiltin<"__builtin_ia32_inserti32x8_mask">,
2658           Intrinsic<[llvm_v16i32_ty],
2659           [llvm_v16i32_ty, llvm_v8i32_ty, llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty],
2660           [IntrNoMem]>;
2661
2662   def int_x86_avx512_mask_inserti64x2_256 :
2663         GCCBuiltin<"__builtin_ia32_inserti64x2_256_mask">,
2664           Intrinsic<[llvm_v4i64_ty],
2665           [llvm_v4i64_ty, llvm_v2i64_ty, llvm_i32_ty, llvm_v4i64_ty, llvm_i8_ty],
2666           [IntrNoMem]>;
2667
2668   def int_x86_avx512_mask_inserti64x2_512 :
2669         GCCBuiltin<"__builtin_ia32_inserti64x2_512_mask">,
2670           Intrinsic<[llvm_v8i64_ty],
2671           [llvm_v8i64_ty, llvm_v2i64_ty, llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty],
2672           [IntrNoMem]>;
2673
2674   def int_x86_avx512_mask_inserti64x4_512 :
2675         GCCBuiltin<"__builtin_ia32_inserti64x4_mask">,
2676           Intrinsic<[llvm_v8i64_ty],
2677           [llvm_v8i64_ty, llvm_v4i64_ty, llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty],
2678           [IntrNoMem]>;                            
2679 }
2680
2681 // Conditional load ops
2682 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2683   def int_x86_avx2_maskload_d : GCCBuiltin<"__builtin_ia32_maskloadd">,
2684         Intrinsic<[llvm_v4i32_ty], [llvm_ptr_ty, llvm_v4i32_ty],
2685                   [IntrReadArgMem]>;
2686   def int_x86_avx2_maskload_q : GCCBuiltin<"__builtin_ia32_maskloadq">,
2687         Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_v2i64_ty],
2688                   [IntrReadArgMem]>;
2689   def int_x86_avx2_maskload_d_256 : GCCBuiltin<"__builtin_ia32_maskloadd256">,
2690         Intrinsic<[llvm_v8i32_ty], [llvm_ptr_ty, llvm_v8i32_ty],
2691                   [IntrReadArgMem]>;
2692   def int_x86_avx2_maskload_q_256 : GCCBuiltin<"__builtin_ia32_maskloadq256">,
2693         Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty, llvm_v4i64_ty],
2694                   [IntrReadArgMem]>;
2695   def int_x86_avx512_mask_loadu_d_512 : GCCBuiltin<"__builtin_ia32_loaddqusi512_mask">,
2696         Intrinsic<[llvm_v16i32_ty], [llvm_ptr_ty, llvm_v16i32_ty, llvm_i16_ty],
2697                   [IntrReadArgMem]>;
2698   def int_x86_avx512_mask_loadu_q_512 : GCCBuiltin<"__builtin_ia32_loaddqudi512_mask">,
2699         Intrinsic<[llvm_v8i64_ty], [llvm_ptr_ty, llvm_v8i64_ty, llvm_i8_ty],
2700                   [IntrReadArgMem]>;
2701 }
2702
2703 // Conditional store ops
2704 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2705   def int_x86_avx2_maskstore_d : GCCBuiltin<"__builtin_ia32_maskstored">,
2706         Intrinsic<[], [llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i32_ty],
2707                   [IntrReadWriteArgMem]>;
2708   def int_x86_avx2_maskstore_q : GCCBuiltin<"__builtin_ia32_maskstoreq">,
2709         Intrinsic<[], [llvm_ptr_ty, llvm_v2i64_ty, llvm_v2i64_ty],
2710                   [IntrReadWriteArgMem]>;
2711   def int_x86_avx2_maskstore_d_256 :
2712         GCCBuiltin<"__builtin_ia32_maskstored256">,
2713         Intrinsic<[], [llvm_ptr_ty, llvm_v8i32_ty, llvm_v8i32_ty],
2714                   [IntrReadWriteArgMem]>;
2715   def int_x86_avx2_maskstore_q_256 :
2716         GCCBuiltin<"__builtin_ia32_maskstoreq256">,
2717         Intrinsic<[], [llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i64_ty],
2718                   [IntrReadWriteArgMem]>;
2719   def int_x86_avx512_mask_storeu_d_512 :
2720         GCCBuiltin<"__builtin_ia32_storedqusi512_mask">,
2721         Intrinsic<[], [llvm_ptr_ty, llvm_v16i32_ty, llvm_i16_ty],
2722                   [IntrReadWriteArgMem]>;
2723   def int_x86_avx512_mask_storeu_q_512 :
2724         GCCBuiltin<"__builtin_ia32_storedqudi512_mask">,
2725         Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty, llvm_i8_ty],
2726                   [IntrReadWriteArgMem]>;
2727 }
2728
2729 // Variable bit shift ops
2730 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2731   def int_x86_avx2_psllv_d : GCCBuiltin<"__builtin_ia32_psllv4si">,
2732               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2733                         [IntrNoMem]>;
2734   def int_x86_avx2_psllv_d_256 : GCCBuiltin<"__builtin_ia32_psllv8si">,
2735               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
2736                         [IntrNoMem]>;
2737   def int_x86_avx2_psllv_q : GCCBuiltin<"__builtin_ia32_psllv2di">,
2738               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2739                         [IntrNoMem]>;
2740   def int_x86_avx2_psllv_q_256 : GCCBuiltin<"__builtin_ia32_psllv4di">,
2741               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty],
2742                         [IntrNoMem]>;
2743
2744   def int_x86_avx2_psrlv_d : GCCBuiltin<"__builtin_ia32_psrlv4si">,
2745               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2746                         [IntrNoMem]>;
2747   def int_x86_avx2_psrlv_d_256 : GCCBuiltin<"__builtin_ia32_psrlv8si">,
2748               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
2749                         [IntrNoMem]>;
2750   def int_x86_avx2_psrlv_q : GCCBuiltin<"__builtin_ia32_psrlv2di">,
2751               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2752                         [IntrNoMem]>;
2753   def int_x86_avx2_psrlv_q_256 : GCCBuiltin<"__builtin_ia32_psrlv4di">,
2754               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty],
2755                         [IntrNoMem]>;
2756
2757   def int_x86_avx2_psrav_d : GCCBuiltin<"__builtin_ia32_psrav4si">,
2758               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2759                         [IntrNoMem]>;
2760   def int_x86_avx2_psrav_d_256 : GCCBuiltin<"__builtin_ia32_psrav8si">,
2761               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
2762                         [IntrNoMem]>;
2763
2764   def int_x86_avx512_mask_psllv_d : GCCBuiltin<"__builtin_ia32_psllv16si_mask">,
2765               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2766                          llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
2767                         [IntrNoMem]>;
2768   def int_x86_avx512_mask_psllv_q : GCCBuiltin<"__builtin_ia32_psllv8di_mask">,
2769               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2770                          llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty], 
2771                         [IntrNoMem]>;
2772   def int_x86_avx512_mask_psrav_d : GCCBuiltin<"__builtin_ia32_psrav16si_mask">,
2773               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2774                          llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
2775                         [IntrNoMem]>;
2776   def int_x86_avx512_mask_psrav_q : GCCBuiltin<"__builtin_ia32_psrav8di_mask">,
2777               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2778                          llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
2779                         [IntrNoMem]>;
2780   def int_x86_avx512_mask_psrlv_d : GCCBuiltin<"__builtin_ia32_psrlv16si_mask">,
2781               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2782                          llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
2783                         [IntrNoMem]>;
2784   def int_x86_avx512_mask_psrlv_q : GCCBuiltin<"__builtin_ia32_psrlv8di_mask">,
2785               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2786                          llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty], 
2787                         [IntrNoMem]>;
2788   def int_x86_avx512_psll_dq_512 : GCCBuiltin<"__builtin_ia32_pslldq512">,
2789               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_i32_ty], 
2790                         [IntrNoMem]>;
2791   def int_x86_avx512_psrl_dq_512 : GCCBuiltin<"__builtin_ia32_psrldq512">,
2792               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_i32_ty], 
2793                         [IntrNoMem]>;                        
2794
2795   def int_x86_avx512_mask_psll_d_128 : GCCBuiltin<"__builtin_ia32_pslld128_mask">,
2796               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
2797                          llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2798   def int_x86_avx512_mask_psll_d_256 : GCCBuiltin<"__builtin_ia32_pslld256_mask">,
2799               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2800                          llvm_v4i32_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2801   def int_x86_avx512_mask_psll_di_128 : GCCBuiltin<"__builtin_ia32_pslldi128_mask">,
2802               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, 
2803                          llvm_i8_ty, llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2804   def int_x86_avx512_mask_psll_di_256 : GCCBuiltin<"__builtin_ia32_pslldi256_mask">,
2805               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2806                          llvm_i8_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2807   def int_x86_avx512_mask_psll_di_512 : GCCBuiltin<"__builtin_ia32_pslldi512_mask">,
2808               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, 
2809                          llvm_i8_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2810   def int_x86_avx512_mask_psll_q_128 : GCCBuiltin<"__builtin_ia32_psllq128_mask">,
2811               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
2812                          llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2813   def int_x86_avx512_mask_psll_q_256 : GCCBuiltin<"__builtin_ia32_psllq256_mask">,
2814               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2815                          llvm_v2i64_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2816   def int_x86_avx512_mask_psll_qi_128 : GCCBuiltin<"__builtin_ia32_psllqi128_mask">,
2817               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, 
2818                          llvm_i8_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2819   def int_x86_avx512_mask_psll_qi_256 : GCCBuiltin<"__builtin_ia32_psllqi256_mask">,
2820               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2821                          llvm_i8_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2822   def int_x86_avx512_mask_psll_qi_512 : GCCBuiltin<"__builtin_ia32_psllqi512_mask">,
2823               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, 
2824                          llvm_i8_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2825
2826   def int_x86_avx512_mask_psrlv16_hi : GCCBuiltin<"__builtin_ia32_psrlv16hi_mask">,
2827               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2828                          llvm_v16i16_ty, llvm_v16i16_ty,  llvm_i16_ty], [IntrNoMem]>;
2829   def int_x86_avx512_mask_psrlv2_di : GCCBuiltin<"__builtin_ia32_psrlv2di_mask">,
2830               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
2831                          llvm_v2i64_ty, llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2832   def int_x86_avx512_mask_psrlv32hi : GCCBuiltin<"__builtin_ia32_psrlv32hi_mask">,
2833               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, 
2834                          llvm_v32i16_ty, llvm_v32i16_ty,  llvm_i32_ty], [IntrNoMem]>;
2835   def int_x86_avx512_mask_psrlv4_di : GCCBuiltin<"__builtin_ia32_psrlv4di_mask">,
2836               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2837                          llvm_v4i64_ty, llvm_v4i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2838   def int_x86_avx512_mask_psrlv4_si : GCCBuiltin<"__builtin_ia32_psrlv4si_mask">,
2839               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, 
2840                          llvm_v4i32_ty, llvm_v4i32_ty,  llvm_i8_ty], [IntrNoMem]>;
2841   def int_x86_avx512_mask_psrlv8_hi : GCCBuiltin<"__builtin_ia32_psrlv8hi_mask">,
2842               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, 
2843                          llvm_v8i16_ty, llvm_v8i16_ty,  llvm_i8_ty], [IntrNoMem]>;
2844   def int_x86_avx512_mask_psrlv8_si : GCCBuiltin<"__builtin_ia32_psrlv8si_mask">,
2845               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2846                          llvm_v8i32_ty, llvm_v8i32_ty,  llvm_i8_ty], [IntrNoMem]>;
2847 }
2848
2849 // Gather ops
2850 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2851   def int_x86_avx2_gather_d_pd : GCCBuiltin<"__builtin_ia32_gatherd_pd">,
2852       Intrinsic<[llvm_v2f64_ty],
2853         [llvm_v2f64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v2f64_ty, llvm_i8_ty],
2854         [IntrReadArgMem]>;
2855   def int_x86_avx2_gather_d_pd_256 : GCCBuiltin<"__builtin_ia32_gatherd_pd256">,
2856       Intrinsic<[llvm_v4f64_ty],
2857         [llvm_v4f64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4f64_ty, llvm_i8_ty],
2858         [IntrReadArgMem]>;
2859   def int_x86_avx2_gather_q_pd : GCCBuiltin<"__builtin_ia32_gatherq_pd">,
2860       Intrinsic<[llvm_v2f64_ty],
2861         [llvm_v2f64_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v2f64_ty, llvm_i8_ty],
2862         [IntrReadArgMem]>;
2863   def int_x86_avx2_gather_q_pd_256 : GCCBuiltin<"__builtin_ia32_gatherq_pd256">,
2864       Intrinsic<[llvm_v4f64_ty],
2865         [llvm_v4f64_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4f64_ty, llvm_i8_ty],
2866         [IntrReadArgMem]>;
2867   def int_x86_avx2_gather_d_ps : GCCBuiltin<"__builtin_ia32_gatherd_ps">,
2868       Intrinsic<[llvm_v4f32_ty],
2869         [llvm_v4f32_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4f32_ty, llvm_i8_ty],
2870         [IntrReadArgMem]>;
2871   def int_x86_avx2_gather_d_ps_256 : GCCBuiltin<"__builtin_ia32_gatherd_ps256">,
2872       Intrinsic<[llvm_v8f32_ty],
2873         [llvm_v8f32_ty, llvm_ptr_ty, llvm_v8i32_ty, llvm_v8f32_ty, llvm_i8_ty],
2874         [IntrReadArgMem]>;
2875   def int_x86_avx2_gather_q_ps : GCCBuiltin<"__builtin_ia32_gatherq_ps">,
2876       Intrinsic<[llvm_v4f32_ty],
2877         [llvm_v4f32_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v4f32_ty, llvm_i8_ty],
2878         [IntrReadArgMem]>;
2879   def int_x86_avx2_gather_q_ps_256 : GCCBuiltin<"__builtin_ia32_gatherq_ps256">,
2880       Intrinsic<[llvm_v4f32_ty],
2881         [llvm_v4f32_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4f32_ty, llvm_i8_ty],
2882         [IntrReadArgMem]>;
2883
2884   def int_x86_avx2_gather_d_q : GCCBuiltin<"__builtin_ia32_gatherd_q">,
2885       Intrinsic<[llvm_v2i64_ty],
2886         [llvm_v2i64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v2i64_ty, llvm_i8_ty],
2887         [IntrReadArgMem]>;
2888   def int_x86_avx2_gather_d_q_256 : GCCBuiltin<"__builtin_ia32_gatherd_q256">,
2889       Intrinsic<[llvm_v4i64_ty],
2890         [llvm_v4i64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i64_ty, llvm_i8_ty],
2891         [IntrReadArgMem]>;
2892   def int_x86_avx2_gather_q_q : GCCBuiltin<"__builtin_ia32_gatherq_q">,
2893       Intrinsic<[llvm_v2i64_ty],
2894         [llvm_v2i64_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
2895         [IntrReadArgMem]>;
2896   def int_x86_avx2_gather_q_q_256 : GCCBuiltin<"__builtin_ia32_gatherq_q256">,
2897       Intrinsic<[llvm_v4i64_ty],
2898         [llvm_v4i64_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
2899         [IntrReadArgMem]>;
2900   def int_x86_avx2_gather_d_d : GCCBuiltin<"__builtin_ia32_gatherd_d">,
2901       Intrinsic<[llvm_v4i32_ty],
2902         [llvm_v4i32_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
2903         [IntrReadArgMem]>;
2904   def int_x86_avx2_gather_d_d_256 : GCCBuiltin<"__builtin_ia32_gatherd_d256">,
2905       Intrinsic<[llvm_v8i32_ty],
2906         [llvm_v8i32_ty, llvm_ptr_ty, llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
2907         [IntrReadArgMem]>;
2908   def int_x86_avx2_gather_q_d : GCCBuiltin<"__builtin_ia32_gatherq_d">,
2909       Intrinsic<[llvm_v4i32_ty],
2910         [llvm_v4i32_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v4i32_ty, llvm_i8_ty],
2911         [IntrReadArgMem]>;
2912   def int_x86_avx2_gather_q_d_256 : GCCBuiltin<"__builtin_ia32_gatherq_d256">,
2913       Intrinsic<[llvm_v4i32_ty],
2914         [llvm_v4i32_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i32_ty, llvm_i8_ty],
2915         [IntrReadArgMem]>;
2916 }
2917
2918 // Misc.
2919 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2920   def int_x86_avx2_pmovmskb : GCCBuiltin<"__builtin_ia32_pmovmskb256">,
2921               Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty], [IntrNoMem]>;
2922   def int_x86_avx2_pshuf_b : GCCBuiltin<"__builtin_ia32_pshufb256">,
2923               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
2924                          llvm_v32i8_ty], [IntrNoMem]>;
2925   def int_x86_avx2_mpsadbw : GCCBuiltin<"__builtin_ia32_mpsadbw256">,
2926               Intrinsic<[llvm_v16i16_ty], [llvm_v32i8_ty, llvm_v32i8_ty,
2927                          llvm_i8_ty], [IntrNoMem, Commutative]>;
2928   def int_x86_avx2_movntdqa : GCCBuiltin<"__builtin_ia32_movntdqa256">,
2929               Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
2930 }
2931
2932 //===----------------------------------------------------------------------===//
2933 // FMA3 and FMA4
2934
2935 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2936   def int_x86_fma_vfmadd_ss : GCCBuiltin<"__builtin_ia32_vfmaddss">,
2937               Intrinsic<[llvm_v4f32_ty],
2938                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2939                         [IntrNoMem]>;
2940   def int_x86_fma_vfmadd_sd : GCCBuiltin<"__builtin_ia32_vfmaddsd">,
2941               Intrinsic<[llvm_v2f64_ty],
2942                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2943                         [IntrNoMem]>;
2944   def int_x86_fma_vfmadd_ps : GCCBuiltin<"__builtin_ia32_vfmaddps">,
2945               Intrinsic<[llvm_v4f32_ty],
2946                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2947                         [IntrNoMem]>;
2948   def int_x86_fma_vfmadd_pd : GCCBuiltin<"__builtin_ia32_vfmaddpd">,
2949               Intrinsic<[llvm_v2f64_ty],
2950                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2951                         [IntrNoMem]>;
2952   def int_x86_fma_vfmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfmaddps256">,
2953               Intrinsic<[llvm_v8f32_ty],
2954                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2955                         [IntrNoMem]>;
2956   def int_x86_fma_vfmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfmaddpd256">,
2957               Intrinsic<[llvm_v4f64_ty],
2958                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
2959                         [IntrNoMem]>;
2960
2961   def int_x86_fma_vfmsub_ss : GCCBuiltin<"__builtin_ia32_vfmsubss">,
2962               Intrinsic<[llvm_v4f32_ty],
2963                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2964                         [IntrNoMem]>;
2965   def int_x86_fma_vfmsub_sd : GCCBuiltin<"__builtin_ia32_vfmsubsd">,
2966               Intrinsic<[llvm_v2f64_ty],
2967                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2968                         [IntrNoMem]>;
2969   def int_x86_fma_vfmsub_ps : GCCBuiltin<"__builtin_ia32_vfmsubps">,
2970               Intrinsic<[llvm_v4f32_ty],
2971                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2972                         [IntrNoMem]>;
2973   def int_x86_fma_vfmsub_pd : GCCBuiltin<"__builtin_ia32_vfmsubpd">,
2974               Intrinsic<[llvm_v2f64_ty],
2975                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2976                         [IntrNoMem]>;
2977   def int_x86_fma_vfmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfmsubps256">,
2978               Intrinsic<[llvm_v8f32_ty],
2979                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2980                         [IntrNoMem]>;
2981   def int_x86_fma_vfmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfmsubpd256">,
2982               Intrinsic<[llvm_v4f64_ty],
2983                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
2984                         [IntrNoMem]>;
2985   def int_x86_fma_vfnmadd_ss : GCCBuiltin<"__builtin_ia32_vfnmaddss">,
2986               Intrinsic<[llvm_v4f32_ty],
2987                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2988                         [IntrNoMem]>;
2989   def int_x86_fma_vfnmadd_sd : GCCBuiltin<"__builtin_ia32_vfnmaddsd">,
2990               Intrinsic<[llvm_v2f64_ty],
2991                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2992                         [IntrNoMem]>;
2993   def int_x86_fma_vfnmadd_ps : GCCBuiltin<"__builtin_ia32_vfnmaddps">,
2994               Intrinsic<[llvm_v4f32_ty],
2995                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2996                         [IntrNoMem]>;
2997   def int_x86_fma_vfnmadd_pd : GCCBuiltin<"__builtin_ia32_vfnmaddpd">,
2998               Intrinsic<[llvm_v2f64_ty],
2999                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3000                         [IntrNoMem]>;
3001   def int_x86_fma_vfnmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmaddps256">,
3002               Intrinsic<[llvm_v8f32_ty],
3003                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
3004                         [IntrNoMem]>;
3005   def int_x86_fma_vfnmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmaddpd256">,
3006               Intrinsic<[llvm_v4f64_ty],
3007                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
3008                         [IntrNoMem]>;
3009   def int_x86_fma_vfnmsub_ss : GCCBuiltin<"__builtin_ia32_vfnmsubss">,
3010               Intrinsic<[llvm_v4f32_ty],
3011                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3012                         [IntrNoMem]>;
3013   def int_x86_fma_vfnmsub_sd : GCCBuiltin<"__builtin_ia32_vfnmsubsd">,
3014               Intrinsic<[llvm_v2f64_ty],
3015                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3016                         [IntrNoMem]>;
3017   def int_x86_fma_vfnmsub_ps : GCCBuiltin<"__builtin_ia32_vfnmsubps">,
3018               Intrinsic<[llvm_v4f32_ty],
3019                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3020                         [IntrNoMem]>;
3021   def int_x86_fma_vfnmsub_pd : GCCBuiltin<"__builtin_ia32_vfnmsubpd">,
3022               Intrinsic<[llvm_v2f64_ty],
3023                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3024                         [IntrNoMem]>;
3025   def int_x86_fma_vfnmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmsubps256">,
3026               Intrinsic<[llvm_v8f32_ty],
3027                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
3028                         [IntrNoMem]>;
3029   def int_x86_fma_vfnmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmsubpd256">,
3030               Intrinsic<[llvm_v4f64_ty],
3031                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
3032                         [IntrNoMem]>;
3033   def int_x86_fma_vfmaddsub_ps : GCCBuiltin<"__builtin_ia32_vfmaddsubps">,
3034               Intrinsic<[llvm_v4f32_ty],
3035                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3036                         [IntrNoMem]>;
3037   def int_x86_fma_vfmaddsub_pd : GCCBuiltin<"__builtin_ia32_vfmaddsubpd">,
3038               Intrinsic<[llvm_v2f64_ty],
3039                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3040                         [IntrNoMem]>;
3041   def int_x86_fma_vfmaddsub_ps_256 :
3042                GCCBuiltin<"__builtin_ia32_vfmaddsubps256">,
3043               Intrinsic<[llvm_v8f32_ty],
3044                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
3045                         [IntrNoMem]>;
3046   def int_x86_fma_vfmaddsub_pd_256 :
3047               GCCBuiltin<"__builtin_ia32_vfmaddsubpd256">,
3048               Intrinsic<[llvm_v4f64_ty],
3049                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
3050                         [IntrNoMem]>;
3051   def int_x86_fma_vfmsubadd_ps : GCCBuiltin<"__builtin_ia32_vfmsubaddps">,
3052               Intrinsic<[llvm_v4f32_ty],
3053                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3054                         [IntrNoMem]>;
3055   def int_x86_fma_vfmsubadd_pd : GCCBuiltin<"__builtin_ia32_vfmsubaddpd">,
3056               Intrinsic<[llvm_v2f64_ty],
3057                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3058                         [IntrNoMem]>;
3059   def int_x86_fma_vfmsubadd_ps_256 :
3060               GCCBuiltin<"__builtin_ia32_vfmsubaddps256">,
3061               Intrinsic<[llvm_v8f32_ty],
3062                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
3063                         [IntrNoMem]>;
3064   def int_x86_fma_vfmsubadd_pd_256 :
3065               GCCBuiltin<"__builtin_ia32_vfmsubaddpd256">,
3066               Intrinsic<[llvm_v4f64_ty],
3067                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
3068                         [IntrNoMem]>;
3069
3070   def int_x86_avx512_mask_vfmadd_pd_128 :
3071          GCCBuiltin<"__builtin_ia32_vfmaddpd128_mask">,
3072           Intrinsic<[llvm_v2f64_ty],
3073           [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,  llvm_i8_ty],
3074           [IntrNoMem]>;
3075
3076   def int_x86_avx512_mask3_vfmadd_pd_128 :
3077          GCCBuiltin<"__builtin_ia32_vfmaddpd128_mask3">,
3078           Intrinsic<[llvm_v2f64_ty],
3079           [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty,  llvm_i8_ty],
3080           [IntrNoMem]>;
3081
3082   def int_x86_avx512_maskz_vfmadd_pd_128 :
3083          GCCBuiltin<"__builtin_ia32_vfmaddpd128_maskz">,
3084           Intrinsic<[