[AVX512] add PSHUFD Intrinsic
[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_pshuf_d_128 : 
1511          GCCBuiltin<"__builtin_ia32_pshufd128_mask">,
1512         Intrinsic<[llvm_v4i32_ty],
1513         [llvm_v4i32_ty, llvm_i16_ty, llvm_v4i32_ty, llvm_i8_ty],
1514         [IntrNoMem]>;
1515
1516   def int_x86_avx512_mask_pshuf_d_256 : 
1517          GCCBuiltin<"__builtin_ia32_pshufd256_mask">,
1518         Intrinsic<[llvm_v8i32_ty],
1519         [llvm_v8i32_ty, llvm_i16_ty, llvm_v8i32_ty, llvm_i8_ty],
1520         [IntrNoMem]>;
1521
1522   def int_x86_avx512_mask_pshuf_d_512 : 
1523          GCCBuiltin<"__builtin_ia32_pshufd512_mask">,
1524         Intrinsic<[llvm_v16i32_ty],
1525         [llvm_v16i32_ty, llvm_i16_ty, llvm_v16i32_ty, llvm_i8_ty],
1526         [IntrNoMem]>;
1527
1528   def int_x86_avx512_mask_shuf_f32x4_256 :
1529          GCCBuiltin<"__builtin_ia32_shuf_f32x4_256_mask">,
1530           Intrinsic<[llvm_v8f32_ty],
1531           [llvm_v8f32_ty, llvm_v8f32_ty, llvm_i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1532           [IntrNoMem]>;
1533
1534   def int_x86_avx512_mask_shuf_f32x4 :
1535          GCCBuiltin<"__builtin_ia32_shuf_f32x4_mask">,
1536           Intrinsic<[llvm_v16f32_ty],
1537           [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i16_ty],
1538           [IntrNoMem]>;
1539
1540   def int_x86_avx512_mask_shuf_f64x2_256 :
1541          GCCBuiltin<"__builtin_ia32_shuf_f64x2_256_mask">,
1542           Intrinsic<[llvm_v4f64_ty],
1543           [llvm_v4f64_ty, llvm_v4f64_ty, llvm_i32_ty, llvm_v4f64_ty, llvm_i8_ty],
1544           [IntrNoMem]>;
1545
1546   def int_x86_avx512_mask_shuf_f64x2 :
1547          GCCBuiltin<"__builtin_ia32_shuf_f64x2_mask">,
1548           Intrinsic<[llvm_v8f64_ty],
1549           [llvm_v8f64_ty, llvm_v8f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
1550           [IntrNoMem]>;
1551
1552   def int_x86_avx512_mask_shuf_i32x4_256 :
1553          GCCBuiltin<"__builtin_ia32_shuf_i32x4_256_mask">,
1554           Intrinsic<[llvm_v8i32_ty],
1555           [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i32_ty, llvm_v8i32_ty, llvm_i8_ty],
1556           [IntrNoMem]>;
1557
1558   def int_x86_avx512_mask_shuf_i32x4 :
1559          GCCBuiltin<"__builtin_ia32_shuf_i32x4_mask">,
1560           Intrinsic<[llvm_v16i32_ty],
1561           [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty],
1562           [IntrNoMem]>;
1563
1564   def int_x86_avx512_mask_shuf_i64x2_256 :
1565          GCCBuiltin<"__builtin_ia32_shuf_i64x2_256_mask">,
1566           Intrinsic<[llvm_v4i64_ty],
1567           [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i32_ty, llvm_v4i64_ty, llvm_i8_ty],
1568           [IntrNoMem]>;
1569
1570   def int_x86_avx512_mask_shuf_i64x2 :
1571          GCCBuiltin<"__builtin_ia32_shuf_i64x2_mask">,
1572           Intrinsic<[llvm_v8i64_ty],
1573           [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty],
1574           [IntrNoMem]>;
1575
1576   def int_x86_avx512_mask_shuf_pd_128 :
1577          GCCBuiltin<"__builtin_ia32_shufpd128_mask">,
1578           Intrinsic<[llvm_v2f64_ty],
1579           [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty, llvm_v2f64_ty, llvm_i8_ty],
1580           [IntrNoMem]>;
1581
1582   def int_x86_avx512_mask_shuf_pd_256 :
1583          GCCBuiltin<"__builtin_ia32_shufpd256_mask">,
1584           Intrinsic<[llvm_v4f64_ty],
1585           [llvm_v4f64_ty, llvm_v4f64_ty, llvm_i32_ty, llvm_v4f64_ty, llvm_i8_ty],
1586           [IntrNoMem]>;
1587
1588   def int_x86_avx512_mask_shuf_pd_512 :
1589          GCCBuiltin<"__builtin_ia32_shufpd512_mask">,
1590           Intrinsic<[llvm_v8f64_ty],
1591           [llvm_v8f64_ty, llvm_v8f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
1592           [IntrNoMem]>;
1593
1594   def int_x86_avx512_mask_shuf_ps_128 :
1595          GCCBuiltin<"__builtin_ia32_shufps128_mask">,
1596           Intrinsic<[llvm_v4f32_ty],
1597           [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty, llvm_v4f32_ty, llvm_i8_ty],
1598           [IntrNoMem]>;
1599
1600   def int_x86_avx512_mask_shuf_ps_256 :
1601          GCCBuiltin<"__builtin_ia32_shufps256_mask">,
1602           Intrinsic<[llvm_v8f32_ty],
1603           [llvm_v8f32_ty, llvm_v8f32_ty, llvm_i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1604           [IntrNoMem]>;
1605
1606   def int_x86_avx512_mask_shuf_ps_512 :
1607          GCCBuiltin<"__builtin_ia32_shufps512_mask">,
1608           Intrinsic<[llvm_v16f32_ty],
1609           [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i16_ty],
1610           [IntrNoMem]>;
1611
1612   def int_x86_avx512_mask_movshdup_128 :
1613          GCCBuiltin<"__builtin_ia32_movshdup128_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_movshdup_256 :
1619          GCCBuiltin<"__builtin_ia32_movshdup256_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_movshdup_512 :
1625          GCCBuiltin<"__builtin_ia32_movshdup512_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_movsldup_128 :
1631          GCCBuiltin<"__builtin_ia32_movsldup128_mask">,
1632           Intrinsic<[llvm_v4f32_ty],
1633           [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
1634           [IntrNoMem]>;
1635
1636   def int_x86_avx512_mask_movsldup_256 :
1637          GCCBuiltin<"__builtin_ia32_movsldup256_mask">,
1638           Intrinsic<[llvm_v8f32_ty],
1639           [llvm_v8f32_ty, llvm_v8f32_ty, llvm_i8_ty],
1640           [IntrNoMem]>;
1641
1642   def int_x86_avx512_mask_movsldup_512 :
1643          GCCBuiltin<"__builtin_ia32_movsldup512_mask">,
1644           Intrinsic<[llvm_v16f32_ty],
1645           [llvm_v16f32_ty, llvm_v16f32_ty, llvm_i16_ty],
1646           [IntrNoMem]>;
1647
1648   def int_x86_avx512_mask_movddup_128 :
1649          GCCBuiltin<"__builtin_ia32_movddup128_mask">,
1650           Intrinsic<[llvm_v2f64_ty],
1651           [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
1652           [IntrNoMem]>;
1653
1654   def int_x86_avx512_mask_movddup_256 :
1655          GCCBuiltin<"__builtin_ia32_movddup256_mask">,
1656           Intrinsic<[llvm_v4f64_ty],
1657           [llvm_v4f64_ty, llvm_v4f64_ty, llvm_i8_ty],
1658           [IntrNoMem]>;
1659
1660   def int_x86_avx512_mask_movddup_512 :
1661          GCCBuiltin<"__builtin_ia32_movddup512_mask">,
1662           Intrinsic<[llvm_v8f64_ty],
1663           [llvm_v8f64_ty, llvm_v8f64_ty, llvm_i8_ty],
1664           [IntrNoMem]>;
1665 }
1666
1667 // Vector blend
1668 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1669   def int_x86_avx_blendv_pd_256 : GCCBuiltin<"__builtin_ia32_blendvpd256">,
1670         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1671                   llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>;
1672   def int_x86_avx_blendv_ps_256 : GCCBuiltin<"__builtin_ia32_blendvps256">,
1673         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1674                   llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>;
1675 }
1676
1677 // Vector dot product
1678 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1679   def int_x86_avx_dp_ps_256 : GCCBuiltin<"__builtin_ia32_dpps256">,
1680         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1681                   llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1682 }
1683
1684 // Vector compare
1685 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1686   def int_x86_avx_cmp_pd_256 : GCCBuiltin<"__builtin_ia32_cmppd256">,
1687         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1688                   llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1689   def int_x86_avx_cmp_ps_256 : GCCBuiltin<"__builtin_ia32_cmpps256">,
1690         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1691                   llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1692 }
1693
1694 // Vector convert
1695 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1696   def int_x86_avx_cvtdq2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtdq2pd256">,
1697         Intrinsic<[llvm_v4f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1698   def int_x86_avx_cvtdq2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtdq2ps256">,
1699         Intrinsic<[llvm_v8f32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
1700   def int_x86_avx_cvt_pd2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtpd2ps256">,
1701         Intrinsic<[llvm_v4f32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1702   def int_x86_avx_cvt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvtps2dq256">,
1703         Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1704   def int_x86_avx_cvt_ps2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtps2pd256">,
1705         Intrinsic<[llvm_v4f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1706   def int_x86_avx_cvtt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvttpd2dq256">,
1707         Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1708   def int_x86_avx_cvt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvtpd2dq256">,
1709         Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1710   def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">,
1711         Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1712 }
1713
1714 // Vector bit test
1715 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1716   def int_x86_avx_vtestz_pd : GCCBuiltin<"__builtin_ia32_vtestzpd">,
1717         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1718                   llvm_v2f64_ty], [IntrNoMem]>;
1719   def int_x86_avx_vtestc_pd : GCCBuiltin<"__builtin_ia32_vtestcpd">,
1720         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1721                   llvm_v2f64_ty], [IntrNoMem]>;
1722   def int_x86_avx_vtestnzc_pd : GCCBuiltin<"__builtin_ia32_vtestnzcpd">,
1723         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1724                   llvm_v2f64_ty], [IntrNoMem]>;
1725   def int_x86_avx_vtestz_ps : GCCBuiltin<"__builtin_ia32_vtestzps">,
1726         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1727                   llvm_v4f32_ty], [IntrNoMem]>;
1728   def int_x86_avx_vtestc_ps : GCCBuiltin<"__builtin_ia32_vtestcps">,
1729         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1730                   llvm_v4f32_ty], [IntrNoMem]>;
1731   def int_x86_avx_vtestnzc_ps : GCCBuiltin<"__builtin_ia32_vtestnzcps">,
1732         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1733                   llvm_v4f32_ty], [IntrNoMem]>;
1734   def int_x86_avx_vtestz_pd_256 : GCCBuiltin<"__builtin_ia32_vtestzpd256">,
1735         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1736                   llvm_v4f64_ty], [IntrNoMem]>;
1737   def int_x86_avx_vtestc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestcpd256">,
1738         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1739                   llvm_v4f64_ty], [IntrNoMem]>;
1740   def int_x86_avx_vtestnzc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestnzcpd256">,
1741         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1742                   llvm_v4f64_ty], [IntrNoMem]>;
1743   def int_x86_avx_vtestz_ps_256 : GCCBuiltin<"__builtin_ia32_vtestzps256">,
1744         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1745                   llvm_v8f32_ty], [IntrNoMem]>;
1746   def int_x86_avx_vtestc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestcps256">,
1747         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1748                   llvm_v8f32_ty], [IntrNoMem]>;
1749   def int_x86_avx_vtestnzc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestnzcps256">,
1750         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1751                   llvm_v8f32_ty], [IntrNoMem]>;
1752   def int_x86_avx_ptestz_256 : GCCBuiltin<"__builtin_ia32_ptestz256">,
1753         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1754                   llvm_v4i64_ty], [IntrNoMem]>;
1755   def int_x86_avx_ptestc_256 : GCCBuiltin<"__builtin_ia32_ptestc256">,
1756         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1757                   llvm_v4i64_ty], [IntrNoMem]>;
1758   def int_x86_avx_ptestnzc_256 : GCCBuiltin<"__builtin_ia32_ptestnzc256">,
1759         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1760                   llvm_v4i64_ty], [IntrNoMem]>;
1761   def int_x86_avx512_mask_ptestm_d_512 : GCCBuiltin<"__builtin_ia32_ptestmd512">,
1762         Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
1763                   llvm_i16_ty], [IntrNoMem]>;
1764   def int_x86_avx512_mask_ptestm_q_512 : GCCBuiltin<"__builtin_ia32_ptestmq512">,
1765         Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
1766                   llvm_i8_ty], [IntrNoMem]>;
1767   def int_x86_avx512_mask_fpclass_pd_128 : 
1768          GCCBuiltin<"__builtin_ia32_fpclasspd128_mask">,
1769           Intrinsic<[llvm_i8_ty], [llvm_v2f64_ty, llvm_i32_ty, llvm_i8_ty],
1770           [IntrNoMem]>;
1771   def int_x86_avx512_mask_fpclass_pd_256 : 
1772          GCCBuiltin<"__builtin_ia32_fpclasspd256_mask">,
1773           Intrinsic<[llvm_i8_ty], [llvm_v4f64_ty, llvm_i32_ty, llvm_i8_ty],
1774           [IntrNoMem]>;
1775   def int_x86_avx512_mask_fpclass_pd_512 : 
1776          GCCBuiltin<"__builtin_ia32_fpclasspd512_mask">,
1777           Intrinsic<[llvm_i8_ty], [llvm_v8f64_ty, llvm_i32_ty, llvm_i8_ty],
1778           [IntrNoMem]>;
1779   def int_x86_avx512_mask_fpclass_ps_128 : 
1780          GCCBuiltin<"__builtin_ia32_fpclassps128_mask">,
1781           Intrinsic<[llvm_i8_ty], [llvm_v4f32_ty, llvm_i32_ty, llvm_i8_ty],
1782           [IntrNoMem]>;
1783   def int_x86_avx512_mask_fpclass_ps_256 : 
1784          GCCBuiltin<"__builtin_ia32_fpclassps256_mask">,
1785           Intrinsic<[llvm_i8_ty], [llvm_v8f32_ty, llvm_i32_ty, llvm_i8_ty],
1786           [IntrNoMem]>;
1787   def int_x86_avx512_mask_fpclass_ps_512 : 
1788          GCCBuiltin<"__builtin_ia32_fpclassps512_mask">,
1789           Intrinsic<[llvm_i16_ty], [llvm_v16f32_ty, llvm_i32_ty, llvm_i16_ty],
1790           [IntrNoMem]>;
1791   def int_x86_avx512_mask_fpclass_sd : 
1792          GCCBuiltin<"__builtin_ia32_fpclasssd">,
1793           Intrinsic<[llvm_i8_ty], [llvm_v2f64_ty, llvm_i32_ty, llvm_i8_ty],
1794           [IntrNoMem]>;
1795   def int_x86_avx512_mask_fpclass_ss : 
1796          GCCBuiltin<"__builtin_ia32_fpclassss">,
1797           Intrinsic<[llvm_i8_ty], [llvm_v4f32_ty, llvm_i32_ty, llvm_i8_ty],
1798           [IntrNoMem]>;
1799 }
1800
1801 // Vector extract sign mask
1802 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1803   def int_x86_avx_movmsk_pd_256 : GCCBuiltin<"__builtin_ia32_movmskpd256">,
1804         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1805   def int_x86_avx_movmsk_ps_256 : GCCBuiltin<"__builtin_ia32_movmskps256">,
1806         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1807 }
1808
1809 // Vector zero
1810 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1811   def int_x86_avx_vzeroall : GCCBuiltin<"__builtin_ia32_vzeroall">,
1812         Intrinsic<[], [], []>;
1813   def int_x86_avx_vzeroupper : GCCBuiltin<"__builtin_ia32_vzeroupper">,
1814         Intrinsic<[], [], []>;
1815 }
1816
1817 // Vector load with broadcast
1818 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1819   def int_x86_avx_vbroadcastf128_pd_256 :
1820         GCCBuiltin<"__builtin_ia32_vbroadcastf128_pd256">,
1821         Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1822   def int_x86_avx_vbroadcastf128_ps_256 :
1823         GCCBuiltin<"__builtin_ia32_vbroadcastf128_ps256">,
1824         Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1825 }
1826
1827 // SIMD load ops
1828 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1829   def int_x86_avx_ldu_dq_256 : GCCBuiltin<"__builtin_ia32_lddqu256">,
1830         Intrinsic<[llvm_v32i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
1831 }
1832
1833 // SIMD store ops
1834 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1835   def int_x86_avx_storeu_pd_256 : GCCBuiltin<"__builtin_ia32_storeupd256">,
1836         Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty], [IntrReadWriteArgMem]>;
1837   def int_x86_avx_storeu_ps_256 : GCCBuiltin<"__builtin_ia32_storeups256">,
1838         Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty], [IntrReadWriteArgMem]>;
1839   def int_x86_avx_storeu_dq_256 : GCCBuiltin<"__builtin_ia32_storedqu256">,
1840         Intrinsic<[], [llvm_ptr_ty, llvm_v32i8_ty], [IntrReadWriteArgMem]>;
1841 }
1842
1843 // Conditional load ops
1844 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1845   def int_x86_avx_maskload_pd : GCCBuiltin<"__builtin_ia32_maskloadpd">,
1846         Intrinsic<[llvm_v2f64_ty], [llvm_ptr_ty, llvm_v2i64_ty],
1847                   [IntrReadArgMem]>;
1848   def int_x86_avx_maskload_ps : GCCBuiltin<"__builtin_ia32_maskloadps">,
1849         Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty, llvm_v4i32_ty],
1850                   [IntrReadArgMem]>;
1851   def int_x86_avx_maskload_pd_256 : GCCBuiltin<"__builtin_ia32_maskloadpd256">,
1852         Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty, llvm_v4i64_ty],
1853                   [IntrReadArgMem]>;
1854   def int_x86_avx_maskload_ps_256 : GCCBuiltin<"__builtin_ia32_maskloadps256">,
1855         Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty, llvm_v8i32_ty],
1856                   [IntrReadArgMem]>;
1857   def int_x86_avx512_mask_loadu_ps_512 : GCCBuiltin<"__builtin_ia32_loadups512_mask">,
1858         Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1859                   [IntrReadArgMem]>;
1860   def int_x86_avx512_mask_loadu_pd_512 : GCCBuiltin<"__builtin_ia32_loadupd512_mask">,
1861         Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1862                   [IntrReadArgMem]>;
1863   def int_x86_avx512_mask_load_ps_512 : GCCBuiltin<"__builtin_ia32_loadaps512_mask">,
1864         Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1865                   [IntrReadArgMem]>;
1866   def int_x86_avx512_mask_load_pd_512 : GCCBuiltin<"__builtin_ia32_loadapd512_mask">,
1867         Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1868                   [IntrReadArgMem]>;
1869
1870   def int_x86_avx512_mask_move_ss : GCCBuiltin<"__builtin_ia32_movss_mask">,
1871         Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i8_ty],
1872                   [IntrNoMem]>;
1873   def int_x86_avx512_mask_move_sd : GCCBuiltin<"__builtin_ia32_movsd_mask">,
1874         Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_i8_ty],
1875                   [IntrNoMem]>;
1876 }
1877
1878 // Conditional store ops
1879 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1880   def int_x86_avx_maskstore_pd : GCCBuiltin<"__builtin_ia32_maskstorepd">,
1881         Intrinsic<[], [llvm_ptr_ty,
1882                   llvm_v2i64_ty, llvm_v2f64_ty], [IntrReadWriteArgMem]>;
1883   def int_x86_avx_maskstore_ps : GCCBuiltin<"__builtin_ia32_maskstoreps">,
1884         Intrinsic<[], [llvm_ptr_ty,
1885                   llvm_v4i32_ty, llvm_v4f32_ty], [IntrReadWriteArgMem]>;
1886   def int_x86_avx_maskstore_pd_256 :
1887         GCCBuiltin<"__builtin_ia32_maskstorepd256">,
1888         Intrinsic<[], [llvm_ptr_ty,
1889                   llvm_v4i64_ty, llvm_v4f64_ty], [IntrReadWriteArgMem]>;
1890   def int_x86_avx_maskstore_ps_256 :
1891         GCCBuiltin<"__builtin_ia32_maskstoreps256">,
1892         Intrinsic<[], [llvm_ptr_ty,
1893                   llvm_v8i32_ty, llvm_v8f32_ty], [IntrReadWriteArgMem]>;
1894   def int_x86_avx512_mask_storeu_ps_512 :
1895         GCCBuiltin<"__builtin_ia32_storeups512_mask">,
1896         Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1897                   [IntrReadWriteArgMem]>;
1898   def int_x86_avx512_mask_storeu_pd_512 :
1899         GCCBuiltin<"__builtin_ia32_storeupd512_mask">,
1900         Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1901                   [IntrReadWriteArgMem]>;
1902   def int_x86_avx512_mask_store_ps_512 :
1903         GCCBuiltin<"__builtin_ia32_storeaps512_mask">,
1904         Intrinsic<[], [llvm_ptr_ty, llvm_v16f32_ty, llvm_i16_ty],
1905                   [IntrReadWriteArgMem]>;
1906   def int_x86_avx512_mask_store_pd_512 :
1907         GCCBuiltin<"__builtin_ia32_storeapd512_mask">,
1908         Intrinsic<[], [llvm_ptr_ty, llvm_v8f64_ty, llvm_i8_ty],
1909                   [IntrReadWriteArgMem]>;
1910   def int_x86_avx512_mask_store_ss :
1911         GCCBuiltin<"__builtin_ia32_storess_mask">,
1912         Intrinsic<[], [llvm_ptr_ty, llvm_v4f32_ty, llvm_i8_ty],
1913                   [IntrReadWriteArgMem]>;
1914 }
1915
1916 //===----------------------------------------------------------------------===//
1917 // AVX2
1918
1919 // Integer arithmetic ops.
1920 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1921   def int_x86_avx2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb256">,
1922               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1923                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1924   def int_x86_avx2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw256">,
1925               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1926                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1927   def int_x86_avx2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb256">,
1928               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1929                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1930   def int_x86_avx2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw256">,
1931               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1932                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1933   def int_x86_avx2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb256">,
1934               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1935                          llvm_v32i8_ty], [IntrNoMem]>;
1936   def int_x86_avx2_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw256">,
1937               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1938                          llvm_v16i16_ty], [IntrNoMem]>;
1939   def int_x86_avx2_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb256">,
1940               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1941                          llvm_v32i8_ty], [IntrNoMem]>;
1942   def int_x86_avx2_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw256">,
1943               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1944                          llvm_v16i16_ty], [IntrNoMem]>;
1945   def int_x86_avx2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw256">,
1946               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1947                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1948   def int_x86_avx2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw256">,
1949               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1950                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1951   def int_x86_avx2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq256">,
1952               Intrinsic<[llvm_v4i64_ty], [llvm_v8i32_ty,
1953                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1954   def int_x86_avx2_pmul_dq : GCCBuiltin<"__builtin_ia32_pmuldq256">,
1955               Intrinsic<[llvm_v4i64_ty], [llvm_v8i32_ty,
1956                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1957   def int_x86_avx2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd256">,
1958               Intrinsic<[llvm_v8i32_ty], [llvm_v16i16_ty,
1959                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1960   def int_x86_avx2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb256">,
1961               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1962                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1963   def int_x86_avx2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw256">,
1964               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1965                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1966   def int_x86_avx2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw256">,
1967               Intrinsic<[llvm_v4i64_ty], [llvm_v32i8_ty,
1968                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1969 }
1970
1971 // Vector min, max
1972 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1973   def int_x86_avx2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub256">,
1974               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1975                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1976   def int_x86_avx2_pmaxu_w : GCCBuiltin<"__builtin_ia32_pmaxuw256">,
1977               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1978                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1979   def int_x86_avx2_pmaxu_d : GCCBuiltin<"__builtin_ia32_pmaxud256">,
1980               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1981                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1982   def int_x86_avx2_pmaxs_b : GCCBuiltin<"__builtin_ia32_pmaxsb256">,
1983               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1984                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1985   def int_x86_avx2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw256">,
1986               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1987                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1988   def int_x86_avx2_pmaxs_d : GCCBuiltin<"__builtin_ia32_pmaxsd256">,
1989               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1990                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1991   def int_x86_avx2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub256">,
1992               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1993                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1994   def int_x86_avx2_pminu_w : GCCBuiltin<"__builtin_ia32_pminuw256">,
1995               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1996                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1997   def int_x86_avx2_pminu_d : GCCBuiltin<"__builtin_ia32_pminud256">,
1998               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1999                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
2000   def int_x86_avx2_pmins_b : GCCBuiltin<"__builtin_ia32_pminsb256">,
2001               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
2002                          llvm_v32i8_ty], [IntrNoMem, Commutative]>;
2003   def int_x86_avx2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw256">,
2004               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2005                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
2006   def int_x86_avx2_pmins_d : GCCBuiltin<"__builtin_ia32_pminsd256">,
2007               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2008                          llvm_v8i32_ty], [IntrNoMem, Commutative]>;
2009   def int_x86_avx512_mask_pmaxs_b_128 : GCCBuiltin<"__builtin_ia32_pmaxsb128_mask">,
2010               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, 
2011                          llvm_v16i8_ty, llvm_i16_ty], [IntrNoMem]>;
2012   def int_x86_avx512_mask_pmaxs_b_256 : GCCBuiltin<"__builtin_ia32_pmaxsb256_mask">,
2013               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty, 
2014                          llvm_v32i8_ty,  llvm_i32_ty], [IntrNoMem]>;
2015   def int_x86_avx512_mask_pmaxs_b_512 : GCCBuiltin<"__builtin_ia32_pmaxsb512_mask">,
2016               Intrinsic<[llvm_v64i8_ty], [llvm_v64i8_ty, llvm_v64i8_ty, 
2017                          llvm_v64i8_ty,  llvm_i64_ty], [IntrNoMem]>;
2018   def int_x86_avx512_mask_pmaxu_b_128 : GCCBuiltin<"__builtin_ia32_pmaxub128_mask">,
2019               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, 
2020                          llvm_v16i8_ty, llvm_i16_ty], [IntrNoMem]>;
2021   def int_x86_avx512_mask_pmaxu_b_256 : GCCBuiltin<"__builtin_ia32_pmaxub256_mask">,
2022               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty, 
2023                          llvm_v32i8_ty,  llvm_i32_ty], [IntrNoMem]>;
2024   def int_x86_avx512_mask_pmaxu_b_512 : GCCBuiltin<"__builtin_ia32_pmaxub512_mask">,
2025               Intrinsic<[llvm_v64i8_ty], [llvm_v64i8_ty, llvm_v64i8_ty, 
2026                          llvm_v64i8_ty,  llvm_i64_ty], [IntrNoMem]>;
2027   def int_x86_avx512_mask_pmaxs_w_128 : GCCBuiltin<"__builtin_ia32_pmaxsw128_mask">,
2028               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2029                          llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2030   def int_x86_avx512_mask_pmaxs_w_256 : GCCBuiltin<"__builtin_ia32_pmaxsw256_mask">,
2031               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2032                          llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2033   def int_x86_avx512_mask_pmaxs_w_512 : GCCBuiltin<"__builtin_ia32_pmaxsw512_mask">,
2034               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty, 
2035                    llvm_v32i16_ty,  llvm_i32_ty],[IntrNoMem]>;
2036   def int_x86_avx512_mask_pmaxu_w_128 : GCCBuiltin<"__builtin_ia32_pmaxuw128_mask">,
2037               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2038                          llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2039   def int_x86_avx512_mask_pmaxu_w_256 : GCCBuiltin<"__builtin_ia32_pmaxuw256_mask">,
2040               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2041                          llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2042   def int_x86_avx512_mask_pmaxu_w_512 : GCCBuiltin<"__builtin_ia32_pmaxuw512_mask">,
2043               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty,
2044                          llvm_v32i16_ty,  llvm_i32_ty],[IntrNoMem]>;
2045   def int_x86_avx512_mask_pmins_b_128 : GCCBuiltin<"__builtin_ia32_pminsb128_mask">,
2046               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, 
2047                          llvm_v16i8_ty,llvm_i16_ty], [IntrNoMem]>;
2048   def int_x86_avx512_mask_pmins_b_256 : GCCBuiltin<"__builtin_ia32_pminsb256_mask">,
2049               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty, 
2050                          llvm_v32i8_ty, llvm_i32_ty], [IntrNoMem]>;
2051   def int_x86_avx512_mask_pmins_b_512 : GCCBuiltin<"__builtin_ia32_pminsb512_mask">,
2052               Intrinsic<[llvm_v64i8_ty], [llvm_v64i8_ty, llvm_v64i8_ty,
2053                          llvm_v64i8_ty, llvm_i64_ty], [IntrNoMem]>;
2054   def int_x86_avx512_mask_pminu_b_128 : GCCBuiltin<"__builtin_ia32_pminub128_mask">,
2055               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,
2056                          llvm_v16i8_ty, llvm_i16_ty], [IntrNoMem]>;
2057   def int_x86_avx512_mask_pminu_b_256 : GCCBuiltin<"__builtin_ia32_pminub256_mask">,
2058               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty, 
2059                          llvm_v32i8_ty, llvm_i32_ty], [IntrNoMem]>;
2060   def int_x86_avx512_mask_pminu_b_512 : GCCBuiltin<"__builtin_ia32_pminub512_mask">,
2061               Intrinsic<[llvm_v64i8_ty], [llvm_v64i8_ty, llvm_v64i8_ty, 
2062                          llvm_v64i8_ty,  llvm_i64_ty], [IntrNoMem]>;
2063   def int_x86_avx512_mask_pmins_w_128 : GCCBuiltin<"__builtin_ia32_pminsw128_mask">,
2064               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2065                          llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2066   def int_x86_avx512_mask_pmins_w_256 : GCCBuiltin<"__builtin_ia32_pminsw256_mask">,
2067               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2068                          llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2069   def int_x86_avx512_mask_pmins_w_512 : GCCBuiltin<"__builtin_ia32_pminsw512_mask">,
2070               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty,
2071                          llvm_v32i16_ty,  llvm_i32_ty],[IntrNoMem]>;
2072   def int_x86_avx512_mask_pminu_w_128 : GCCBuiltin<"__builtin_ia32_pminuw128_mask">,
2073               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2074                          llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2075   def int_x86_avx512_mask_pminu_w_256 : GCCBuiltin<"__builtin_ia32_pminuw256_mask">,
2076               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2077                          llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2078   def int_x86_avx512_mask_pminu_w_512 : GCCBuiltin<"__builtin_ia32_pminuw512_mask">,
2079               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty, 
2080                          llvm_v32i16_ty,  llvm_i32_ty], [IntrNoMem]>;
2081   def int_x86_avx512_mask_pmaxu_d_512 : GCCBuiltin<"__builtin_ia32_pmaxud512_mask">,
2082               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
2083                          llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2084   def int_x86_avx512_mask_pmaxu_d_256 : GCCBuiltin<"__builtin_ia32_pmaxud256_mask">,
2085               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
2086                          llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2087   def int_x86_avx512_mask_pmaxu_d_128 : GCCBuiltin<"__builtin_ia32_pmaxud128_mask">,
2088               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2089                          llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2090   def int_x86_avx512_mask_pmaxs_d_512 : GCCBuiltin<"__builtin_ia32_pmaxsd512_mask">,
2091               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
2092                          llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2093   def int_x86_avx512_mask_pmaxs_d_256 : GCCBuiltin<"__builtin_ia32_pmaxsd256_mask">,
2094               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
2095                          llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2096   def int_x86_avx512_mask_pmaxs_d_128 : GCCBuiltin<"__builtin_ia32_pmaxsd128_mask">,
2097               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2098                          llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2099   def int_x86_avx512_mask_pmaxu_q_512 : GCCBuiltin<"__builtin_ia32_pmaxuq512_mask">,
2100               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
2101                          llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2102   def int_x86_avx512_mask_pmaxu_q_256 : GCCBuiltin<"__builtin_ia32_pmaxuq256_mask">,
2103               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
2104                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2105   def int_x86_avx512_mask_pmaxu_q_128 : GCCBuiltin<"__builtin_ia32_pmaxuq128_mask">,
2106               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2107                          llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2108   def int_x86_avx512_mask_pmaxs_q_512 : GCCBuiltin<"__builtin_ia32_pmaxsq512_mask">,
2109               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
2110                          llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2111   def int_x86_avx512_mask_pmaxs_q_256 : GCCBuiltin<"__builtin_ia32_pmaxsq256_mask">,
2112               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
2113                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2114   def int_x86_avx512_mask_pmaxs_q_128 : GCCBuiltin<"__builtin_ia32_pmaxsq128_mask">,
2115               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2116                          llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2117   def int_x86_avx512_mask_pminu_d_512 : GCCBuiltin<"__builtin_ia32_pminud512_mask">,
2118               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
2119                          llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2120   def int_x86_avx512_mask_pminu_d_256 : GCCBuiltin<"__builtin_ia32_pminud256_mask">,
2121               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
2122                          llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2123   def int_x86_avx512_mask_pminu_d_128 : GCCBuiltin<"__builtin_ia32_pminud128_mask">,
2124               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2125                          llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2126   def int_x86_avx512_mask_pmins_d_512 : GCCBuiltin<"__builtin_ia32_pminsd512_mask">,
2127               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty,
2128                          llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2129   def int_x86_avx512_mask_pmins_d_256 : GCCBuiltin<"__builtin_ia32_pminsd256_mask">,
2130               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
2131                          llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2132   def int_x86_avx512_mask_pmins_d_128 : GCCBuiltin<"__builtin_ia32_pminsd128_mask">,
2133               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2134                          llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2135   def int_x86_avx512_mask_pminu_q_512 : GCCBuiltin<"__builtin_ia32_pminuq512_mask">,
2136               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
2137                          llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2138   def int_x86_avx512_mask_pminu_q_256 : GCCBuiltin<"__builtin_ia32_pminuq256_mask">,
2139               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
2140                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2141   def int_x86_avx512_mask_pminu_q_128 : GCCBuiltin<"__builtin_ia32_pminuq128_mask">,
2142               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2143                          llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2144   def int_x86_avx512_mask_pmins_q_512 : GCCBuiltin<"__builtin_ia32_pminsq512_mask">,
2145               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty,
2146                          llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2147   def int_x86_avx512_mask_pmins_q_256 : GCCBuiltin<"__builtin_ia32_pminsq256_mask">,
2148               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty,
2149                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2150   def int_x86_avx512_mask_pmins_q_128 : GCCBuiltin<"__builtin_ia32_pminsq128_mask">,
2151               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2152                          llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2153 }
2154
2155 // Integer shift ops.
2156 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2157   def int_x86_avx2_psll_w : GCCBuiltin<"__builtin_ia32_psllw256">,
2158               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2159                          llvm_v8i16_ty], [IntrNoMem]>;
2160   def int_x86_avx2_psll_d : GCCBuiltin<"__builtin_ia32_pslld256">,
2161               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2162                          llvm_v4i32_ty], [IntrNoMem]>;
2163   def int_x86_avx2_psll_q : GCCBuiltin<"__builtin_ia32_psllq256">,
2164               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2165                          llvm_v2i64_ty], [IntrNoMem]>;
2166   def int_x86_avx2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw256">,
2167               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2168                          llvm_v8i16_ty], [IntrNoMem]>;
2169   def int_x86_avx2_psrl_d : GCCBuiltin<"__builtin_ia32_psrld256">,
2170               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2171                          llvm_v4i32_ty], [IntrNoMem]>;
2172   def int_x86_avx2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq256">,
2173               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2174                          llvm_v2i64_ty], [IntrNoMem]>;
2175   def int_x86_avx2_psra_w : GCCBuiltin<"__builtin_ia32_psraw256">,
2176               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2177                          llvm_v8i16_ty], [IntrNoMem]>;
2178   def int_x86_avx2_psra_d : GCCBuiltin<"__builtin_ia32_psrad256">,
2179               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2180                          llvm_v4i32_ty], [IntrNoMem]>;
2181
2182   def int_x86_avx2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi256">,
2183               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2184                          llvm_i32_ty], [IntrNoMem]>;
2185   def int_x86_avx2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi256">,
2186               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2187                          llvm_i32_ty], [IntrNoMem]>;
2188   def int_x86_avx2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi256">,
2189               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2190                          llvm_i32_ty], [IntrNoMem]>;
2191   def int_x86_avx2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi256">,
2192               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2193                          llvm_i32_ty], [IntrNoMem]>;
2194   def int_x86_avx2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi256">,
2195               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2196                          llvm_i32_ty], [IntrNoMem]>;
2197   def int_x86_avx2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi256">,
2198               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2199                          llvm_i32_ty], [IntrNoMem]>;
2200   def int_x86_avx2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi256">,
2201               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2202                          llvm_i32_ty], [IntrNoMem]>;
2203   def int_x86_avx2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi256">,
2204               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2205                          llvm_i32_ty], [IntrNoMem]>;
2206
2207   def int_x86_avx512_mask_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi512">,
2208               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2209                          llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2210   def int_x86_avx512_mask_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi512">,
2211               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2212                          llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2213   def int_x86_avx512_mask_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi512">,
2214               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2215                          llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2216   def int_x86_avx512_mask_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi512">,
2217               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2218                          llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2219   def int_x86_avx512_mask_psrai_d : GCCBuiltin<"__builtin_ia32_psradi512">,
2220               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2221                          llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2222   def int_x86_avx512_mask_psrai_q : GCCBuiltin<"__builtin_ia32_psraqi512">,
2223               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2224                          llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2225
2226   def int_x86_avx512_mask_psrl_w_128 : GCCBuiltin<"__builtin_ia32_psrlw128_mask">,
2227               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
2228                          llvm_v8i16_ty, llvm_v8i16_ty,  llvm_i8_ty], [IntrNoMem]>;
2229   def int_x86_avx512_mask_psrl_w_256 : GCCBuiltin<"__builtin_ia32_psrlw256_mask">,
2230               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2231                          llvm_v8i16_ty, llvm_v16i16_ty,  llvm_i16_ty], [IntrNoMem]>;
2232   def int_x86_avx512_mask_psrl_w_512 : GCCBuiltin<"__builtin_ia32_psrlw512_mask">,
2233               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty,
2234                          llvm_v8i16_ty, llvm_v32i16_ty,  llvm_i32_ty], [IntrNoMem]>;
2235   def int_x86_avx512_mask_psrl_wi_128 : GCCBuiltin<"__builtin_ia32_psrlwi128_mask">,
2236               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
2237                          llvm_i8_ty, llvm_v8i16_ty,  llvm_i8_ty], [IntrNoMem]>;
2238   def int_x86_avx512_mask_psrl_wi_256 : GCCBuiltin<"__builtin_ia32_psrlwi256_mask">,
2239               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2240                          llvm_i8_ty, llvm_v16i16_ty,  llvm_i16_ty], [IntrNoMem]>;
2241   def int_x86_avx512_mask_psrl_wi_512 : GCCBuiltin<"__builtin_ia32_psrlwi512_mask">,
2242               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty,
2243                          llvm_i8_ty, llvm_v32i16_ty,  llvm_i32_ty], [IntrNoMem]>;
2244
2245   def int_x86_avx512_mask_psra_w_128 : GCCBuiltin<"__builtin_ia32_psraw128_mask">,
2246               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
2247                          llvm_v8i16_ty, llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2248   def int_x86_avx512_mask_psra_w_256 : GCCBuiltin<"__builtin_ia32_psraw256_mask">,
2249               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2250                          llvm_v8i16_ty, llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2251   def int_x86_avx512_mask_psra_w_512 : GCCBuiltin<"__builtin_ia32_psraw512_mask">,
2252               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty,
2253                          llvm_v8i16_ty, llvm_v32i16_ty, llvm_i32_ty], [IntrNoMem]>;
2254   def int_x86_avx512_mask_psra_wi_128 : GCCBuiltin<"__builtin_ia32_psrawi128_mask">,
2255               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
2256                          llvm_i8_ty, llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2257   def int_x86_avx512_mask_psra_wi_256 : GCCBuiltin<"__builtin_ia32_psrawi256_mask">,
2258               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2259                          llvm_i8_ty, llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2260   def int_x86_avx512_mask_psra_wi_512 : GCCBuiltin<"__builtin_ia32_psrawi512_mask">,
2261               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty,
2262                          llvm_i8_ty, llvm_v32i16_ty, llvm_i32_ty], [IntrNoMem]>;
2263
2264   def int_x86_avx512_mask_psll_d : GCCBuiltin<"__builtin_ia32_pslld512_mask">,
2265               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2266                          llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2267   def int_x86_avx512_mask_psll_q : GCCBuiltin<"__builtin_ia32_psllq512_mask">,
2268               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2269                          llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2270   def int_x86_avx512_mask_psrl_d : GCCBuiltin<"__builtin_ia32_psrld512_mask">,
2271               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2272                          llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2273   def int_x86_avx512_mask_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq512_mask">,
2274               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2275                          llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2276   def int_x86_avx512_mask_psra_d : GCCBuiltin<"__builtin_ia32_psrad512_mask">,
2277               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2278                          llvm_v4i32_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2279   def int_x86_avx512_mask_psra_q : GCCBuiltin<"__builtin_ia32_psraq512_mask">,
2280               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2281                          llvm_v2i64_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2282
2283   def int_x86_avx512_mask_psra_d_128 : GCCBuiltin<"__builtin_ia32_psrad128_mask">,
2284               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
2285                          llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2286   def int_x86_avx512_mask_psra_d_256 : GCCBuiltin<"__builtin_ia32_psrad256_mask">,
2287              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2288                          llvm_v4i32_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2289   def int_x86_avx512_mask_psra_di_128 : GCCBuiltin<"__builtin_ia32_psradi128_mask">,
2290               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, 
2291                          llvm_i8_ty, llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2292   def int_x86_avx512_mask_psra_di_256 : GCCBuiltin<"__builtin_ia32_psradi256_mask">,
2293               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2294                         llvm_i8_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2295   def int_x86_avx512_mask_psra_di_512 : GCCBuiltin<"__builtin_ia32_psradi512_mask">,
2296               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2297                          llvm_i8_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2298   def int_x86_avx512_mask_psra_q_128 : GCCBuiltin<"__builtin_ia32_psraq128_mask">,
2299               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, 
2300                          llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2301   def int_x86_avx512_mask_psra_q_256 : GCCBuiltin<"__builtin_ia32_psraq256_mask">,
2302              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2303                          llvm_v2i64_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2304   def int_x86_avx512_mask_psra_qi_128 : GCCBuiltin<"__builtin_ia32_psraqi128_mask">,
2305               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, 
2306                          llvm_i8_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2307   def int_x86_avx512_mask_psra_qi_256 : GCCBuiltin<"__builtin_ia32_psraqi256_mask">,
2308              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2309                          llvm_i8_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2310   def int_x86_avx512_mask_psra_qi_512 : GCCBuiltin<"__builtin_ia32_psraqi512_mask">,
2311               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, 
2312                          llvm_i8_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2313
2314   def int_x86_avx512_mask_psrl_d_128: GCCBuiltin<"__builtin_ia32_psrld128_mask">,
2315               Intrinsic<[llvm_v4i32_ty], [ llvm_v4i32_ty,
2316                          llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty ], [IntrNoMem]>;
2317   def int_x86_avx512_mask_psrl_d_256: GCCBuiltin<"__builtin_ia32_psrld256_mask">,
2318               Intrinsic<[llvm_v8i32_ty], [ llvm_v8i32_ty, 
2319                          llvm_v4i32_ty, llvm_v8i32_ty, llvm_i8_ty ], [IntrNoMem]>;
2320   def int_x86_avx512_mask_psrl_di_128: GCCBuiltin<"__builtin_ia32_psrldi128_mask">,
2321               Intrinsic<[llvm_v4i32_ty], [ llvm_v4i32_ty, 
2322                          llvm_i8_ty, llvm_v4i32_ty, llvm_i8_ty ], [IntrNoMem]>;
2323   def int_x86_avx512_mask_psrl_di_256: GCCBuiltin<"__builtin_ia32_psrldi256_mask">,
2324               Intrinsic<[llvm_v8i32_ty], [ llvm_v8i32_ty, 
2325                          llvm_i8_ty, llvm_v8i32_ty, llvm_i8_ty ], [IntrNoMem]>;
2326   def int_x86_avx512_mask_psrl_di_512: GCCBuiltin<"__builtin_ia32_psrldi512_mask">,
2327               Intrinsic<[llvm_v16i32_ty], [ llvm_v16i32_ty, 
2328                          llvm_i8_ty, llvm_v16i32_ty, llvm_i16_ty ], [IntrNoMem]>;
2329
2330   def int_x86_avx512_mask_psrl_q_128:  GCCBuiltin<"__builtin_ia32_psrlq128_mask">,
2331         Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, 
2332                    llvm_v2i64_ty, llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2333   def int_x86_avx512_mask_psrl_q_256: GCCBuiltin<"__builtin_ia32_psrlq256_mask">,
2334         Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,  
2335                    llvm_v2i64_ty, llvm_v4i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2336   def int_x86_avx512_mask_psrl_qi_128: GCCBuiltin<"__builtin_ia32_psrlqi128_mask">,
2337         Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
2338                    llvm_i8_ty, llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2339   def int_x86_avx512_mask_psrl_qi_256: GCCBuiltin<"__builtin_ia32_psrlqi256_mask">,
2340         Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2341                    llvm_i8_ty, llvm_v4i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2342   def int_x86_avx512_mask_psrl_qi_512: GCCBuiltin<"__builtin_ia32_psrlqi512_mask">,
2343         Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, 
2344                    llvm_i8_ty, llvm_v8i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2345 }
2346
2347 // Pack ops.
2348 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2349   def int_x86_avx2_packsswb : GCCBuiltin<"__builtin_ia32_packsswb256">,
2350               Intrinsic<[llvm_v32i8_ty], [llvm_v16i16_ty,
2351                          llvm_v16i16_ty], [IntrNoMem]>;
2352   def int_x86_avx2_packssdw : GCCBuiltin<"__builtin_ia32_packssdw256">,
2353               Intrinsic<[llvm_v16i16_ty], [llvm_v8i32_ty,
2354                          llvm_v8i32_ty], [IntrNoMem]>;
2355   def int_x86_avx2_packuswb : GCCBuiltin<"__builtin_ia32_packuswb256">,
2356               Intrinsic<[llvm_v32i8_ty], [llvm_v16i16_ty,
2357                          llvm_v16i16_ty], [IntrNoMem]>;
2358   def int_x86_avx2_packusdw : GCCBuiltin<"__builtin_ia32_packusdw256">,
2359               Intrinsic<[llvm_v16i16_ty], [llvm_v8i32_ty,
2360                          llvm_v8i32_ty], [IntrNoMem]>;
2361 }
2362
2363 // Absolute value ops
2364 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2365   def int_x86_avx2_pabs_b : GCCBuiltin<"__builtin_ia32_pabsb256">,
2366               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty], [IntrNoMem]>;
2367   def int_x86_avx2_pabs_w : GCCBuiltin<"__builtin_ia32_pabsw256">,
2368               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty], [IntrNoMem]>;
2369   def int_x86_avx2_pabs_d : GCCBuiltin<"__builtin_ia32_pabsd256">,
2370               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
2371
2372   def int_x86_avx512_mask_pabs_b_128 : 
2373        GCCBuiltin<"__builtin_ia32_pabsb128_mask">,
2374         Intrinsic<[llvm_v16i8_ty],
2375         [llvm_v16i8_ty, llvm_v16i8_ty,  llvm_i16_ty],
2376         [IntrNoMem]>;
2377
2378   def int_x86_avx512_mask_pabs_b_256 : 
2379         GCCBuiltin<"__builtin_ia32_pabsb256_mask">,
2380           Intrinsic<[llvm_v32i8_ty],
2381           [llvm_v32i8_ty, llvm_v32i8_ty,  llvm_i32_ty],
2382           [IntrNoMem]>;
2383
2384   def int_x86_avx512_mask_pabs_b_512 : 
2385         GCCBuiltin<"__builtin_ia32_pabsb512_mask">,
2386           Intrinsic<[llvm_v64i8_ty],
2387           [llvm_v64i8_ty, llvm_v64i8_ty,  llvm_i64_ty],
2388           [IntrNoMem]>;
2389
2390   def int_x86_avx512_mask_pabs_d_128 : 
2391         GCCBuiltin<"__builtin_ia32_pabsd128_mask">,
2392           Intrinsic<[llvm_v4i32_ty],
2393           [llvm_v4i32_ty, llvm_v4i32_ty,  llvm_i8_ty],
2394           [IntrNoMem]>;
2395
2396   def int_x86_avx512_mask_pabs_d_256 : 
2397         GCCBuiltin<"__builtin_ia32_pabsd256_mask">,
2398           Intrinsic<[llvm_v8i32_ty],
2399           [llvm_v8i32_ty, llvm_v8i32_ty,  llvm_i8_ty],
2400           [IntrNoMem]>;
2401
2402   def int_x86_avx512_mask_pabs_d_512 : 
2403         GCCBuiltin<"__builtin_ia32_pabsd512_mask">,
2404           Intrinsic<[llvm_v16i32_ty],
2405           [llvm_v16i32_ty, llvm_v16i32_ty,  llvm_i16_ty],
2406           [IntrNoMem]>;
2407
2408   def int_x86_avx512_mask_pabs_q_128 : 
2409         GCCBuiltin<"__builtin_ia32_pabsq128_mask">,
2410           Intrinsic<[llvm_v2i64_ty],
2411           [llvm_v2i64_ty, llvm_v2i64_ty,  llvm_i8_ty],
2412           [IntrNoMem]>;
2413
2414   def int_x86_avx512_mask_pabs_q_256 : 
2415         GCCBuiltin<"__builtin_ia32_pabsq256_mask">,
2416           Intrinsic<[llvm_v4i64_ty],
2417           [llvm_v4i64_ty, llvm_v4i64_ty,  llvm_i8_ty],
2418           [IntrNoMem]>;
2419
2420   def int_x86_avx512_mask_pabs_q_512 : 
2421         GCCBuiltin<"__builtin_ia32_pabsq512_mask">,
2422           Intrinsic<[llvm_v8i64_ty],
2423           [llvm_v8i64_ty, llvm_v8i64_ty,  llvm_i8_ty],
2424           [IntrNoMem]>;
2425
2426   def int_x86_avx512_mask_pabs_w_128 : 
2427         GCCBuiltin<"__builtin_ia32_pabsw128_mask">,
2428           Intrinsic<[llvm_v8i16_ty],
2429           [llvm_v8i16_ty, llvm_v8i16_ty,  llvm_i8_ty],
2430           [IntrNoMem]>;
2431
2432   def int_x86_avx512_mask_pabs_w_256 : 
2433         GCCBuiltin<"__builtin_ia32_pabsw256_mask">,
2434           Intrinsic<[llvm_v16i16_ty],
2435           [llvm_v16i16_ty, llvm_v16i16_ty,  llvm_i16_ty],
2436           [IntrNoMem]>;
2437
2438   def int_x86_avx512_mask_pabs_w_512 : 
2439         GCCBuiltin<"__builtin_ia32_pabsw512_mask">,
2440           Intrinsic<[llvm_v32i16_ty],
2441           [llvm_v32i16_ty, llvm_v32i16_ty,  llvm_i32_ty],
2442           [IntrNoMem]>;
2443 }
2444
2445 // Horizontal arithmetic ops
2446 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2447   def int_x86_avx2_phadd_w : GCCBuiltin<"__builtin_ia32_phaddw256">,
2448               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2449                          llvm_v16i16_ty], [IntrNoMem]>;
2450   def int_x86_avx2_phadd_d : GCCBuiltin<"__builtin_ia32_phaddd256">,
2451               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2452                          llvm_v8i32_ty], [IntrNoMem]>;
2453   def int_x86_avx2_phadd_sw : GCCBuiltin<"__builtin_ia32_phaddsw256">,
2454               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2455                          llvm_v16i16_ty], [IntrNoMem]>;
2456   def int_x86_avx2_phsub_w : GCCBuiltin<"__builtin_ia32_phsubw256">,
2457               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2458                          llvm_v16i16_ty], [IntrNoMem]>;
2459   def int_x86_avx2_phsub_d : GCCBuiltin<"__builtin_ia32_phsubd256">,
2460               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2461                          llvm_v8i32_ty], [IntrNoMem]>;
2462   def int_x86_avx2_phsub_sw : GCCBuiltin<"__builtin_ia32_phsubsw256">,
2463               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2464                          llvm_v16i16_ty], [IntrNoMem]>;
2465   def int_x86_avx2_pmadd_ub_sw : GCCBuiltin<"__builtin_ia32_pmaddubsw256">,
2466               Intrinsic<[llvm_v16i16_ty], [llvm_v32i8_ty,
2467                          llvm_v32i8_ty], [IntrNoMem]>;
2468 }
2469
2470 // Sign ops
2471 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2472   def int_x86_avx2_psign_b : GCCBuiltin<"__builtin_ia32_psignb256">,
2473               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
2474                          llvm_v32i8_ty], [IntrNoMem]>;
2475   def int_x86_avx2_psign_w : GCCBuiltin<"__builtin_ia32_psignw256">,
2476               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2477                          llvm_v16i16_ty], [IntrNoMem]>;
2478   def int_x86_avx2_psign_d : GCCBuiltin<"__builtin_ia32_psignd256">,
2479               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
2480                          llvm_v8i32_ty], [IntrNoMem]>;
2481 }
2482
2483 // Packed multiply high with round and scale
2484 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2485   def int_x86_avx2_pmul_hr_sw : GCCBuiltin<"__builtin_ia32_pmulhrsw256">,
2486               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2487                          llvm_v16i16_ty], [IntrNoMem, Commutative]>;
2488   def int_x86_avx512_mask_pmul_hr_sw_128 : GCCBuiltin<"__builtin_ia32_pmulhrsw128_mask">,
2489               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, 
2490                      llvm_v8i16_ty, llvm_i8_ty], [IntrNoMem]>;
2491   def int_x86_avx512_mask_pmul_hr_sw_256 : GCCBuiltin<"__builtin_ia32_pmulhrsw256_mask">,
2492               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, 
2493                      llvm_v16i16_ty, llvm_i16_ty], [IntrNoMem]>;
2494   def int_x86_avx512_mask_pmul_hr_sw_512 : GCCBuiltin<"__builtin_ia32_pmulhrsw512_mask">,
2495               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, llvm_v32i16_ty, 
2496                      llvm_v32i16_ty, llvm_i32_ty], [IntrNoMem]>;
2497 }
2498
2499 // Vector sign and zero extend
2500 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2501   def int_x86_avx2_pmovsxbd : GCCBuiltin<"__builtin_ia32_pmovsxbd256">,
2502               Intrinsic<[llvm_v8i32_ty], [llvm_v16i8_ty],
2503                         [IntrNoMem]>;
2504   def int_x86_avx2_pmovsxbq : GCCBuiltin<"__builtin_ia32_pmovsxbq256">,
2505               Intrinsic<[llvm_v4i64_ty], [llvm_v16i8_ty],
2506                         [IntrNoMem]>;
2507   def int_x86_avx2_pmovsxbw : GCCBuiltin<"__builtin_ia32_pmovsxbw256">,
2508               Intrinsic<[llvm_v16i16_ty], [llvm_v16i8_ty],
2509                         [IntrNoMem]>;
2510   def int_x86_avx2_pmovsxdq : GCCBuiltin<"__builtin_ia32_pmovsxdq256">,
2511               Intrinsic<[llvm_v4i64_ty], [llvm_v4i32_ty],
2512                         [IntrNoMem]>;
2513   def int_x86_avx2_pmovsxwd : GCCBuiltin<"__builtin_ia32_pmovsxwd256">,
2514               Intrinsic<[llvm_v8i32_ty], [llvm_v8i16_ty],
2515                         [IntrNoMem]>;
2516   def int_x86_avx2_pmovsxwq : GCCBuiltin<"__builtin_ia32_pmovsxwq256">,
2517               Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty],
2518                         [IntrNoMem]>;
2519   def int_x86_avx2_pmovzxbd : GCCBuiltin<"__builtin_ia32_pmovzxbd256">,
2520               Intrinsic<[llvm_v8i32_ty], [llvm_v16i8_ty],
2521                         [IntrNoMem]>;
2522   def int_x86_avx2_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq256">,
2523               Intrinsic<[llvm_v4i64_ty], [llvm_v16i8_ty],
2524                         [IntrNoMem]>;
2525   def int_x86_avx2_pmovzxbw : GCCBuiltin<"__builtin_ia32_pmovzxbw256">,
2526               Intrinsic<[llvm_v16i16_ty], [llvm_v16i8_ty],
2527                         [IntrNoMem]>;
2528   def int_x86_avx2_pmovzxdq : GCCBuiltin<"__builtin_ia32_pmovzxdq256">,
2529               Intrinsic<[llvm_v4i64_ty], [llvm_v4i32_ty],
2530                         [IntrNoMem]>;
2531   def int_x86_avx2_pmovzxwd : GCCBuiltin<"__builtin_ia32_pmovzxwd256">,
2532               Intrinsic<[llvm_v8i32_ty], [llvm_v8i16_ty],
2533                         [IntrNoMem]>;
2534   def int_x86_avx2_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq256">,
2535               Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty],
2536                         [IntrNoMem]>;
2537 }
2538
2539 // Vector blend
2540 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2541   def int_x86_avx2_pblendvb : GCCBuiltin<"__builtin_ia32_pblendvb256">,
2542               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty,
2543                          llvm_v32i8_ty], [IntrNoMem]>;
2544 }
2545
2546 // Vector load with broadcast
2547 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2548   def int_x86_avx512_mask_pbroadcast_d_gpr_512 :
2549               GCCBuiltin<"__builtin_ia32_pbroadcastd512_gpr_mask">,
2550               Intrinsic<[llvm_v16i32_ty], [llvm_i32_ty, llvm_v16i32_ty,
2551               llvm_i16_ty], [IntrNoMem]>;
2552   def int_x86_avx512_mask_pbroadcast_q_gpr_512 :
2553               GCCBuiltin<"__builtin_ia32_pbroadcastq512_gpr_mask">,
2554               Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty, llvm_v8i64_ty,
2555               llvm_i8_ty], [IntrNoMem]>;
2556   def int_x86_avx512_mask_pbroadcast_q_mem_512 :
2557               GCCBuiltin<"__builtin_ia32_pbroadcastq512_mem_mask">,
2558               Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty, llvm_v8i64_ty,
2559               llvm_i8_ty], [IntrNoMem]>;
2560 }
2561
2562 // Vector permutation
2563 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2564   def int_x86_avx2_permd : GCCBuiltin<"__builtin_ia32_permvarsi256">,
2565               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
2566                         [IntrNoMem]>;
2567   def int_x86_avx2_permps : GCCBuiltin<"__builtin_ia32_permvarsf256">,
2568               Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8i32_ty],
2569                         [IntrNoMem]>;
2570   def int_x86_avx2_vperm2i128 : GCCBuiltin<"__builtin_ia32_permti256">,
2571               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
2572                          llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2573 }
2574
2575 // Vector extract and insert
2576 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2577   def int_x86_avx512_mask_vextractf32x4_512 :
2578       GCCBuiltin<"__builtin_ia32_extractf32x4_mask">,
2579                  Intrinsic<[llvm_v4f32_ty], [llvm_v16f32_ty, llvm_i32_ty,
2580                             llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
2581   def int_x86_avx512_mask_vextracti32x4_512 :
2582       GCCBuiltin<"__builtin_ia32_extracti32x4_mask">,
2583                  Intrinsic<[llvm_v4i32_ty], [llvm_v16i32_ty, llvm_i32_ty,
2584                             llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2585   def int_x86_avx512_mask_vextractf32x4_256 :
2586       GCCBuiltin<"__builtin_ia32_extractf32x4_256_mask">,
2587                  Intrinsic<[llvm_v4f32_ty], [llvm_v8f32_ty, llvm_i32_ty,
2588                             llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
2589   def int_x86_avx512_mask_vextracti32x4_256 :
2590       GCCBuiltin<"__builtin_ia32_extracti32x4_256_mask">,
2591                  Intrinsic<[llvm_v4i32_ty], [llvm_v8i32_ty, llvm_i32_ty,
2592                             llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2593   def int_x86_avx512_mask_vextractf64x2_256 :
2594       GCCBuiltin<"__builtin_ia32_extractf64x2_256_mask">,
2595                  Intrinsic<[llvm_v2f64_ty], [llvm_v4f64_ty, llvm_i32_ty,
2596                             llvm_v2f64_ty,  llvm_i8_ty], [IntrNoMem]>;
2597   def int_x86_avx512_mask_vextracti64x2_256 :
2598       GCCBuiltin<"__builtin_ia32_extracti64x2_256_mask">,
2599                  Intrinsic<[llvm_v2i64_ty], [llvm_v4i64_ty, llvm_i32_ty,
2600                             llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2601   def int_x86_avx512_mask_vextractf64x2_512 :
2602       GCCBuiltin<"__builtin_ia32_extractf64x2_512_mask">,
2603                  Intrinsic<[llvm_v2f64_ty], [llvm_v8f64_ty, llvm_i32_ty,
2604                             llvm_v2f64_ty,  llvm_i8_ty], [IntrNoMem]>;
2605   def int_x86_avx512_mask_vextracti64x2_512 :
2606       GCCBuiltin<"__builtin_ia32_extracti64x2_512_mask">,
2607                  Intrinsic<[llvm_v2i64_ty], [llvm_v8i64_ty, llvm_i32_ty,
2608                             llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2609   def int_x86_avx512_mask_vextractf32x8_512 :
2610       GCCBuiltin<"__builtin_ia32_extractf32x8_mask">,
2611                  Intrinsic<[llvm_v8f32_ty], [llvm_v16f32_ty, llvm_i32_ty,
2612                             llvm_v8f32_ty,  llvm_i8_ty], [IntrNoMem]>;
2613   def int_x86_avx512_mask_vextracti32x8_512 :
2614       GCCBuiltin<"__builtin_ia32_extracti32x8_mask">,
2615                  Intrinsic<[llvm_v8i32_ty],[llvm_v16i32_ty, llvm_i32_ty,
2616                             llvm_v8i32_ty,  llvm_i8_ty], [IntrNoMem]>;
2617   def int_x86_avx512_mask_vextractf64x4_512 :
2618       GCCBuiltin<"__builtin_ia32_extractf64x4_mask">,
2619                  Intrinsic<[llvm_v4f64_ty], [llvm_v8f64_ty, llvm_i32_ty,
2620                             llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
2621   def int_x86_avx512_mask_vextracti64x4_512 :
2622       GCCBuiltin<"__builtin_ia32_extracti64x4_mask">,
2623                  Intrinsic<[llvm_v4i64_ty], [llvm_v8i64_ty, llvm_i32_ty,
2624                             llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2625
2626   def int_x86_avx512_mask_insertf32x4_256 :
2627         GCCBuiltin<"__builtin_ia32_insertf32x4_256_mask">,
2628           Intrinsic<[llvm_v8f32_ty],
2629           [llvm_v8f32_ty, llvm_v4f32_ty, llvm_i32_ty, llvm_v8f32_ty, llvm_i8_ty],
2630           [IntrNoMem]>;
2631
2632   def int_x86_avx512_mask_insertf32x4_512 :
2633         GCCBuiltin<"__builtin_ia32_insertf32x4_512_mask">,
2634           Intrinsic<[llvm_v16f32_ty],
2635           [llvm_v16f32_ty, llvm_v4f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i8_ty],
2636           [IntrNoMem]>;
2637
2638   def int_x86_avx512_mask_insertf32x8_512 :
2639         GCCBuiltin<"__builtin_ia32_insertf32x8_mask">,
2640           Intrinsic<[llvm_v16f32_ty],
2641           [llvm_v16f32_ty, llvm_v8f32_ty, llvm_i32_ty, llvm_v16f32_ty, llvm_i16_ty],
2642           [IntrNoMem]>;
2643
2644   def int_x86_avx512_mask_insertf64x2_256 :
2645         GCCBuiltin<"__builtin_ia32_insertf64x2_256_mask">,
2646           Intrinsic<[llvm_v4f64_ty],
2647           [llvm_v4f64_ty, llvm_v2f64_ty, llvm_i32_ty, llvm_v4f64_ty, llvm_i8_ty],
2648           [IntrNoMem]>;
2649
2650   def int_x86_avx512_mask_insertf64x2_512 :
2651         GCCBuiltin<"__builtin_ia32_insertf64x2_512_mask">,
2652           Intrinsic<[llvm_v8f64_ty],
2653           [llvm_v8f64_ty, llvm_v2f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
2654           [IntrNoMem]>;
2655
2656   def int_x86_avx512_mask_insertf64x4_512 :
2657         GCCBuiltin<"__builtin_ia32_insertf64x4_mask">,
2658           Intrinsic<[llvm_v8f64_ty],
2659           [llvm_v8f64_ty, llvm_v4f64_ty, llvm_i32_ty, llvm_v8f64_ty, llvm_i8_ty],
2660           [IntrNoMem]>;
2661
2662   def int_x86_avx512_mask_inserti32x4_256 :
2663         GCCBuiltin<"__builtin_ia32_inserti32x4_256_mask">,
2664           Intrinsic<[llvm_v8i32_ty],
2665           [llvm_v8i32_ty, llvm_v4i32_ty, llvm_i32_ty, llvm_v8i32_ty, llvm_i8_ty],
2666           [IntrNoMem]>;
2667
2668   def int_x86_avx512_mask_inserti32x4_512 :
2669         GCCBuiltin<"__builtin_ia32_inserti32x4_512_mask">,
2670           Intrinsic<[llvm_v16i32_ty],
2671           [llvm_v16i32_ty, llvm_v4i32_ty, llvm_i32_ty, llvm_v16i32_ty, llvm_i8_ty],
2672           [IntrNoMem]>;
2673
2674   def int_x86_avx512_mask_inserti32x8_512 :
2675         GCCBuiltin<"__builtin_ia32_inserti32x8_mask">,
2676           Intrinsic<[llvm_v16i32_ty],
2677           [llvm_v16i32_ty, llvm_v8i32_ty, llvm_i32_ty, llvm_v16i32_ty, llvm_i16_ty],
2678           [IntrNoMem]>;
2679
2680   def int_x86_avx512_mask_inserti64x2_256 :
2681         GCCBuiltin<"__builtin_ia32_inserti64x2_256_mask">,
2682           Intrinsic<[llvm_v4i64_ty],
2683           [llvm_v4i64_ty, llvm_v2i64_ty, llvm_i32_ty, llvm_v4i64_ty, llvm_i8_ty],
2684           [IntrNoMem]>;
2685
2686   def int_x86_avx512_mask_inserti64x2_512 :
2687         GCCBuiltin<"__builtin_ia32_inserti64x2_512_mask">,
2688           Intrinsic<[llvm_v8i64_ty],
2689           [llvm_v8i64_ty, llvm_v2i64_ty, llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty],
2690           [IntrNoMem]>;
2691
2692   def int_x86_avx512_mask_inserti64x4_512 :
2693         GCCBuiltin<"__builtin_ia32_inserti64x4_mask">,
2694           Intrinsic<[llvm_v8i64_ty],
2695           [llvm_v8i64_ty, llvm_v4i64_ty, llvm_i32_ty, llvm_v8i64_ty, llvm_i8_ty],
2696           [IntrNoMem]>;                            
2697 }
2698
2699 // Conditional load ops
2700 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2701   def int_x86_avx2_maskload_d : GCCBuiltin<"__builtin_ia32_maskloadd">,
2702         Intrinsic<[llvm_v4i32_ty], [llvm_ptr_ty, llvm_v4i32_ty],
2703                   [IntrReadArgMem]>;
2704   def int_x86_avx2_maskload_q : GCCBuiltin<"__builtin_ia32_maskloadq">,
2705         Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_v2i64_ty],
2706                   [IntrReadArgMem]>;
2707   def int_x86_avx2_maskload_d_256 : GCCBuiltin<"__builtin_ia32_maskloadd256">,
2708         Intrinsic<[llvm_v8i32_ty], [llvm_ptr_ty, llvm_v8i32_ty],
2709                   [IntrReadArgMem]>;
2710   def int_x86_avx2_maskload_q_256 : GCCBuiltin<"__builtin_ia32_maskloadq256">,
2711         Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty, llvm_v4i64_ty],
2712                   [IntrReadArgMem]>;
2713   def int_x86_avx512_mask_loadu_d_512 : GCCBuiltin<"__builtin_ia32_loaddqusi512_mask">,
2714         Intrinsic<[llvm_v16i32_ty], [llvm_ptr_ty, llvm_v16i32_ty, llvm_i16_ty],
2715                   [IntrReadArgMem]>;
2716   def int_x86_avx512_mask_loadu_q_512 : GCCBuiltin<"__builtin_ia32_loaddqudi512_mask">,
2717         Intrinsic<[llvm_v8i64_ty], [llvm_ptr_ty, llvm_v8i64_ty, llvm_i8_ty],
2718                   [IntrReadArgMem]>;
2719 }
2720
2721 // Conditional store ops
2722 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2723   def int_x86_avx2_maskstore_d : GCCBuiltin<"__builtin_ia32_maskstored">,
2724         Intrinsic<[], [llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i32_ty],
2725                   [IntrReadWriteArgMem]>;
2726   def int_x86_avx2_maskstore_q : GCCBuiltin<"__builtin_ia32_maskstoreq">,
2727         Intrinsic<[], [llvm_ptr_ty, llvm_v2i64_ty, llvm_v2i64_ty],
2728                   [IntrReadWriteArgMem]>;
2729   def int_x86_avx2_maskstore_d_256 :
2730         GCCBuiltin<"__builtin_ia32_maskstored256">,
2731         Intrinsic<[], [llvm_ptr_ty, llvm_v8i32_ty, llvm_v8i32_ty],
2732                   [IntrReadWriteArgMem]>;
2733   def int_x86_avx2_maskstore_q_256 :
2734         GCCBuiltin<"__builtin_ia32_maskstoreq256">,
2735         Intrinsic<[], [llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i64_ty],
2736                   [IntrReadWriteArgMem]>;
2737   def int_x86_avx512_mask_storeu_d_512 :
2738         GCCBuiltin<"__builtin_ia32_storedqusi512_mask">,
2739         Intrinsic<[], [llvm_ptr_ty, llvm_v16i32_ty, llvm_i16_ty],
2740                   [IntrReadWriteArgMem]>;
2741   def int_x86_avx512_mask_storeu_q_512 :
2742         GCCBuiltin<"__builtin_ia32_storedqudi512_mask">,
2743         Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty, llvm_i8_ty],
2744                   [IntrReadWriteArgMem]>;
2745 }
2746
2747 // Variable bit shift ops
2748 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2749   def int_x86_avx2_psllv_d : GCCBuiltin<"__builtin_ia32_psllv4si">,
2750               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2751                         [IntrNoMem]>;
2752   def int_x86_avx2_psllv_d_256 : GCCBuiltin<"__builtin_ia32_psllv8si">,
2753               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
2754                         [IntrNoMem]>;
2755   def int_x86_avx2_psllv_q : GCCBuiltin<"__builtin_ia32_psllv2di">,
2756               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2757                         [IntrNoMem]>;
2758   def int_x86_avx2_psllv_q_256 : GCCBuiltin<"__builtin_ia32_psllv4di">,
2759               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty],
2760                         [IntrNoMem]>;
2761
2762   def int_x86_avx2_psrlv_d : GCCBuiltin<"__builtin_ia32_psrlv4si">,
2763               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2764                         [IntrNoMem]>;
2765   def int_x86_avx2_psrlv_d_256 : GCCBuiltin<"__builtin_ia32_psrlv8si">,
2766               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
2767                         [IntrNoMem]>;
2768   def int_x86_avx2_psrlv_q : GCCBuiltin<"__builtin_ia32_psrlv2di">,
2769               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2770                         [IntrNoMem]>;
2771   def int_x86_avx2_psrlv_q_256 : GCCBuiltin<"__builtin_ia32_psrlv4di">,
2772               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty],
2773                         [IntrNoMem]>;
2774
2775   def int_x86_avx2_psrav_d : GCCBuiltin<"__builtin_ia32_psrav4si">,
2776               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2777                         [IntrNoMem]>;
2778   def int_x86_avx2_psrav_d_256 : GCCBuiltin<"__builtin_ia32_psrav8si">,
2779               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
2780                         [IntrNoMem]>;
2781
2782   def int_x86_avx512_mask_psllv_d : GCCBuiltin<"__builtin_ia32_psllv16si_mask">,
2783               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2784                          llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
2785                         [IntrNoMem]>;
2786   def int_x86_avx512_mask_psllv_q : GCCBuiltin<"__builtin_ia32_psllv8di_mask">,
2787               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2788                          llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty], 
2789                         [IntrNoMem]>;
2790   def int_x86_avx512_mask_psrav_d : GCCBuiltin<"__builtin_ia32_psrav16si_mask">,
2791               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2792                          llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
2793                         [IntrNoMem]>;
2794   def int_x86_avx512_mask_psrav_q : GCCBuiltin<"__builtin_ia32_psrav8di_mask">,
2795               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2796                          llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty],
2797                         [IntrNoMem]>;
2798   def int_x86_avx512_mask_psrlv_d : GCCBuiltin<"__builtin_ia32_psrlv16si_mask">,
2799               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty,
2800                          llvm_v16i32_ty, llvm_v16i32_ty, llvm_i16_ty],
2801                         [IntrNoMem]>;
2802   def int_x86_avx512_mask_psrlv_q : GCCBuiltin<"__builtin_ia32_psrlv8di_mask">,
2803               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty,
2804                          llvm_v8i64_ty, llvm_v8i64_ty, llvm_i8_ty], 
2805                         [IntrNoMem]>;
2806   def int_x86_avx512_psll_dq_512 : GCCBuiltin<"__builtin_ia32_pslldq512">,
2807               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_i32_ty], 
2808                         [IntrNoMem]>;
2809   def int_x86_avx512_psrl_dq_512 : GCCBuiltin<"__builtin_ia32_psrldq512">,
2810               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_i32_ty], 
2811                         [IntrNoMem]>;                        
2812
2813   def int_x86_avx512_mask_psll_d_128 : GCCBuiltin<"__builtin_ia32_pslld128_mask">,
2814               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
2815                          llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2816   def int_x86_avx512_mask_psll_d_256 : GCCBuiltin<"__builtin_ia32_pslld256_mask">,
2817               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2818                          llvm_v4i32_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2819   def int_x86_avx512_mask_psll_di_128 : GCCBuiltin<"__builtin_ia32_pslldi128_mask">,
2820               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, 
2821                          llvm_i8_ty, llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
2822   def int_x86_avx512_mask_psll_di_256 : GCCBuiltin<"__builtin_ia32_pslldi256_mask">,
2823               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2824                          llvm_i8_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
2825   def int_x86_avx512_mask_psll_di_512 : GCCBuiltin<"__builtin_ia32_pslldi512_mask">,
2826               Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, 
2827                          llvm_i8_ty, llvm_v16i32_ty, llvm_i16_ty], [IntrNoMem]>;
2828   def int_x86_avx512_mask_psll_q_128 : GCCBuiltin<"__builtin_ia32_psllq128_mask">,
2829               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
2830                          llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2831   def int_x86_avx512_mask_psll_q_256 : GCCBuiltin<"__builtin_ia32_psllq256_mask">,
2832               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2833                          llvm_v2i64_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2834   def int_x86_avx512_mask_psll_qi_128 : GCCBuiltin<"__builtin_ia32_psllqi128_mask">,
2835               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, 
2836                          llvm_i8_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
2837   def int_x86_avx512_mask_psll_qi_256 : GCCBuiltin<"__builtin_ia32_psllqi256_mask">,
2838               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2839                          llvm_i8_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
2840   def int_x86_avx512_mask_psll_qi_512 : GCCBuiltin<"__builtin_ia32_psllqi512_mask">,
2841               Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, 
2842                          llvm_i8_ty, llvm_v8i64_ty, llvm_i8_ty], [IntrNoMem]>;
2843
2844   def int_x86_avx512_mask_psrlv16_hi : GCCBuiltin<"__builtin_ia32_psrlv16hi_mask">,
2845               Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
2846                          llvm_v16i16_ty, llvm_v16i16_ty,  llvm_i16_ty], [IntrNoMem]>;
2847   def int_x86_avx512_mask_psrlv2_di : GCCBuiltin<"__builtin_ia32_psrlv2di_mask">,
2848               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
2849                          llvm_v2i64_ty, llvm_v2i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2850   def int_x86_avx512_mask_psrlv32hi : GCCBuiltin<"__builtin_ia32_psrlv32hi_mask">,
2851               Intrinsic<[llvm_v32i16_ty], [llvm_v32i16_ty, 
2852                          llvm_v32i16_ty, llvm_v32i16_ty,  llvm_i32_ty], [IntrNoMem]>;
2853   def int_x86_avx512_mask_psrlv4_di : GCCBuiltin<"__builtin_ia32_psrlv4di_mask">,
2854               Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, 
2855                          llvm_v4i64_ty, llvm_v4i64_ty,  llvm_i8_ty], [IntrNoMem]>;
2856   def int_x86_avx512_mask_psrlv4_si : GCCBuiltin<"__builtin_ia32_psrlv4si_mask">,
2857               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, 
2858                          llvm_v4i32_ty, llvm_v4i32_ty,  llvm_i8_ty], [IntrNoMem]>;
2859   def int_x86_avx512_mask_psrlv8_hi : GCCBuiltin<"__builtin_ia32_psrlv8hi_mask">,
2860               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, 
2861                          llvm_v8i16_ty, llvm_v8i16_ty,  llvm_i8_ty], [IntrNoMem]>;
2862   def int_x86_avx512_mask_psrlv8_si : GCCBuiltin<"__builtin_ia32_psrlv8si_mask">,
2863               Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, 
2864                          llvm_v8i32_ty, llvm_v8i32_ty,  llvm_i8_ty], [IntrNoMem]>;
2865 }
2866
2867 // Gather ops
2868 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2869   def int_x86_avx2_gather_d_pd : GCCBuiltin<"__builtin_ia32_gatherd_pd">,
2870       Intrinsic<[llvm_v2f64_ty],
2871         [llvm_v2f64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v2f64_ty, llvm_i8_ty],
2872         [IntrReadArgMem]>;
2873   def int_x86_avx2_gather_d_pd_256 : GCCBuiltin<"__builtin_ia32_gatherd_pd256">,
2874       Intrinsic<[llvm_v4f64_ty],
2875         [llvm_v4f64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4f64_ty, llvm_i8_ty],
2876         [IntrReadArgMem]>;
2877   def int_x86_avx2_gather_q_pd : GCCBuiltin<"__builtin_ia32_gatherq_pd">,
2878       Intrinsic<[llvm_v2f64_ty],
2879         [llvm_v2f64_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v2f64_ty, llvm_i8_ty],
2880         [IntrReadArgMem]>;
2881   def int_x86_avx2_gather_q_pd_256 : GCCBuiltin<"__builtin_ia32_gatherq_pd256">,
2882       Intrinsic<[llvm_v4f64_ty],
2883         [llvm_v4f64_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4f64_ty, llvm_i8_ty],
2884         [IntrReadArgMem]>;
2885   def int_x86_avx2_gather_d_ps : GCCBuiltin<"__builtin_ia32_gatherd_ps">,
2886       Intrinsic<[llvm_v4f32_ty],
2887         [llvm_v4f32_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4f32_ty, llvm_i8_ty],
2888         [IntrReadArgMem]>;
2889   def int_x86_avx2_gather_d_ps_256 : GCCBuiltin<"__builtin_ia32_gatherd_ps256">,
2890       Intrinsic<[llvm_v8f32_ty],
2891         [llvm_v8f32_ty, llvm_ptr_ty, llvm_v8i32_ty, llvm_v8f32_ty, llvm_i8_ty],
2892         [IntrReadArgMem]>;
2893   def int_x86_avx2_gather_q_ps : GCCBuiltin<"__builtin_ia32_gatherq_ps">,
2894       Intrinsic<[llvm_v4f32_ty],
2895         [llvm_v4f32_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v4f32_ty, llvm_i8_ty],
2896         [IntrReadArgMem]>;
2897   def int_x86_avx2_gather_q_ps_256 : GCCBuiltin<"__builtin_ia32_gatherq_ps256">,
2898       Intrinsic<[llvm_v4f32_ty],
2899         [llvm_v4f32_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4f32_ty, llvm_i8_ty],
2900         [IntrReadArgMem]>;
2901
2902   def int_x86_avx2_gather_d_q : GCCBuiltin<"__builtin_ia32_gatherd_q">,
2903       Intrinsic<[llvm_v2i64_ty],
2904         [llvm_v2i64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v2i64_ty, llvm_i8_ty],
2905         [IntrReadArgMem]>;
2906   def int_x86_avx2_gather_d_q_256 : GCCBuiltin<"__builtin_ia32_gatherd_q256">,
2907       Intrinsic<[llvm_v4i64_ty],
2908         [llvm_v4i64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i64_ty, llvm_i8_ty],
2909         [IntrReadArgMem]>;
2910   def int_x86_avx2_gather_q_q : GCCBuiltin<"__builtin_ia32_gatherq_q">,
2911       Intrinsic<[llvm_v2i64_ty],
2912         [llvm_v2i64_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
2913         [IntrReadArgMem]>;
2914   def int_x86_avx2_gather_q_q_256 : GCCBuiltin<"__builtin_ia32_gatherq_q256">,
2915       Intrinsic<[llvm_v4i64_ty],
2916         [llvm_v4i64_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
2917         [IntrReadArgMem]>;
2918   def int_x86_avx2_gather_d_d : GCCBuiltin<"__builtin_ia32_gatherd_d">,
2919       Intrinsic<[llvm_v4i32_ty],
2920         [llvm_v4i32_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
2921         [IntrReadArgMem]>;
2922   def int_x86_avx2_gather_d_d_256 : GCCBuiltin<"__builtin_ia32_gatherd_d256">,
2923       Intrinsic<[llvm_v8i32_ty],
2924         [llvm_v8i32_ty, llvm_ptr_ty, llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
2925         [IntrReadArgMem]>;
2926   def int_x86_avx2_gather_q_d : GCCBuiltin<"__builtin_ia32_gatherq_d">,
2927       Intrinsic<[llvm_v4i32_ty],
2928         [llvm_v4i32_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v4i32_ty, llvm_i8_ty],
2929         [IntrReadArgMem]>;
2930   def int_x86_avx2_gather_q_d_256 : GCCBuiltin<"__builtin_ia32_gatherq_d256">,
2931       Intrinsic<[llvm_v4i32_ty],
2932         [llvm_v4i32_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i32_ty, llvm_i8_ty],
2933         [IntrReadArgMem]>;
2934 }
2935
2936 // Misc.
2937 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2938   def int_x86_avx2_pmovmskb : GCCBuiltin<"__builtin_ia32_pmovmskb256">,
2939               Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty], [IntrNoMem]>;
2940   def int_x86_avx2_pshuf_b : GCCBuiltin<"__builtin_ia32_pshufb256">,
2941               Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
2942                          llvm_v32i8_ty], [IntrNoMem]>;
2943   def int_x86_avx2_mpsadbw : GCCBuiltin<"__builtin_ia32_mpsadbw256">,
2944               Intrinsic<[llvm_v16i16_ty], [llvm_v32i8_ty, llvm_v32i8_ty,
2945                          llvm_i8_ty], [IntrNoMem, Commutative]>;
2946   def int_x86_avx2_movntdqa : GCCBuiltin<"__builtin_ia32_movntdqa256">,
2947               Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
2948 }
2949
2950 //===----------------------------------------------------------------------===//
2951 // FMA3 and FMA4
2952
2953 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2954   def int_x86_fma_vfmadd_ss : GCCBuiltin<"__builtin_ia32_vfmaddss">,
2955               Intrinsic<[llvm_v4f32_ty],
2956                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2957                         [IntrNoMem]>;
2958   def int_x86_fma_vfmadd_sd : GCCBuiltin<"__builtin_ia32_vfmaddsd">,
2959               Intrinsic<[llvm_v2f64_ty],
2960                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2961                         [IntrNoMem]>;
2962   def int_x86_fma_vfmadd_ps : GCCBuiltin<"__builtin_ia32_vfmaddps">,
2963               Intrinsic<[llvm_v4f32_ty],
2964                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2965                         [IntrNoMem]>;
2966   def int_x86_fma_vfmadd_pd : GCCBuiltin<"__builtin_ia32_vfmaddpd">,
2967               Intrinsic<[llvm_v2f64_ty],
2968                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2969                         [IntrNoMem]>;
2970   def int_x86_fma_vfmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfmaddps256">,
2971               Intrinsic<[llvm_v8f32_ty],
2972                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2973                         [IntrNoMem]>;
2974   def int_x86_fma_vfmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfmaddpd256">,
2975               Intrinsic<[llvm_v4f64_ty],
2976                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
2977                         [IntrNoMem]>;
2978
2979   def int_x86_fma_vfmsub_ss : GCCBuiltin<"__builtin_ia32_vfmsubss">,
2980               Intrinsic<[llvm_v4f32_ty],
2981                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2982                         [IntrNoMem]>;
2983   def int_x86_fma_vfmsub_sd : GCCBuiltin<"__builtin_ia32_vfmsubsd">,
2984               Intrinsic<[llvm_v2f64_ty],
2985                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2986                         [IntrNoMem]>;
2987   def int_x86_fma_vfmsub_ps : GCCBuiltin<"__builtin_ia32_vfmsubps">,
2988               Intrinsic<[llvm_v4f32_ty],
2989                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
2990                         [IntrNoMem]>;
2991   def int_x86_fma_vfmsub_pd : GCCBuiltin<"__builtin_ia32_vfmsubpd">,
2992               Intrinsic<[llvm_v2f64_ty],
2993                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
2994                         [IntrNoMem]>;
2995   def int_x86_fma_vfmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfmsubps256">,
2996               Intrinsic<[llvm_v8f32_ty],
2997                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
2998                         [IntrNoMem]>;
2999   def int_x86_fma_vfmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfmsubpd256">,
3000               Intrinsic<[llvm_v4f64_ty],
3001                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
3002                         [IntrNoMem]>;
3003   def int_x86_fma_vfnmadd_ss : GCCBuiltin<"__builtin_ia32_vfnmaddss">,
3004               Intrinsic<[llvm_v4f32_ty],
3005                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3006                         [IntrNoMem]>;
3007   def int_x86_fma_vfnmadd_sd : GCCBuiltin<"__builtin_ia32_vfnmaddsd">,
3008               Intrinsic<[llvm_v2f64_ty],
3009                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3010                         [IntrNoMem]>;
3011   def int_x86_fma_vfnmadd_ps : GCCBuiltin<"__builtin_ia32_vfnmaddps">,
3012               Intrinsic<[llvm_v4f32_ty],
3013                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3014                         [IntrNoMem]>;
3015   def int_x86_fma_vfnmadd_pd : GCCBuiltin<"__builtin_ia32_vfnmaddpd">,
3016               Intrinsic<[llvm_v2f64_ty],
3017                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3018                         [IntrNoMem]>;
3019   def int_x86_fma_vfnmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmaddps256">,
3020               Intrinsic<[llvm_v8f32_ty],
3021                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
3022                         [IntrNoMem]>;
3023   def int_x86_fma_vfnmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmaddpd256">,
3024               Intrinsic<[llvm_v4f64_ty],
3025                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
3026                         [IntrNoMem]>;
3027   def int_x86_fma_vfnmsub_ss : GCCBuiltin<"__builtin_ia32_vfnmsubss">,
3028               Intrinsic<[llvm_v4f32_ty],
3029                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3030                         [IntrNoMem]>;
3031   def int_x86_fma_vfnmsub_sd : GCCBuiltin<"__builtin_ia32_vfnmsubsd">,
3032               Intrinsic<[llvm_v2f64_ty],
3033                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3034                         [IntrNoMem]>;
3035   def int_x86_fma_vfnmsub_ps : GCCBuiltin<"__builtin_ia32_vfnmsubps">,
3036               Intrinsic<[llvm_v4f32_ty],
3037                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3038                         [IntrNoMem]>;
3039   def int_x86_fma_vfnmsub_pd : GCCBuiltin<"__builtin_ia32_vfnmsubpd">,
3040               Intrinsic<[llvm_v2f64_ty],
3041                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3042                         [IntrNoMem]>;
3043   def int_x86_fma_vfnmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmsubps256">,
3044               Intrinsic<[llvm_v8f32_ty],
3045                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
3046                         [IntrNoMem]>;
3047   def int_x86_fma_vfnmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmsubpd256">,
3048               Intrinsic<[llvm_v4f64_ty],
3049                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
3050                         [IntrNoMem]>;
3051   def int_x86_fma_vfmaddsub_ps : GCCBuiltin<"__builtin_ia32_vfmaddsubps">,
3052               Intrinsic<[llvm_v4f32_ty],
3053                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3054                         [IntrNoMem]>;
3055   def int_x86_fma_vfmaddsub_pd : GCCBuiltin<"__builtin_ia32_vfmaddsubpd">,
3056               Intrinsic<[llvm_v2f64_ty],
3057                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3058                         [IntrNoMem]>;
3059   def int_x86_fma_vfmaddsub_ps_256 :
3060                GCCBuiltin<"__builtin_ia32_vfmaddsubps256">,
3061               Intrinsic<[llvm_v8f32_ty],
3062                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
3063                         [IntrNoMem]>;
3064   def int_x86_fma_vfmaddsub_pd_256 :
3065               GCCBuiltin<"__builtin_ia32_vfmaddsubpd256">,
3066               Intrinsic<[llvm_v4f64_ty],
3067                         [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
3068                         [IntrNoMem]>;
3069   def int_x86_fma_vfmsubadd_ps : GCCBuiltin<"__builtin_ia32_vfmsubaddps">,
3070               Intrinsic<[llvm_v4f32_ty],
3071                         [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
3072                         [IntrNoMem]>;
3073   def int_x86_fma_vfmsubadd_pd : GCCBuiltin<"__builtin_ia32_vfmsubaddpd">,
3074               Intrinsic<[llvm_v2f64_ty],
3075                         [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
3076                         [IntrNoMem]>;
3077   def int_x86_fma_vfmsubadd_ps_256 :
3078               GCCBuiltin<"__builtin_ia32_vfmsubaddps256">,
3079               Intrinsic<[llvm_v8f32_ty],
3080                         [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
3081                         [IntrNoMem]>;
3082   def int_x86_fma_vfmsubadd_pd_256 :
3083               GCCBuiltin<"__builtin_ia32_vfmsubaddpd256">,
3084               Intrinsic<[llvm_v4f64_ty],
3085