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