]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/Headers/emmintrin.h
Import DTS files from Linux 4.18
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / Headers / emmintrin.h
1 /*===---- emmintrin.h - SSE2 intrinsics ------------------------------------===
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19  * THE SOFTWARE.
20  *
21  *===-----------------------------------------------------------------------===
22  */
23
24 #ifndef __EMMINTRIN_H
25 #define __EMMINTRIN_H
26
27 #include <xmmintrin.h>
28
29 typedef double __m128d __attribute__((__vector_size__(16)));
30 typedef long long __m128i __attribute__((__vector_size__(16)));
31
32 /* Type defines.  */
33 typedef double __v2df __attribute__ ((__vector_size__ (16)));
34 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
35 typedef short __v8hi __attribute__((__vector_size__(16)));
36 typedef char __v16qi __attribute__((__vector_size__(16)));
37
38 /* Unsigned types */
39 typedef unsigned long long __v2du __attribute__ ((__vector_size__ (16)));
40 typedef unsigned short __v8hu __attribute__((__vector_size__(16)));
41 typedef unsigned char __v16qu __attribute__((__vector_size__(16)));
42
43 /* We need an explicitly signed variant for char. Note that this shouldn't
44  * appear in the interface though. */
45 typedef signed char __v16qs __attribute__((__vector_size__(16)));
46
47 #include <f16cintrin.h>
48
49 /* Define the default attributes for the functions in this file. */
50 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2")))
51
52 /// \brief Adds lower double-precision values in both operands and returns the
53 ///    sum in the lower 64 bits of the result. The upper 64 bits of the result
54 ///    are copied from the upper double-precision value of the first operand.
55 ///
56 /// \headerfile <x86intrin.h>
57 ///
58 /// This intrinsic corresponds to the <c> VADDSD / ADDSD </c> instruction.
59 ///
60 /// \param __a
61 ///    A 128-bit vector of [2 x double] containing one of the source operands.
62 /// \param __b
63 ///    A 128-bit vector of [2 x double] containing one of the source operands.
64 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
65 ///    sum of the lower 64 bits of both operands. The upper 64 bits are copied
66 ///    from the upper 64 bits of the first source operand.
67 static __inline__ __m128d __DEFAULT_FN_ATTRS
68 _mm_add_sd(__m128d __a, __m128d __b)
69 {
70   __a[0] += __b[0];
71   return __a;
72 }
73
74 /// \brief Adds two 128-bit vectors of [2 x double].
75 ///
76 /// \headerfile <x86intrin.h>
77 ///
78 /// This intrinsic corresponds to the <c> VADDPD / ADDPD </c> instruction.
79 ///
80 /// \param __a
81 ///    A 128-bit vector of [2 x double] containing one of the source operands.
82 /// \param __b
83 ///    A 128-bit vector of [2 x double] containing one of the source operands.
84 /// \returns A 128-bit vector of [2 x double] containing the sums of both
85 ///    operands.
86 static __inline__ __m128d __DEFAULT_FN_ATTRS
87 _mm_add_pd(__m128d __a, __m128d __b)
88 {
89   return (__m128d)((__v2df)__a + (__v2df)__b);
90 }
91
92 /// \brief Subtracts the lower double-precision value of the second operand
93 ///    from the lower double-precision value of the first operand and returns
94 ///    the difference in the lower 64 bits of the result. The upper 64 bits of
95 ///    the result are copied from the upper double-precision value of the first
96 ///    operand.
97 ///
98 /// \headerfile <x86intrin.h>
99 ///
100 /// This intrinsic corresponds to the <c> VSUBSD / SUBSD </c> instruction.
101 ///
102 /// \param __a
103 ///    A 128-bit vector of [2 x double] containing the minuend.
104 /// \param __b
105 ///    A 128-bit vector of [2 x double] containing the subtrahend.
106 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
107 ///    difference of the lower 64 bits of both operands. The upper 64 bits are
108 ///    copied from the upper 64 bits of the first source operand.
109 static __inline__ __m128d __DEFAULT_FN_ATTRS
110 _mm_sub_sd(__m128d __a, __m128d __b)
111 {
112   __a[0] -= __b[0];
113   return __a;
114 }
115
116 /// \brief Subtracts two 128-bit vectors of [2 x double].
117 ///
118 /// \headerfile <x86intrin.h>
119 ///
120 /// This intrinsic corresponds to the <c> VSUBPD / SUBPD </c> instruction.
121 ///
122 /// \param __a
123 ///    A 128-bit vector of [2 x double] containing the minuend.
124 /// \param __b
125 ///    A 128-bit vector of [2 x double] containing the subtrahend.
126 /// \returns A 128-bit vector of [2 x double] containing the differences between
127 ///    both operands.
128 static __inline__ __m128d __DEFAULT_FN_ATTRS
129 _mm_sub_pd(__m128d __a, __m128d __b)
130 {
131   return (__m128d)((__v2df)__a - (__v2df)__b);
132 }
133
134 /// \brief Multiplies lower double-precision values in both operands and returns
135 ///    the product in the lower 64 bits of the result. The upper 64 bits of the
136 ///    result are copied from the upper double-precision value of the first
137 ///    operand.
138 ///
139 /// \headerfile <x86intrin.h>
140 ///
141 /// This intrinsic corresponds to the <c> VMULSD / MULSD </c> instruction.
142 ///
143 /// \param __a
144 ///    A 128-bit vector of [2 x double] containing one of the source operands.
145 /// \param __b
146 ///    A 128-bit vector of [2 x double] containing one of the source operands.
147 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
148 ///    product of the lower 64 bits of both operands. The upper 64 bits are
149 ///    copied from the upper 64 bits of the first source operand.
150 static __inline__ __m128d __DEFAULT_FN_ATTRS
151 _mm_mul_sd(__m128d __a, __m128d __b)
152 {
153   __a[0] *= __b[0];
154   return __a;
155 }
156
157 /// \brief Multiplies two 128-bit vectors of [2 x double].
158 ///
159 /// \headerfile <x86intrin.h>
160 ///
161 /// This intrinsic corresponds to the <c> VMULPD / MULPD </c> instruction.
162 ///
163 /// \param __a
164 ///    A 128-bit vector of [2 x double] containing one of the operands.
165 /// \param __b
166 ///    A 128-bit vector of [2 x double] containing one of the operands.
167 /// \returns A 128-bit vector of [2 x double] containing the products of both
168 ///    operands.
169 static __inline__ __m128d __DEFAULT_FN_ATTRS
170 _mm_mul_pd(__m128d __a, __m128d __b)
171 {
172   return (__m128d)((__v2df)__a * (__v2df)__b);
173 }
174
175 /// \brief Divides the lower double-precision value of the first operand by the
176 ///    lower double-precision value of the second operand and returns the
177 ///    quotient in the lower 64 bits of the result. The upper 64 bits of the
178 ///    result are copied from the upper double-precision value of the first
179 ///    operand.
180 ///
181 /// \headerfile <x86intrin.h>
182 ///
183 /// This intrinsic corresponds to the <c> VDIVSD / DIVSD </c> instruction.
184 ///
185 /// \param __a
186 ///    A 128-bit vector of [2 x double] containing the dividend.
187 /// \param __b
188 ///    A 128-bit vector of [2 x double] containing divisor.
189 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
190 ///    quotient of the lower 64 bits of both operands. The upper 64 bits are
191 ///    copied from the upper 64 bits of the first source operand.
192 static __inline__ __m128d __DEFAULT_FN_ATTRS
193 _mm_div_sd(__m128d __a, __m128d __b)
194 {
195   __a[0] /= __b[0];
196   return __a;
197 }
198
199 /// \brief Performs an element-by-element division of two 128-bit vectors of
200 ///    [2 x double].
201 ///
202 /// \headerfile <x86intrin.h>
203 ///
204 /// This intrinsic corresponds to the <c> VDIVPD / DIVPD </c> instruction.
205 ///
206 /// \param __a
207 ///    A 128-bit vector of [2 x double] containing the dividend.
208 /// \param __b
209 ///    A 128-bit vector of [2 x double] containing the divisor.
210 /// \returns A 128-bit vector of [2 x double] containing the quotients of both
211 ///    operands.
212 static __inline__ __m128d __DEFAULT_FN_ATTRS
213 _mm_div_pd(__m128d __a, __m128d __b)
214 {
215   return (__m128d)((__v2df)__a / (__v2df)__b);
216 }
217
218 /// \brief Calculates the square root of the lower double-precision value of
219 ///    the second operand and returns it in the lower 64 bits of the result.
220 ///    The upper 64 bits of the result are copied from the upper
221 ///    double-precision value of the first operand.
222 ///
223 /// \headerfile <x86intrin.h>
224 ///
225 /// This intrinsic corresponds to the <c> VSQRTSD / SQRTSD </c> instruction.
226 ///
227 /// \param __a
228 ///    A 128-bit vector of [2 x double] containing one of the operands. The
229 ///    upper 64 bits of this operand are copied to the upper 64 bits of the
230 ///    result.
231 /// \param __b
232 ///    A 128-bit vector of [2 x double] containing one of the operands. The
233 ///    square root is calculated using the lower 64 bits of this operand.
234 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
235 ///    square root of the lower 64 bits of operand \a __b, and whose upper 64
236 ///    bits are copied from the upper 64 bits of operand \a __a.
237 static __inline__ __m128d __DEFAULT_FN_ATTRS
238 _mm_sqrt_sd(__m128d __a, __m128d __b)
239 {
240   __m128d __c = __builtin_ia32_sqrtsd((__v2df)__b);
241   return (__m128d) { __c[0], __a[1] };
242 }
243
244 /// \brief Calculates the square root of the each of two values stored in a
245 ///    128-bit vector of [2 x double].
246 ///
247 /// \headerfile <x86intrin.h>
248 ///
249 /// This intrinsic corresponds to the <c> VSQRTPD / SQRTPD </c> instruction.
250 ///
251 /// \param __a
252 ///    A 128-bit vector of [2 x double].
253 /// \returns A 128-bit vector of [2 x double] containing the square roots of the
254 ///    values in the operand.
255 static __inline__ __m128d __DEFAULT_FN_ATTRS
256 _mm_sqrt_pd(__m128d __a)
257 {
258   return __builtin_ia32_sqrtpd((__v2df)__a);
259 }
260
261 /// \brief Compares lower 64-bit double-precision values of both operands, and
262 ///    returns the lesser of the pair of values in the lower 64-bits of the
263 ///    result. The upper 64 bits of the result are copied from the upper
264 ///    double-precision value of the first operand.
265 ///
266 /// \headerfile <x86intrin.h>
267 ///
268 /// This intrinsic corresponds to the <c> VMINSD / MINSD </c> instruction.
269 ///
270 /// \param __a
271 ///    A 128-bit vector of [2 x double] containing one of the operands. The
272 ///    lower 64 bits of this operand are used in the comparison.
273 /// \param __b
274 ///    A 128-bit vector of [2 x double] containing one of the operands. The
275 ///    lower 64 bits of this operand are used in the comparison.
276 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
277 ///    minimum value between both operands. The upper 64 bits are copied from
278 ///    the upper 64 bits of the first source operand.
279 static __inline__ __m128d __DEFAULT_FN_ATTRS
280 _mm_min_sd(__m128d __a, __m128d __b)
281 {
282   return __builtin_ia32_minsd((__v2df)__a, (__v2df)__b);
283 }
284
285 /// \brief Performs element-by-element comparison of the two 128-bit vectors of
286 ///    [2 x double] and returns the vector containing the lesser of each pair of
287 ///    values.
288 ///
289 /// \headerfile <x86intrin.h>
290 ///
291 /// This intrinsic corresponds to the <c> VMINPD / MINPD </c> instruction.
292 ///
293 /// \param __a
294 ///    A 128-bit vector of [2 x double] containing one of the operands.
295 /// \param __b
296 ///    A 128-bit vector of [2 x double] containing one of the operands.
297 /// \returns A 128-bit vector of [2 x double] containing the minimum values
298 ///    between both operands.
299 static __inline__ __m128d __DEFAULT_FN_ATTRS
300 _mm_min_pd(__m128d __a, __m128d __b)
301 {
302   return __builtin_ia32_minpd((__v2df)__a, (__v2df)__b);
303 }
304
305 /// \brief Compares lower 64-bit double-precision values of both operands, and
306 ///    returns the greater of the pair of values in the lower 64-bits of the
307 ///    result. The upper 64 bits of the result are copied from the upper
308 ///    double-precision value of the first operand.
309 ///
310 /// \headerfile <x86intrin.h>
311 ///
312 /// This intrinsic corresponds to the <c> VMAXSD / MAXSD </c> instruction.
313 ///
314 /// \param __a
315 ///    A 128-bit vector of [2 x double] containing one of the operands. The
316 ///    lower 64 bits of this operand are used in the comparison.
317 /// \param __b
318 ///    A 128-bit vector of [2 x double] containing one of the operands. The
319 ///    lower 64 bits of this operand are used in the comparison.
320 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
321 ///    maximum value between both operands. The upper 64 bits are copied from
322 ///    the upper 64 bits of the first source operand.
323 static __inline__ __m128d __DEFAULT_FN_ATTRS
324 _mm_max_sd(__m128d __a, __m128d __b)
325 {
326   return __builtin_ia32_maxsd((__v2df)__a, (__v2df)__b);
327 }
328
329 /// \brief Performs element-by-element comparison of the two 128-bit vectors of
330 ///    [2 x double] and returns the vector containing the greater of each pair
331 ///    of values.
332 ///
333 /// \headerfile <x86intrin.h>
334 ///
335 /// This intrinsic corresponds to the <c> VMAXPD / MAXPD </c> instruction.
336 ///
337 /// \param __a
338 ///    A 128-bit vector of [2 x double] containing one of the operands.
339 /// \param __b
340 ///    A 128-bit vector of [2 x double] containing one of the operands.
341 /// \returns A 128-bit vector of [2 x double] containing the maximum values
342 ///    between both operands.
343 static __inline__ __m128d __DEFAULT_FN_ATTRS
344 _mm_max_pd(__m128d __a, __m128d __b)
345 {
346   return __builtin_ia32_maxpd((__v2df)__a, (__v2df)__b);
347 }
348
349 /// \brief Performs a bitwise AND of two 128-bit vectors of [2 x double].
350 ///
351 /// \headerfile <x86intrin.h>
352 ///
353 /// This intrinsic corresponds to the <c> VPAND / PAND </c> instruction.
354 ///
355 /// \param __a
356 ///    A 128-bit vector of [2 x double] containing one of the source operands.
357 /// \param __b
358 ///    A 128-bit vector of [2 x double] containing one of the source operands.
359 /// \returns A 128-bit vector of [2 x double] containing the bitwise AND of the
360 ///    values between both operands.
361 static __inline__ __m128d __DEFAULT_FN_ATTRS
362 _mm_and_pd(__m128d __a, __m128d __b)
363 {
364   return (__m128d)((__v2du)__a & (__v2du)__b);
365 }
366
367 /// \brief Performs a bitwise AND of two 128-bit vectors of [2 x double], using
368 ///    the one's complement of the values contained in the first source operand.
369 ///
370 /// \headerfile <x86intrin.h>
371 ///
372 /// This intrinsic corresponds to the <c> VPANDN / PANDN </c> instruction.
373 ///
374 /// \param __a
375 ///    A 128-bit vector of [2 x double] containing the left source operand. The
376 ///    one's complement of this value is used in the bitwise AND.
377 /// \param __b
378 ///    A 128-bit vector of [2 x double] containing the right source operand.
379 /// \returns A 128-bit vector of [2 x double] containing the bitwise AND of the
380 ///    values in the second operand and the one's complement of the first
381 ///    operand.
382 static __inline__ __m128d __DEFAULT_FN_ATTRS
383 _mm_andnot_pd(__m128d __a, __m128d __b)
384 {
385   return (__m128d)(~(__v2du)__a & (__v2du)__b);
386 }
387
388 /// \brief Performs a bitwise OR of two 128-bit vectors of [2 x double].
389 ///
390 /// \headerfile <x86intrin.h>
391 ///
392 /// This intrinsic corresponds to the <c> VPOR / POR </c> instruction.
393 ///
394 /// \param __a
395 ///    A 128-bit vector of [2 x double] containing one of the source operands.
396 /// \param __b
397 ///    A 128-bit vector of [2 x double] containing one of the source operands.
398 /// \returns A 128-bit vector of [2 x double] containing the bitwise OR of the
399 ///    values between both operands.
400 static __inline__ __m128d __DEFAULT_FN_ATTRS
401 _mm_or_pd(__m128d __a, __m128d __b)
402 {
403   return (__m128d)((__v2du)__a | (__v2du)__b);
404 }
405
406 /// \brief Performs a bitwise XOR of two 128-bit vectors of [2 x double].
407 ///
408 /// \headerfile <x86intrin.h>
409 ///
410 /// This intrinsic corresponds to the <c> VPXOR / PXOR </c> instruction.
411 ///
412 /// \param __a
413 ///    A 128-bit vector of [2 x double] containing one of the source operands.
414 /// \param __b
415 ///    A 128-bit vector of [2 x double] containing one of the source operands.
416 /// \returns A 128-bit vector of [2 x double] containing the bitwise XOR of the
417 ///    values between both operands.
418 static __inline__ __m128d __DEFAULT_FN_ATTRS
419 _mm_xor_pd(__m128d __a, __m128d __b)
420 {
421   return (__m128d)((__v2du)__a ^ (__v2du)__b);
422 }
423
424 /// \brief Compares each of the corresponding double-precision values of the
425 ///    128-bit vectors of [2 x double] for equality. Each comparison yields 0h
426 ///    for false, FFFFFFFFFFFFFFFFh for true.
427 ///
428 /// \headerfile <x86intrin.h>
429 ///
430 /// This intrinsic corresponds to the <c> VCMPEQPD / CMPEQPD </c> instruction.
431 ///
432 /// \param __a
433 ///    A 128-bit vector of [2 x double].
434 /// \param __b
435 ///    A 128-bit vector of [2 x double].
436 /// \returns A 128-bit vector containing the comparison results.
437 static __inline__ __m128d __DEFAULT_FN_ATTRS
438 _mm_cmpeq_pd(__m128d __a, __m128d __b)
439 {
440   return (__m128d)__builtin_ia32_cmpeqpd((__v2df)__a, (__v2df)__b);
441 }
442
443 /// \brief Compares each of the corresponding double-precision values of the
444 ///    128-bit vectors of [2 x double] to determine if the values in the first
445 ///    operand are less than those in the second operand. Each comparison
446 ///    yields 0h for false, FFFFFFFFFFFFFFFFh for true.
447 ///
448 /// \headerfile <x86intrin.h>
449 ///
450 /// This intrinsic corresponds to the <c> VCMPLTPD / CMPLTPD </c> instruction.
451 ///
452 /// \param __a
453 ///    A 128-bit vector of [2 x double].
454 /// \param __b
455 ///    A 128-bit vector of [2 x double].
456 /// \returns A 128-bit vector containing the comparison results.
457 static __inline__ __m128d __DEFAULT_FN_ATTRS
458 _mm_cmplt_pd(__m128d __a, __m128d __b)
459 {
460   return (__m128d)__builtin_ia32_cmpltpd((__v2df)__a, (__v2df)__b);
461 }
462
463 /// \brief Compares each of the corresponding double-precision values of the
464 ///    128-bit vectors of [2 x double] to determine if the values in the first
465 ///    operand are less than or equal to those in the second operand.
466 ///
467 ///    Each comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
468 ///
469 /// \headerfile <x86intrin.h>
470 ///
471 /// This intrinsic corresponds to the <c> VCMPLEPD / CMPLEPD </c> instruction.
472 ///
473 /// \param __a
474 ///    A 128-bit vector of [2 x double].
475 /// \param __b
476 ///    A 128-bit vector of [2 x double].
477 /// \returns A 128-bit vector containing the comparison results.
478 static __inline__ __m128d __DEFAULT_FN_ATTRS
479 _mm_cmple_pd(__m128d __a, __m128d __b)
480 {
481   return (__m128d)__builtin_ia32_cmplepd((__v2df)__a, (__v2df)__b);
482 }
483
484 /// \brief Compares each of the corresponding double-precision values of the
485 ///    128-bit vectors of [2 x double] to determine if the values in the first
486 ///    operand are greater than those in the second operand.
487 ///
488 ///    Each comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
489 ///
490 /// \headerfile <x86intrin.h>
491 ///
492 /// This intrinsic corresponds to the <c> VCMPLTPD / CMPLTPD </c> instruction.
493 ///
494 /// \param __a
495 ///    A 128-bit vector of [2 x double].
496 /// \param __b
497 ///    A 128-bit vector of [2 x double].
498 /// \returns A 128-bit vector containing the comparison results.
499 static __inline__ __m128d __DEFAULT_FN_ATTRS
500 _mm_cmpgt_pd(__m128d __a, __m128d __b)
501 {
502   return (__m128d)__builtin_ia32_cmpltpd((__v2df)__b, (__v2df)__a);
503 }
504
505 /// \brief Compares each of the corresponding double-precision values of the
506 ///    128-bit vectors of [2 x double] to determine if the values in the first
507 ///    operand are greater than or equal to those in the second operand.
508 ///
509 ///    Each comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
510 ///
511 /// \headerfile <x86intrin.h>
512 ///
513 /// This intrinsic corresponds to the <c> VCMPLEPD / CMPLEPD </c> instruction.
514 ///
515 /// \param __a
516 ///    A 128-bit vector of [2 x double].
517 /// \param __b
518 ///    A 128-bit vector of [2 x double].
519 /// \returns A 128-bit vector containing the comparison results.
520 static __inline__ __m128d __DEFAULT_FN_ATTRS
521 _mm_cmpge_pd(__m128d __a, __m128d __b)
522 {
523   return (__m128d)__builtin_ia32_cmplepd((__v2df)__b, (__v2df)__a);
524 }
525
526 /// \brief Compares each of the corresponding double-precision values of the
527 ///    128-bit vectors of [2 x double] to determine if the values in the first
528 ///    operand are ordered with respect to those in the second operand.
529 ///
530 ///    A pair of double-precision values are "ordered" with respect to each
531 ///    other if neither value is a NaN. Each comparison yields 0h for false,
532 ///    FFFFFFFFFFFFFFFFh for true.
533 ///
534 /// \headerfile <x86intrin.h>
535 ///
536 /// This intrinsic corresponds to the <c> VCMPORDPD / CMPORDPD </c> instruction.
537 ///
538 /// \param __a
539 ///    A 128-bit vector of [2 x double].
540 /// \param __b
541 ///    A 128-bit vector of [2 x double].
542 /// \returns A 128-bit vector containing the comparison results.
543 static __inline__ __m128d __DEFAULT_FN_ATTRS
544 _mm_cmpord_pd(__m128d __a, __m128d __b)
545 {
546   return (__m128d)__builtin_ia32_cmpordpd((__v2df)__a, (__v2df)__b);
547 }
548
549 /// \brief Compares each of the corresponding double-precision values of the
550 ///    128-bit vectors of [2 x double] to determine if the values in the first
551 ///    operand are unordered with respect to those in the second operand.
552 ///
553 ///    A pair of double-precision values are "unordered" with respect to each
554 ///    other if one or both values are NaN. Each comparison yields 0h for false,
555 ///    FFFFFFFFFFFFFFFFh for true.
556 ///
557 /// \headerfile <x86intrin.h>
558 ///
559 /// This intrinsic corresponds to the <c> VCMPUNORDPD / CMPUNORDPD </c>
560 ///   instruction.
561 ///
562 /// \param __a
563 ///    A 128-bit vector of [2 x double].
564 /// \param __b
565 ///    A 128-bit vector of [2 x double].
566 /// \returns A 128-bit vector containing the comparison results.
567 static __inline__ __m128d __DEFAULT_FN_ATTRS
568 _mm_cmpunord_pd(__m128d __a, __m128d __b)
569 {
570   return (__m128d)__builtin_ia32_cmpunordpd((__v2df)__a, (__v2df)__b);
571 }
572
573 /// \brief Compares each of the corresponding double-precision values of the
574 ///    128-bit vectors of [2 x double] to determine if the values in the first
575 ///    operand are unequal to those in the second operand.
576 ///
577 ///    Each comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
578 ///
579 /// \headerfile <x86intrin.h>
580 ///
581 /// This intrinsic corresponds to the <c> VCMPNEQPD / CMPNEQPD </c> instruction.
582 ///
583 /// \param __a
584 ///    A 128-bit vector of [2 x double].
585 /// \param __b
586 ///    A 128-bit vector of [2 x double].
587 /// \returns A 128-bit vector containing the comparison results.
588 static __inline__ __m128d __DEFAULT_FN_ATTRS
589 _mm_cmpneq_pd(__m128d __a, __m128d __b)
590 {
591   return (__m128d)__builtin_ia32_cmpneqpd((__v2df)__a, (__v2df)__b);
592 }
593
594 /// \brief Compares each of the corresponding double-precision values of the
595 ///    128-bit vectors of [2 x double] to determine if the values in the first
596 ///    operand are not less than those in the second operand.
597 ///
598 ///    Each comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
599 ///
600 /// \headerfile <x86intrin.h>
601 ///
602 /// This intrinsic corresponds to the <c> VCMPNLTPD / CMPNLTPD </c> instruction.
603 ///
604 /// \param __a
605 ///    A 128-bit vector of [2 x double].
606 /// \param __b
607 ///    A 128-bit vector of [2 x double].
608 /// \returns A 128-bit vector containing the comparison results.
609 static __inline__ __m128d __DEFAULT_FN_ATTRS
610 _mm_cmpnlt_pd(__m128d __a, __m128d __b)
611 {
612   return (__m128d)__builtin_ia32_cmpnltpd((__v2df)__a, (__v2df)__b);
613 }
614
615 /// \brief Compares each of the corresponding double-precision values of the
616 ///    128-bit vectors of [2 x double] to determine if the values in the first
617 ///    operand are not less than or equal to those in the second operand.
618 ///
619 ///    Each comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
620 ///
621 /// \headerfile <x86intrin.h>
622 ///
623 /// This intrinsic corresponds to the <c> VCMPNLEPD / CMPNLEPD </c> instruction.
624 ///
625 /// \param __a
626 ///    A 128-bit vector of [2 x double].
627 /// \param __b
628 ///    A 128-bit vector of [2 x double].
629 /// \returns A 128-bit vector containing the comparison results.
630 static __inline__ __m128d __DEFAULT_FN_ATTRS
631 _mm_cmpnle_pd(__m128d __a, __m128d __b)
632 {
633   return (__m128d)__builtin_ia32_cmpnlepd((__v2df)__a, (__v2df)__b);
634 }
635
636 /// \brief Compares each of the corresponding double-precision values of the
637 ///    128-bit vectors of [2 x double] to determine if the values in the first
638 ///    operand are not greater than those in the second operand.
639 ///
640 ///    Each comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
641 ///
642 /// \headerfile <x86intrin.h>
643 ///
644 /// This intrinsic corresponds to the <c> VCMPNLTPD / CMPNLTPD </c> instruction.
645 ///
646 /// \param __a
647 ///    A 128-bit vector of [2 x double].
648 /// \param __b
649 ///    A 128-bit vector of [2 x double].
650 /// \returns A 128-bit vector containing the comparison results.
651 static __inline__ __m128d __DEFAULT_FN_ATTRS
652 _mm_cmpngt_pd(__m128d __a, __m128d __b)
653 {
654   return (__m128d)__builtin_ia32_cmpnltpd((__v2df)__b, (__v2df)__a);
655 }
656
657 /// \brief Compares each of the corresponding double-precision values of the
658 ///    128-bit vectors of [2 x double] to determine if the values in the first
659 ///    operand are not greater than or equal to those in the second operand.
660 ///
661 ///    Each comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
662 ///
663 /// \headerfile <x86intrin.h>
664 ///
665 /// This intrinsic corresponds to the <c> VCMPNLEPD / CMPNLEPD </c> instruction.
666 ///
667 /// \param __a
668 ///    A 128-bit vector of [2 x double].
669 /// \param __b
670 ///    A 128-bit vector of [2 x double].
671 /// \returns A 128-bit vector containing the comparison results.
672 static __inline__ __m128d __DEFAULT_FN_ATTRS
673 _mm_cmpnge_pd(__m128d __a, __m128d __b)
674 {
675   return (__m128d)__builtin_ia32_cmpnlepd((__v2df)__b, (__v2df)__a);
676 }
677
678 /// \brief Compares the lower double-precision floating-point values in each of
679 ///    the two 128-bit floating-point vectors of [2 x double] for equality.
680 ///
681 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
682 ///
683 /// \headerfile <x86intrin.h>
684 ///
685 /// This intrinsic corresponds to the <c> VCMPEQSD / CMPEQSD </c> instruction.
686 ///
687 /// \param __a
688 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
689 ///    compared to the lower double-precision value of \a __b.
690 /// \param __b
691 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
692 ///    compared to the lower double-precision value of \a __a.
693 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
694 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
695 static __inline__ __m128d __DEFAULT_FN_ATTRS
696 _mm_cmpeq_sd(__m128d __a, __m128d __b)
697 {
698   return (__m128d)__builtin_ia32_cmpeqsd((__v2df)__a, (__v2df)__b);
699 }
700
701 /// \brief Compares the lower double-precision floating-point values in each of
702 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
703 ///    the value in the first parameter is less than the corresponding value in
704 ///    the second parameter.
705 ///
706 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
707 ///
708 /// \headerfile <x86intrin.h>
709 ///
710 /// This intrinsic corresponds to the <c> VCMPLTSD / CMPLTSD </c> instruction.
711 ///
712 /// \param __a
713 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
714 ///    compared to the lower double-precision value of \a __b.
715 /// \param __b
716 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
717 ///    compared to the lower double-precision value of \a __a.
718 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
719 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
720 static __inline__ __m128d __DEFAULT_FN_ATTRS
721 _mm_cmplt_sd(__m128d __a, __m128d __b)
722 {
723   return (__m128d)__builtin_ia32_cmpltsd((__v2df)__a, (__v2df)__b);
724 }
725
726 /// \brief Compares the lower double-precision floating-point values in each of
727 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
728 ///    the value in the first parameter is less than or equal to the
729 ///    corresponding value in the second parameter.
730 ///
731 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
732 ///
733 /// \headerfile <x86intrin.h>
734 ///
735 /// This intrinsic corresponds to the <c> VCMPLESD / CMPLESD </c> instruction.
736 ///
737 /// \param __a
738 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
739 ///    compared to the lower double-precision value of \a __b.
740 /// \param __b
741 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
742 ///    compared to the lower double-precision value of \a __a.
743 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
744 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
745 static __inline__ __m128d __DEFAULT_FN_ATTRS
746 _mm_cmple_sd(__m128d __a, __m128d __b)
747 {
748   return (__m128d)__builtin_ia32_cmplesd((__v2df)__a, (__v2df)__b);
749 }
750
751 /// \brief Compares the lower double-precision floating-point values in each of
752 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
753 ///    the value in the first parameter is greater than the corresponding value
754 ///    in the second parameter.
755 ///
756 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
757 ///
758 /// \headerfile <x86intrin.h>
759 ///
760 /// This intrinsic corresponds to the <c> VCMPLTSD / CMPLTSD </c> instruction.
761 ///
762 /// \param __a
763 ///     A 128-bit vector of [2 x double]. The lower double-precision value is
764 ///     compared to the lower double-precision value of \a __b.
765 /// \param __b
766 ///     A 128-bit vector of [2 x double]. The lower double-precision value is
767 ///     compared to the lower double-precision value of \a __a.
768 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
769 ///     results. The upper 64 bits are copied from the upper 64 bits of \a __a.
770 static __inline__ __m128d __DEFAULT_FN_ATTRS
771 _mm_cmpgt_sd(__m128d __a, __m128d __b)
772 {
773   __m128d __c = __builtin_ia32_cmpltsd((__v2df)__b, (__v2df)__a);
774   return (__m128d) { __c[0], __a[1] };
775 }
776
777 /// \brief Compares the lower double-precision floating-point values in each of
778 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
779 ///    the value in the first parameter is greater than or equal to the
780 ///    corresponding value in the second parameter.
781 ///
782 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
783 ///
784 /// \headerfile <x86intrin.h>
785 ///
786 /// This intrinsic corresponds to the <c> VCMPLESD / CMPLESD </c> instruction.
787 ///
788 /// \param __a
789 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
790 ///    compared to the lower double-precision value of \a __b.
791 /// \param __b
792 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
793 ///    compared to the lower double-precision value of \a __a.
794 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
795 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
796 static __inline__ __m128d __DEFAULT_FN_ATTRS
797 _mm_cmpge_sd(__m128d __a, __m128d __b)
798 {
799   __m128d __c = __builtin_ia32_cmplesd((__v2df)__b, (__v2df)__a);
800   return (__m128d) { __c[0], __a[1] };
801 }
802
803 /// \brief Compares the lower double-precision floating-point values in each of
804 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
805 ///    the value in the first parameter is "ordered" with respect to the
806 ///    corresponding value in the second parameter.
807 ///
808 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true. A pair of
809 ///    double-precision values are "ordered" with respect to each other if
810 ///    neither value is a NaN.
811 ///
812 /// \headerfile <x86intrin.h>
813 ///
814 /// This intrinsic corresponds to the <c> VCMPORDSD / CMPORDSD </c> instruction.
815 ///
816 /// \param __a
817 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
818 ///    compared to the lower double-precision value of \a __b.
819 /// \param __b
820 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
821 ///    compared to the lower double-precision value of \a __a.
822 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
823 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
824 static __inline__ __m128d __DEFAULT_FN_ATTRS
825 _mm_cmpord_sd(__m128d __a, __m128d __b)
826 {
827   return (__m128d)__builtin_ia32_cmpordsd((__v2df)__a, (__v2df)__b);
828 }
829
830 /// \brief Compares the lower double-precision floating-point values in each of
831 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
832 ///    the value in the first parameter is "unordered" with respect to the
833 ///    corresponding value in the second parameter.
834 ///
835 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true. A pair of
836 ///    double-precision values are "unordered" with respect to each other if one
837 ///    or both values are NaN.
838 ///
839 /// \headerfile <x86intrin.h>
840 ///
841 /// This intrinsic corresponds to the <c> VCMPUNORDSD / CMPUNORDSD </c>
842 ///   instruction.
843 ///
844 /// \param __a
845 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
846 ///    compared to the lower double-precision value of \a __b.
847 /// \param __b
848 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
849 ///    compared to the lower double-precision value of \a __a.
850 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
851 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
852 static __inline__ __m128d __DEFAULT_FN_ATTRS
853 _mm_cmpunord_sd(__m128d __a, __m128d __b)
854 {
855   return (__m128d)__builtin_ia32_cmpunordsd((__v2df)__a, (__v2df)__b);
856 }
857
858 /// \brief Compares the lower double-precision floating-point values in each of
859 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
860 ///    the value in the first parameter is unequal to the corresponding value in
861 ///    the second parameter.
862 ///
863 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
864 ///
865 /// \headerfile <x86intrin.h>
866 ///
867 /// This intrinsic corresponds to the <c> VCMPNEQSD / CMPNEQSD </c> instruction.
868 ///
869 /// \param __a
870 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
871 ///    compared to the lower double-precision value of \a __b.
872 /// \param __b
873 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
874 ///    compared to the lower double-precision value of \a __a.
875 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
876 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
877 static __inline__ __m128d __DEFAULT_FN_ATTRS
878 _mm_cmpneq_sd(__m128d __a, __m128d __b)
879 {
880   return (__m128d)__builtin_ia32_cmpneqsd((__v2df)__a, (__v2df)__b);
881 }
882
883 /// \brief Compares the lower double-precision floating-point values in each of
884 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
885 ///    the value in the first parameter is not less than the corresponding
886 ///    value in the second parameter.
887 ///
888 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
889 ///
890 /// \headerfile <x86intrin.h>
891 ///
892 /// This intrinsic corresponds to the <c> VCMPNLTSD / CMPNLTSD </c> instruction.
893 ///
894 /// \param __a
895 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
896 ///    compared to the lower double-precision value of \a __b.
897 /// \param __b
898 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
899 ///    compared to the lower double-precision value of \a __a.
900 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
901 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
902 static __inline__ __m128d __DEFAULT_FN_ATTRS
903 _mm_cmpnlt_sd(__m128d __a, __m128d __b)
904 {
905   return (__m128d)__builtin_ia32_cmpnltsd((__v2df)__a, (__v2df)__b);
906 }
907
908 /// \brief Compares the lower double-precision floating-point values in each of
909 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
910 ///    the value in the first parameter is not less than or equal to the
911 ///    corresponding value in the second parameter.
912 ///
913 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
914 ///
915 /// \headerfile <x86intrin.h>
916 ///
917 /// This intrinsic corresponds to the <c> VCMPNLESD / CMPNLESD </c> instruction.
918 ///
919 /// \param __a
920 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
921 ///    compared to the lower double-precision value of \a __b.
922 /// \param __b
923 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
924 ///    compared to the lower double-precision value of \a __a.
925 /// \returns  A 128-bit vector. The lower 64 bits contains the comparison
926 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
927 static __inline__ __m128d __DEFAULT_FN_ATTRS
928 _mm_cmpnle_sd(__m128d __a, __m128d __b)
929 {
930   return (__m128d)__builtin_ia32_cmpnlesd((__v2df)__a, (__v2df)__b);
931 }
932
933 /// \brief Compares the lower double-precision floating-point values in each of
934 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
935 ///    the value in the first parameter is not greater than the corresponding
936 ///    value in the second parameter.
937 ///
938 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
939 ///
940 /// \headerfile <x86intrin.h>
941 ///
942 /// This intrinsic corresponds to the <c> VCMPNLTSD / CMPNLTSD </c> instruction.
943 ///
944 /// \param __a
945 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
946 ///    compared to the lower double-precision value of \a __b.
947 /// \param __b
948 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
949 ///    compared to the lower double-precision value of \a __a.
950 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
951 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
952 static __inline__ __m128d __DEFAULT_FN_ATTRS
953 _mm_cmpngt_sd(__m128d __a, __m128d __b)
954 {
955   __m128d __c = __builtin_ia32_cmpnltsd((__v2df)__b, (__v2df)__a);
956   return (__m128d) { __c[0], __a[1] };
957 }
958
959 /// \brief Compares the lower double-precision floating-point values in each of
960 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
961 ///    the value in the first parameter is not greater than or equal to the
962 ///    corresponding value in the second parameter.
963 ///
964 ///    The comparison yields 0h for false, FFFFFFFFFFFFFFFFh for true.
965 ///
966 /// \headerfile <x86intrin.h>
967 ///
968 /// This intrinsic corresponds to the <c> VCMPNLESD / CMPNLESD </c> instruction.
969 ///
970 /// \param __a
971 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
972 ///    compared to the lower double-precision value of \a __b.
973 /// \param __b
974 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
975 ///    compared to the lower double-precision value of \a __a.
976 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
977 ///    results. The upper 64 bits are copied from the upper 64 bits of \a __a.
978 static __inline__ __m128d __DEFAULT_FN_ATTRS
979 _mm_cmpnge_sd(__m128d __a, __m128d __b)
980 {
981   __m128d __c = __builtin_ia32_cmpnlesd((__v2df)__b, (__v2df)__a);
982   return (__m128d) { __c[0], __a[1] };
983 }
984
985 /// \brief Compares the lower double-precision floating-point values in each of
986 ///    the two 128-bit floating-point vectors of [2 x double] for equality.
987 ///
988 ///    The comparison yields 0 for false, 1 for true. If either of the two
989 ///    lower double-precision values is NaN, 0 is returned.
990 ///
991 /// \headerfile <x86intrin.h>
992 ///
993 /// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
994 ///
995 /// \param __a
996 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
997 ///    compared to the lower double-precision value of \a __b.
998 /// \param __b
999 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1000 ///    compared to the lower double-precision value of \a __a.
1001 /// \returns An integer containing the comparison results. If either of the two
1002 ///    lower double-precision values is NaN, 0 is returned.
1003 static __inline__ int __DEFAULT_FN_ATTRS
1004 _mm_comieq_sd(__m128d __a, __m128d __b)
1005 {
1006   return __builtin_ia32_comisdeq((__v2df)__a, (__v2df)__b);
1007 }
1008
1009 /// \brief Compares the lower double-precision floating-point values in each of
1010 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1011 ///    the value in the first parameter is less than the corresponding value in
1012 ///    the second parameter.
1013 ///
1014 ///    The comparison yields 0 for false, 1 for true. If either of the two
1015 ///    lower double-precision values is NaN, 0 is returned.
1016 ///
1017 /// \headerfile <x86intrin.h>
1018 ///
1019 /// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
1020 ///
1021 /// \param __a
1022 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1023 ///    compared to the lower double-precision value of \a __b.
1024 /// \param __b
1025 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1026 ///    compared to the lower double-precision value of \a __a.
1027 /// \returns An integer containing the comparison results. If either of the two
1028 ///     lower double-precision values is NaN, 0 is returned.
1029 static __inline__ int __DEFAULT_FN_ATTRS
1030 _mm_comilt_sd(__m128d __a, __m128d __b)
1031 {
1032   return __builtin_ia32_comisdlt((__v2df)__a, (__v2df)__b);
1033 }
1034
1035 /// \brief Compares the lower double-precision floating-point values in each of
1036 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1037 ///    the value in the first parameter is less than or equal to the
1038 ///    corresponding value in the second parameter.
1039 ///
1040 ///    The comparison yields 0 for false, 1 for true. If either of the two
1041 ///    lower double-precision values is NaN, 0 is returned.
1042 ///
1043 /// \headerfile <x86intrin.h>
1044 ///
1045 /// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
1046 ///
1047 /// \param __a
1048 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1049 ///    compared to the lower double-precision value of \a __b.
1050 /// \param __b
1051 ///     A 128-bit vector of [2 x double]. The lower double-precision value is
1052 ///     compared to the lower double-precision value of \a __a.
1053 /// \returns An integer containing the comparison results. If either of the two
1054 ///     lower double-precision values is NaN, 0 is returned.
1055 static __inline__ int __DEFAULT_FN_ATTRS
1056 _mm_comile_sd(__m128d __a, __m128d __b)
1057 {
1058   return __builtin_ia32_comisdle((__v2df)__a, (__v2df)__b);
1059 }
1060
1061 /// \brief Compares the lower double-precision floating-point values in each of
1062 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1063 ///    the value in the first parameter is greater than the corresponding value
1064 ///    in the second parameter.
1065 ///
1066 ///    The comparison yields 0 for false, 1 for true. If either of the two
1067 ///    lower double-precision values is NaN, 0 is returned.
1068 ///
1069 /// \headerfile <x86intrin.h>
1070 ///
1071 /// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
1072 ///
1073 /// \param __a
1074 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1075 ///    compared to the lower double-precision value of \a __b.
1076 /// \param __b
1077 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1078 ///    compared to the lower double-precision value of \a __a.
1079 /// \returns An integer containing the comparison results. If either of the two
1080 ///     lower double-precision values is NaN, 0 is returned.
1081 static __inline__ int __DEFAULT_FN_ATTRS
1082 _mm_comigt_sd(__m128d __a, __m128d __b)
1083 {
1084   return __builtin_ia32_comisdgt((__v2df)__a, (__v2df)__b);
1085 }
1086
1087 /// \brief Compares the lower double-precision floating-point values in each of
1088 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1089 ///    the value in the first parameter is greater than or equal to the
1090 ///    corresponding value in the second parameter.
1091 ///
1092 ///    The comparison yields 0 for false, 1 for true. If either of the two
1093 ///    lower double-precision values is NaN, 0 is returned.
1094 ///
1095 /// \headerfile <x86intrin.h>
1096 ///
1097 /// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
1098 ///
1099 /// \param __a
1100 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1101 ///    compared to the lower double-precision value of \a __b.
1102 /// \param __b
1103 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1104 ///    compared to the lower double-precision value of \a __a.
1105 /// \returns An integer containing the comparison results. If either of the two
1106 ///    lower double-precision values is NaN, 0 is returned.
1107 static __inline__ int __DEFAULT_FN_ATTRS
1108 _mm_comige_sd(__m128d __a, __m128d __b)
1109 {
1110   return __builtin_ia32_comisdge((__v2df)__a, (__v2df)__b);
1111 }
1112
1113 /// \brief Compares the lower double-precision floating-point values in each of
1114 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1115 ///    the value in the first parameter is unequal to the corresponding value in
1116 ///    the second parameter.
1117 ///
1118 ///    The comparison yields 0 for false, 1 for true. If either of the two
1119 ///    lower double-precision values is NaN, 1 is returned.
1120 ///
1121 /// \headerfile <x86intrin.h>
1122 ///
1123 /// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
1124 ///
1125 /// \param __a
1126 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1127 ///    compared to the lower double-precision value of \a __b.
1128 /// \param __b
1129 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1130 ///    compared to the lower double-precision value of \a __a.
1131 /// \returns An integer containing the comparison results. If either of the two
1132 ///     lower double-precision values is NaN, 1 is returned.
1133 static __inline__ int __DEFAULT_FN_ATTRS
1134 _mm_comineq_sd(__m128d __a, __m128d __b)
1135 {
1136   return __builtin_ia32_comisdneq((__v2df)__a, (__v2df)__b);
1137 }
1138
1139 /// \brief Compares the lower double-precision floating-point values in each of
1140 ///    the two 128-bit floating-point vectors of [2 x double] for equality. The
1141 ///    comparison yields 0 for false, 1 for true.
1142 ///
1143 ///    If either of the two lower double-precision values is NaN, 0 is returned.
1144 ///
1145 /// \headerfile <x86intrin.h>
1146 ///
1147 /// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
1148 ///
1149 /// \param __a
1150 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1151 ///    compared to the lower double-precision value of \a __b.
1152 /// \param __b
1153 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1154 ///    compared to the lower double-precision value of \a __a.
1155 /// \returns An integer containing the comparison results. If either of the two
1156 ///    lower double-precision values is NaN, 0 is returned.
1157 static __inline__ int __DEFAULT_FN_ATTRS
1158 _mm_ucomieq_sd(__m128d __a, __m128d __b)
1159 {
1160   return __builtin_ia32_ucomisdeq((__v2df)__a, (__v2df)__b);
1161 }
1162
1163 /// \brief Compares the lower double-precision floating-point values in each of
1164 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1165 ///    the value in the first parameter is less than the corresponding value in
1166 ///    the second parameter.
1167 ///
1168 ///    The comparison yields 0 for false, 1 for true. If either of the two lower
1169 ///    double-precision values is NaN, 0 is returned.
1170 ///
1171 /// \headerfile <x86intrin.h>
1172 ///
1173 /// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
1174 ///
1175 /// \param __a
1176 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1177 ///    compared to the lower double-precision value of \a __b.
1178 /// \param __b
1179 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1180 ///    compared to the lower double-precision value of \a __a.
1181 /// \returns An integer containing the comparison results. If either of the two
1182 ///    lower double-precision values is NaN, 0 is returned.
1183 static __inline__ int __DEFAULT_FN_ATTRS
1184 _mm_ucomilt_sd(__m128d __a, __m128d __b)
1185 {
1186   return __builtin_ia32_ucomisdlt((__v2df)__a, (__v2df)__b);
1187 }
1188
1189 /// \brief Compares the lower double-precision floating-point values in each of
1190 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1191 ///    the value in the first parameter is less than or equal to the
1192 ///    corresponding value in the second parameter.
1193 ///
1194 ///    The comparison yields 0 for false, 1 for true. If either of the two lower
1195 ///    double-precision values is NaN, 0 is returned.
1196 ///
1197 /// \headerfile <x86intrin.h>
1198 ///
1199 /// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
1200 ///
1201 /// \param __a
1202 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1203 ///    compared to the lower double-precision value of \a __b.
1204 /// \param __b
1205 ///     A 128-bit vector of [2 x double]. The lower double-precision value is
1206 ///     compared to the lower double-precision value of \a __a.
1207 /// \returns An integer containing the comparison results. If either of the two
1208 ///     lower double-precision values is NaN, 0 is returned.
1209 static __inline__ int __DEFAULT_FN_ATTRS
1210 _mm_ucomile_sd(__m128d __a, __m128d __b)
1211 {
1212   return __builtin_ia32_ucomisdle((__v2df)__a, (__v2df)__b);
1213 }
1214
1215 /// \brief Compares the lower double-precision floating-point values in each of
1216 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1217 ///    the value in the first parameter is greater than the corresponding value
1218 ///    in the second parameter.
1219 ///
1220 ///    The comparison yields 0 for false, 1 for true. If either of the two lower
1221 ///    double-precision values is NaN, 0 is returned.
1222 ///
1223 /// \headerfile <x86intrin.h>
1224 ///
1225 /// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
1226 ///
1227 /// \param __a
1228 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1229 ///    compared to the lower double-precision value of \a __b.
1230 /// \param __b
1231 ///     A 128-bit vector of [2 x double]. The lower double-precision value is
1232 ///     compared to the lower double-precision value of \a __a.
1233 /// \returns An integer containing the comparison results. If either of the two
1234 ///     lower double-precision values is NaN, 0 is returned.
1235 static __inline__ int __DEFAULT_FN_ATTRS
1236 _mm_ucomigt_sd(__m128d __a, __m128d __b)
1237 {
1238   return __builtin_ia32_ucomisdgt((__v2df)__a, (__v2df)__b);
1239 }
1240
1241 /// \brief Compares the lower double-precision floating-point values in each of
1242 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1243 ///    the value in the first parameter is greater than or equal to the
1244 ///    corresponding value in the second parameter.
1245 ///
1246 ///    The comparison yields 0 for false, 1 for true.  If either of the two
1247 ///    lower double-precision values is NaN, 0 is returned.
1248 ///
1249 /// \headerfile <x86intrin.h>
1250 ///
1251 /// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
1252 ///
1253 /// \param __a
1254 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1255 ///    compared to the lower double-precision value of \a __b.
1256 /// \param __b
1257 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1258 ///    compared to the lower double-precision value of \a __a.
1259 /// \returns An integer containing the comparison results. If either of the two
1260 ///    lower double-precision values is NaN, 0 is returned.
1261 static __inline__ int __DEFAULT_FN_ATTRS
1262 _mm_ucomige_sd(__m128d __a, __m128d __b)
1263 {
1264   return __builtin_ia32_ucomisdge((__v2df)__a, (__v2df)__b);
1265 }
1266
1267 /// \brief Compares the lower double-precision floating-point values in each of
1268 ///    the two 128-bit floating-point vectors of [2 x double] to determine if
1269 ///    the value in the first parameter is unequal to the corresponding value in
1270 ///    the second parameter.
1271 ///
1272 ///    The comparison yields 0 for false, 1 for true. If either of the two lower
1273 ///    double-precision values is NaN, 1 is returned.
1274 ///
1275 /// \headerfile <x86intrin.h>
1276 ///
1277 /// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
1278 ///
1279 /// \param __a
1280 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1281 ///    compared to the lower double-precision value of \a __b.
1282 /// \param __b
1283 ///    A 128-bit vector of [2 x double]. The lower double-precision value is
1284 ///    compared to the lower double-precision value of \a __a.
1285 /// \returns An integer containing the comparison result. If either of the two
1286 ///    lower double-precision values is NaN, 1 is returned.
1287 static __inline__ int __DEFAULT_FN_ATTRS
1288 _mm_ucomineq_sd(__m128d __a, __m128d __b)
1289 {
1290   return __builtin_ia32_ucomisdneq((__v2df)__a, (__v2df)__b);
1291 }
1292
1293 /// \brief Converts the two double-precision floating-point elements of a
1294 ///    128-bit vector of [2 x double] into two single-precision floating-point
1295 ///    values, returned in the lower 64 bits of a 128-bit vector of [4 x float].
1296 ///    The upper 64 bits of the result vector are set to zero.
1297 ///
1298 /// \headerfile <x86intrin.h>
1299 ///
1300 /// This intrinsic corresponds to the <c> VCVTPD2PS / CVTPD2PS </c> instruction.
1301 ///
1302 /// \param __a
1303 ///    A 128-bit vector of [2 x double].
1304 /// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the
1305 ///    converted values. The upper 64 bits are set to zero.
1306 static __inline__ __m128 __DEFAULT_FN_ATTRS
1307 _mm_cvtpd_ps(__m128d __a)
1308 {
1309   return __builtin_ia32_cvtpd2ps((__v2df)__a);
1310 }
1311
1312 /// \brief Converts the lower two single-precision floating-point elements of a
1313 ///    128-bit vector of [4 x float] into two double-precision floating-point
1314 ///    values, returned in a 128-bit vector of [2 x double]. The upper two
1315 ///    elements of the input vector are unused.
1316 ///
1317 /// \headerfile <x86intrin.h>
1318 ///
1319 /// This intrinsic corresponds to the <c> VCVTPS2PD / CVTPS2PD </c> instruction.
1320 ///
1321 /// \param __a
1322 ///    A 128-bit vector of [4 x float]. The lower two single-precision
1323 ///    floating-point elements are converted to double-precision values. The
1324 ///    upper two elements are unused.
1325 /// \returns A 128-bit vector of [2 x double] containing the converted values.
1326 static __inline__ __m128d __DEFAULT_FN_ATTRS
1327 _mm_cvtps_pd(__m128 __a)
1328 {
1329   return (__m128d) __builtin_convertvector(
1330       __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 1), __v2df);
1331 }
1332
1333 /// \brief Converts the lower two integer elements of a 128-bit vector of
1334 ///    [4 x i32] into two double-precision floating-point values, returned in a
1335 ///    128-bit vector of [2 x double].
1336 ///
1337 ///    The upper two elements of the input vector are unused.
1338 ///
1339 /// \headerfile <x86intrin.h>
1340 ///
1341 /// This intrinsic corresponds to the <c> VCVTDQ2PD / CVTDQ2PD </c> instruction.
1342 ///
1343 /// \param __a
1344 ///    A 128-bit integer vector of [4 x i32]. The lower two integer elements are
1345 ///    converted to double-precision values.
1346 ///
1347 ///    The upper two elements are unused.
1348 /// \returns A 128-bit vector of [2 x double] containing the converted values.
1349 static __inline__ __m128d __DEFAULT_FN_ATTRS
1350 _mm_cvtepi32_pd(__m128i __a)
1351 {
1352   return (__m128d) __builtin_convertvector(
1353       __builtin_shufflevector((__v4si)__a, (__v4si)__a, 0, 1), __v2df);
1354 }
1355
1356 /// \brief Converts the two double-precision floating-point elements of a
1357 ///    128-bit vector of [2 x double] into two signed 32-bit integer values,
1358 ///    returned in the lower 64 bits of a 128-bit vector of [4 x i32]. The upper
1359 ///    64 bits of the result vector are set to zero.
1360 ///
1361 /// \headerfile <x86intrin.h>
1362 ///
1363 /// This intrinsic corresponds to the <c> VCVTPD2DQ / CVTPD2DQ </c> instruction.
1364 ///
1365 /// \param __a
1366 ///    A 128-bit vector of [2 x double].
1367 /// \returns A 128-bit vector of [4 x i32] whose lower 64 bits contain the
1368 ///    converted values. The upper 64 bits are set to zero.
1369 static __inline__ __m128i __DEFAULT_FN_ATTRS
1370 _mm_cvtpd_epi32(__m128d __a)
1371 {
1372   return __builtin_ia32_cvtpd2dq((__v2df)__a);
1373 }
1374
1375 /// \brief Converts the low-order element of a 128-bit vector of [2 x double]
1376 ///    into a 32-bit signed integer value.
1377 ///
1378 /// \headerfile <x86intrin.h>
1379 ///
1380 /// This intrinsic corresponds to the <c> VCVTSD2SI / CVTSD2SI </c> instruction.
1381 ///
1382 /// \param __a
1383 ///    A 128-bit vector of [2 x double]. The lower 64 bits are used in the
1384 ///    conversion.
1385 /// \returns A 32-bit signed integer containing the converted value.
1386 static __inline__ int __DEFAULT_FN_ATTRS
1387 _mm_cvtsd_si32(__m128d __a)
1388 {
1389   return __builtin_ia32_cvtsd2si((__v2df)__a);
1390 }
1391
1392 /// \brief Converts the lower double-precision floating-point element of a
1393 ///    128-bit vector of [2 x double], in the second parameter, into a
1394 ///    single-precision floating-point value, returned in the lower 32 bits of a
1395 ///    128-bit vector of [4 x float]. The upper 96 bits of the result vector are
1396 ///    copied from the upper 96 bits of the first parameter.
1397 ///
1398 /// \headerfile <x86intrin.h>
1399 ///
1400 /// This intrinsic corresponds to the <c> VCVTSD2SS / CVTSD2SS </c> instruction.
1401 ///
1402 /// \param __a
1403 ///    A 128-bit vector of [4 x float]. The upper 96 bits of this parameter are
1404 ///    copied to the upper 96 bits of the result.
1405 /// \param __b
1406 ///    A 128-bit vector of [2 x double]. The lower double-precision
1407 ///    floating-point element is used in the conversion.
1408 /// \returns A 128-bit vector of [4 x float]. The lower 32 bits contain the
1409 ///    converted value from the second parameter. The upper 96 bits are copied
1410 ///    from the upper 96 bits of the first parameter.
1411 static __inline__ __m128 __DEFAULT_FN_ATTRS
1412 _mm_cvtsd_ss(__m128 __a, __m128d __b)
1413 {
1414   return (__m128)__builtin_ia32_cvtsd2ss((__v4sf)__a, (__v2df)__b);
1415 }
1416
1417 /// \brief Converts a 32-bit signed integer value, in the second parameter, into
1418 ///    a double-precision floating-point value, returned in the lower 64 bits of
1419 ///    a 128-bit vector of [2 x double]. The upper 64 bits of the result vector
1420 ///    are copied from the upper 64 bits of the first parameter.
1421 ///
1422 /// \headerfile <x86intrin.h>
1423 ///
1424 /// This intrinsic corresponds to the <c> VCVTSI2SD / CVTSI2SD </c> instruction.
1425 ///
1426 /// \param __a
1427 ///    A 128-bit vector of [2 x double]. The upper 64 bits of this parameter are
1428 ///    copied to the upper 64 bits of the result.
1429 /// \param __b
1430 ///    A 32-bit signed integer containing the value to be converted.
1431 /// \returns A 128-bit vector of [2 x double]. The lower 64 bits contain the
1432 ///    converted value from the second parameter. The upper 64 bits are copied
1433 ///    from the upper 64 bits of the first parameter.
1434 static __inline__ __m128d __DEFAULT_FN_ATTRS
1435 _mm_cvtsi32_sd(__m128d __a, int __b)
1436 {
1437   __a[0] = __b;
1438   return __a;
1439 }
1440
1441 /// \brief Converts the lower single-precision floating-point element of a
1442 ///    128-bit vector of [4 x float], in the second parameter, into a
1443 ///    double-precision floating-point value, returned in the lower 64 bits of
1444 ///    a 128-bit vector of [2 x double]. The upper 64 bits of the result vector
1445 ///    are copied from the upper 64 bits of the first parameter.
1446 ///
1447 /// \headerfile <x86intrin.h>
1448 ///
1449 /// This intrinsic corresponds to the <c> VCVTSS2SD / CVTSS2SD </c> instruction.
1450 ///
1451 /// \param __a
1452 ///    A 128-bit vector of [2 x double]. The upper 64 bits of this parameter are
1453 ///    copied to the upper 64 bits of the result.
1454 /// \param __b
1455 ///    A 128-bit vector of [4 x float]. The lower single-precision
1456 ///    floating-point element is used in the conversion.
1457 /// \returns A 128-bit vector of [2 x double]. The lower 64 bits contain the
1458 ///    converted value from the second parameter. The upper 64 bits are copied
1459 ///    from the upper 64 bits of the first parameter.
1460 static __inline__ __m128d __DEFAULT_FN_ATTRS
1461 _mm_cvtss_sd(__m128d __a, __m128 __b)
1462 {
1463   __a[0] = __b[0];
1464   return __a;
1465 }
1466
1467 /// \brief Converts the two double-precision floating-point elements of a
1468 ///    128-bit vector of [2 x double] into two signed 32-bit integer values,
1469 ///    returned in the lower 64 bits of a 128-bit vector of [4 x i32].
1470 ///
1471 ///    If the result of either conversion is inexact, the result is truncated
1472 ///    (rounded towards zero) regardless of the current MXCSR setting. The upper
1473 ///    64 bits of the result vector are set to zero.
1474 ///
1475 /// \headerfile <x86intrin.h>
1476 ///
1477 /// This intrinsic corresponds to the <c> VCVTTPD2DQ / CVTTPD2DQ </c>
1478 ///   instruction.
1479 ///
1480 /// \param __a
1481 ///    A 128-bit vector of [2 x double].
1482 /// \returns A 128-bit vector of [4 x i32] whose lower 64 bits contain the
1483 ///    converted values. The upper 64 bits are set to zero.
1484 static __inline__ __m128i __DEFAULT_FN_ATTRS
1485 _mm_cvttpd_epi32(__m128d __a)
1486 {
1487   return (__m128i)__builtin_ia32_cvttpd2dq((__v2df)__a);
1488 }
1489
1490 /// \brief Converts the low-order element of a [2 x double] vector into a 32-bit
1491 ///    signed integer value, truncating the result when it is inexact.
1492 ///
1493 /// \headerfile <x86intrin.h>
1494 ///
1495 /// This intrinsic corresponds to the <c> VCVTTSD2SI / CVTTSD2SI </c>
1496 ///   instruction.
1497 ///
1498 /// \param __a
1499 ///    A 128-bit vector of [2 x double]. The lower 64 bits are used in the
1500 ///    conversion.
1501 /// \returns A 32-bit signed integer containing the converted value.
1502 static __inline__ int __DEFAULT_FN_ATTRS
1503 _mm_cvttsd_si32(__m128d __a)
1504 {
1505   return __builtin_ia32_cvttsd2si((__v2df)__a);
1506 }
1507
1508 /// \brief Converts the two double-precision floating-point elements of a
1509 ///    128-bit vector of [2 x double] into two signed 32-bit integer values,
1510 ///    returned in a 64-bit vector of [2 x i32].
1511 ///
1512 /// \headerfile <x86intrin.h>
1513 ///
1514 /// This intrinsic corresponds to the <c> CVTPD2PI </c> instruction.
1515 ///
1516 /// \param __a
1517 ///    A 128-bit vector of [2 x double].
1518 /// \returns A 64-bit vector of [2 x i32] containing the converted values.
1519 static __inline__ __m64 __DEFAULT_FN_ATTRS
1520 _mm_cvtpd_pi32(__m128d __a)
1521 {
1522   return (__m64)__builtin_ia32_cvtpd2pi((__v2df)__a);
1523 }
1524
1525 /// \brief Converts the two double-precision floating-point elements of a
1526 ///    128-bit vector of [2 x double] into two signed 32-bit integer values,
1527 ///    returned in a 64-bit vector of [2 x i32].
1528 ///
1529 ///    If the result of either conversion is inexact, the result is truncated
1530 ///    (rounded towards zero) regardless of the current MXCSR setting.
1531 ///
1532 /// \headerfile <x86intrin.h>
1533 ///
1534 /// This intrinsic corresponds to the <c> CVTTPD2PI </c> instruction.
1535 ///
1536 /// \param __a
1537 ///    A 128-bit vector of [2 x double].
1538 /// \returns A 64-bit vector of [2 x i32] containing the converted values.
1539 static __inline__ __m64 __DEFAULT_FN_ATTRS
1540 _mm_cvttpd_pi32(__m128d __a)
1541 {
1542   return (__m64)__builtin_ia32_cvttpd2pi((__v2df)__a);
1543 }
1544
1545 /// \brief Converts the two signed 32-bit integer elements of a 64-bit vector of
1546 ///    [2 x i32] into two double-precision floating-point values, returned in a
1547 ///    128-bit vector of [2 x double].
1548 ///
1549 /// \headerfile <x86intrin.h>
1550 ///
1551 /// This intrinsic corresponds to the <c> CVTPI2PD </c> instruction.
1552 ///
1553 /// \param __a
1554 ///    A 64-bit vector of [2 x i32].
1555 /// \returns A 128-bit vector of [2 x double] containing the converted values.
1556 static __inline__ __m128d __DEFAULT_FN_ATTRS
1557 _mm_cvtpi32_pd(__m64 __a)
1558 {
1559   return __builtin_ia32_cvtpi2pd((__v2si)__a);
1560 }
1561
1562 /// \brief Returns the low-order element of a 128-bit vector of [2 x double] as
1563 ///    a double-precision floating-point value.
1564 ///
1565 /// \headerfile <x86intrin.h>
1566 ///
1567 /// This intrinsic has no corresponding instruction.
1568 ///
1569 /// \param __a
1570 ///    A 128-bit vector of [2 x double]. The lower 64 bits are returned.
1571 /// \returns A double-precision floating-point value copied from the lower 64
1572 ///    bits of \a __a.
1573 static __inline__ double __DEFAULT_FN_ATTRS
1574 _mm_cvtsd_f64(__m128d __a)
1575 {
1576   return __a[0];
1577 }
1578
1579 /// \brief Loads a 128-bit floating-point vector of [2 x double] from an aligned
1580 ///    memory location.
1581 ///
1582 /// \headerfile <x86intrin.h>
1583 ///
1584 /// This intrinsic corresponds to the <c> VMOVAPD / MOVAPD </c> instruction.
1585 ///
1586 /// \param __dp
1587 ///    A pointer to a 128-bit memory location. The address of the memory
1588 ///    location has to be 16-byte aligned.
1589 /// \returns A 128-bit vector of [2 x double] containing the loaded values.
1590 static __inline__ __m128d __DEFAULT_FN_ATTRS
1591 _mm_load_pd(double const *__dp)
1592 {
1593   return *(__m128d*)__dp;
1594 }
1595
1596 /// \brief Loads a double-precision floating-point value from a specified memory
1597 ///    location and duplicates it to both vector elements of a 128-bit vector of
1598 ///    [2 x double].
1599 ///
1600 /// \headerfile <x86intrin.h>
1601 ///
1602 /// This intrinsic corresponds to the <c> VMOVDDUP / MOVDDUP </c> instruction.
1603 ///
1604 /// \param __dp
1605 ///    A pointer to a memory location containing a double-precision value.
1606 /// \returns A 128-bit vector of [2 x double] containing the loaded and
1607 ///    duplicated values.
1608 static __inline__ __m128d __DEFAULT_FN_ATTRS
1609 _mm_load1_pd(double const *__dp)
1610 {
1611   struct __mm_load1_pd_struct {
1612     double __u;
1613   } __attribute__((__packed__, __may_alias__));
1614   double __u = ((struct __mm_load1_pd_struct*)__dp)->__u;
1615   return (__m128d){ __u, __u };
1616 }
1617
1618 #define        _mm_load_pd1(dp)        _mm_load1_pd(dp)
1619
1620 /// \brief Loads two double-precision values, in reverse order, from an aligned
1621 ///    memory location into a 128-bit vector of [2 x double].
1622 ///
1623 /// \headerfile <x86intrin.h>
1624 ///
1625 /// This intrinsic corresponds to the <c> VMOVAPD / MOVAPD </c> instruction +
1626 /// needed shuffling instructions. In AVX mode, the shuffling may be combined
1627 /// with the \c VMOVAPD, resulting in only a \c VPERMILPD instruction.
1628 ///
1629 /// \param __dp
1630 ///    A 16-byte aligned pointer to an array of double-precision values to be
1631 ///    loaded in reverse order.
1632 /// \returns A 128-bit vector of [2 x double] containing the reversed loaded
1633 ///    values.
1634 static __inline__ __m128d __DEFAULT_FN_ATTRS
1635 _mm_loadr_pd(double const *__dp)
1636 {
1637   __m128d __u = *(__m128d*)__dp;
1638   return __builtin_shufflevector((__v2df)__u, (__v2df)__u, 1, 0);
1639 }
1640
1641 /// \brief Loads a 128-bit floating-point vector of [2 x double] from an
1642 ///    unaligned memory location.
1643 ///
1644 /// \headerfile <x86intrin.h>
1645 ///
1646 /// This intrinsic corresponds to the <c> VMOVUPD / MOVUPD </c> instruction.
1647 ///
1648 /// \param __dp
1649 ///    A pointer to a 128-bit memory location. The address of the memory
1650 ///    location does not have to be aligned.
1651 /// \returns A 128-bit vector of [2 x double] containing the loaded values.
1652 static __inline__ __m128d __DEFAULT_FN_ATTRS
1653 _mm_loadu_pd(double const *__dp)
1654 {
1655   struct __loadu_pd {
1656     __m128d __v;
1657   } __attribute__((__packed__, __may_alias__));
1658   return ((struct __loadu_pd*)__dp)->__v;
1659 }
1660
1661 /// \brief Loads a 64-bit integer value to the low element of a 128-bit integer
1662 ///    vector and clears the upper element.
1663 ///
1664 /// \headerfile <x86intrin.h>
1665 ///
1666 /// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
1667 ///
1668 /// \param __a
1669 ///    A pointer to a 64-bit memory location. The address of the memory
1670 ///    location does not have to be aligned.
1671 /// \returns A 128-bit vector of [2 x i64] containing the loaded value.
1672 static __inline__ __m128i __DEFAULT_FN_ATTRS
1673 _mm_loadu_si64(void const *__a)
1674 {
1675   struct __loadu_si64 {
1676     long long __v;
1677   } __attribute__((__packed__, __may_alias__));
1678   long long __u = ((struct __loadu_si64*)__a)->__v;
1679   return (__m128i){__u, 0L};
1680 }
1681
1682 /// \brief Loads a 64-bit double-precision value to the low element of a
1683 ///    128-bit integer vector and clears the upper element.
1684 ///
1685 /// \headerfile <x86intrin.h>
1686 ///
1687 /// This intrinsic corresponds to the <c> VMOVSD / MOVSD </c> instruction.
1688 ///
1689 /// \param __dp
1690 ///    A pointer to a memory location containing a double-precision value.
1691 ///    The address of the memory location does not have to be aligned.
1692 /// \returns A 128-bit vector of [2 x double] containing the loaded value.
1693 static __inline__ __m128d __DEFAULT_FN_ATTRS
1694 _mm_load_sd(double const *__dp)
1695 {
1696   struct __mm_load_sd_struct {
1697     double __u;
1698   } __attribute__((__packed__, __may_alias__));
1699   double __u = ((struct __mm_load_sd_struct*)__dp)->__u;
1700   return (__m128d){ __u, 0 };
1701 }
1702
1703 /// \brief Loads a double-precision value into the high-order bits of a 128-bit
1704 ///    vector of [2 x double]. The low-order bits are copied from the low-order
1705 ///    bits of the first operand.
1706 ///
1707 /// \headerfile <x86intrin.h>
1708 ///
1709 /// This intrinsic corresponds to the <c> VMOVHPD / MOVHPD </c> instruction.
1710 ///
1711 /// \param __a
1712 ///    A 128-bit vector of [2 x double]. \n
1713 ///    Bits [63:0] are written to bits [63:0] of the result.
1714 /// \param __dp
1715 ///    A pointer to a 64-bit memory location containing a double-precision
1716 ///    floating-point value that is loaded. The loaded value is written to bits
1717 ///    [127:64] of the result. The address of the memory location does not have
1718 ///    to be aligned.
1719 /// \returns A 128-bit vector of [2 x double] containing the moved values.
1720 static __inline__ __m128d __DEFAULT_FN_ATTRS
1721 _mm_loadh_pd(__m128d __a, double const *__dp)
1722 {
1723   struct __mm_loadh_pd_struct {
1724     double __u;
1725   } __attribute__((__packed__, __may_alias__));
1726   double __u = ((struct __mm_loadh_pd_struct*)__dp)->__u;
1727   return (__m128d){ __a[0], __u };
1728 }
1729
1730 /// \brief Loads a double-precision value into the low-order bits of a 128-bit
1731 ///    vector of [2 x double]. The high-order bits are copied from the
1732 ///    high-order bits of the first operand.
1733 ///
1734 /// \headerfile <x86intrin.h>
1735 ///
1736 /// This intrinsic corresponds to the <c> VMOVLPD / MOVLPD </c> instruction.
1737 ///
1738 /// \param __a
1739 ///    A 128-bit vector of [2 x double]. \n
1740 ///    Bits [127:64] are written to bits [127:64] of the result.
1741 /// \param __dp
1742 ///    A pointer to a 64-bit memory location containing a double-precision
1743 ///    floating-point value that is loaded. The loaded value is written to bits
1744 ///    [63:0] of the result. The address of the memory location does not have to
1745 ///    be aligned.
1746 /// \returns A 128-bit vector of [2 x double] containing the moved values.
1747 static __inline__ __m128d __DEFAULT_FN_ATTRS
1748 _mm_loadl_pd(__m128d __a, double const *__dp)
1749 {
1750   struct __mm_loadl_pd_struct {
1751     double __u;
1752   } __attribute__((__packed__, __may_alias__));
1753   double __u = ((struct __mm_loadl_pd_struct*)__dp)->__u;
1754   return (__m128d){ __u, __a[1] };
1755 }
1756
1757 /// \brief Constructs a 128-bit floating-point vector of [2 x double] with
1758 ///    unspecified content. This could be used as an argument to another
1759 ///    intrinsic function where the argument is required but the value is not
1760 ///    actually used.
1761 ///
1762 /// \headerfile <x86intrin.h>
1763 ///
1764 /// This intrinsic has no corresponding instruction.
1765 ///
1766 /// \returns A 128-bit floating-point vector of [2 x double] with unspecified
1767 ///    content.
1768 static __inline__ __m128d __DEFAULT_FN_ATTRS
1769 _mm_undefined_pd(void)
1770 {
1771   return (__m128d)__builtin_ia32_undef128();
1772 }
1773
1774 /// \brief Constructs a 128-bit floating-point vector of [2 x double]. The lower
1775 ///    64 bits of the vector are initialized with the specified double-precision
1776 ///    floating-point value. The upper 64 bits are set to zero.
1777 ///
1778 /// \headerfile <x86intrin.h>
1779 ///
1780 /// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
1781 ///
1782 /// \param __w
1783 ///    A double-precision floating-point value used to initialize the lower 64
1784 ///    bits of the result.
1785 /// \returns An initialized 128-bit floating-point vector of [2 x double]. The
1786 ///    lower 64 bits contain the value of the parameter. The upper 64 bits are
1787 ///    set to zero.
1788 static __inline__ __m128d __DEFAULT_FN_ATTRS
1789 _mm_set_sd(double __w)
1790 {
1791   return (__m128d){ __w, 0 };
1792 }
1793
1794 /// \brief Constructs a 128-bit floating-point vector of [2 x double], with each
1795 ///    of the two double-precision floating-point vector elements set to the
1796 ///    specified double-precision floating-point value.
1797 ///
1798 /// \headerfile <x86intrin.h>
1799 ///
1800 /// This intrinsic corresponds to the <c> VMOVDDUP / MOVLHPS </c> instruction.
1801 ///
1802 /// \param __w
1803 ///    A double-precision floating-point value used to initialize each vector
1804 ///    element of the result.
1805 /// \returns An initialized 128-bit floating-point vector of [2 x double].
1806 static __inline__ __m128d __DEFAULT_FN_ATTRS
1807 _mm_set1_pd(double __w)
1808 {
1809   return (__m128d){ __w, __w };
1810 }
1811
1812 /// \brief Constructs a 128-bit floating-point vector of [2 x double], with each
1813 ///    of the two double-precision floating-point vector elements set to the
1814 ///    specified double-precision floating-point value.
1815 ///
1816 /// \headerfile <x86intrin.h>
1817 ///
1818 /// This intrinsic corresponds to the <c> VMOVDDUP / MOVLHPS </c> instruction.
1819 ///
1820 /// \param __w
1821 ///    A double-precision floating-point value used to initialize each vector
1822 ///    element of the result.
1823 /// \returns An initialized 128-bit floating-point vector of [2 x double].
1824 static __inline__ __m128d __DEFAULT_FN_ATTRS
1825 _mm_set_pd1(double __w)
1826 {
1827   return _mm_set1_pd(__w);
1828 }
1829
1830 /// \brief Constructs a 128-bit floating-point vector of [2 x double]
1831 ///    initialized with the specified double-precision floating-point values.
1832 ///
1833 /// \headerfile <x86intrin.h>
1834 ///
1835 /// This intrinsic corresponds to the <c> VUNPCKLPD / UNPCKLPD </c> instruction.
1836 ///
1837 /// \param __w
1838 ///    A double-precision floating-point value used to initialize the upper 64
1839 ///    bits of the result.
1840 /// \param __x
1841 ///    A double-precision floating-point value used to initialize the lower 64
1842 ///    bits of the result.
1843 /// \returns An initialized 128-bit floating-point vector of [2 x double].
1844 static __inline__ __m128d __DEFAULT_FN_ATTRS
1845 _mm_set_pd(double __w, double __x)
1846 {
1847   return (__m128d){ __x, __w };
1848 }
1849
1850 /// \brief Constructs a 128-bit floating-point vector of [2 x double],
1851 ///    initialized in reverse order with the specified double-precision
1852 ///    floating-point values.
1853 ///
1854 /// \headerfile <x86intrin.h>
1855 ///
1856 /// This intrinsic corresponds to the <c> VUNPCKLPD / UNPCKLPD </c> instruction.
1857 ///
1858 /// \param __w
1859 ///    A double-precision floating-point value used to initialize the lower 64
1860 ///    bits of the result.
1861 /// \param __x
1862 ///    A double-precision floating-point value used to initialize the upper 64
1863 ///    bits of the result.
1864 /// \returns An initialized 128-bit floating-point vector of [2 x double].
1865 static __inline__ __m128d __DEFAULT_FN_ATTRS
1866 _mm_setr_pd(double __w, double __x)
1867 {
1868   return (__m128d){ __w, __x };
1869 }
1870
1871 /// \brief Constructs a 128-bit floating-point vector of [2 x double]
1872 ///    initialized to zero.
1873 ///
1874 /// \headerfile <x86intrin.h>
1875 ///
1876 /// This intrinsic corresponds to the <c> VXORPS / XORPS </c> instruction.
1877 ///
1878 /// \returns An initialized 128-bit floating-point vector of [2 x double] with
1879 ///    all elements set to zero.
1880 static __inline__ __m128d __DEFAULT_FN_ATTRS
1881 _mm_setzero_pd(void)
1882 {
1883   return (__m128d){ 0, 0 };
1884 }
1885
1886 /// \brief Constructs a 128-bit floating-point vector of [2 x double]. The lower
1887 ///    64 bits are set to the lower 64 bits of the second parameter. The upper
1888 ///    64 bits are set to the upper 64 bits of the first parameter.
1889 ///
1890 /// \headerfile <x86intrin.h>
1891 ///
1892 /// This intrinsic corresponds to the <c> VBLENDPD / BLENDPD </c> instruction.
1893 ///
1894 /// \param __a
1895 ///    A 128-bit vector of [2 x double]. The upper 64 bits are written to the
1896 ///    upper 64 bits of the result.
1897 /// \param __b
1898 ///    A 128-bit vector of [2 x double]. The lower 64 bits are written to the
1899 ///    lower 64 bits of the result.
1900 /// \returns A 128-bit vector of [2 x double] containing the moved values.
1901 static __inline__ __m128d __DEFAULT_FN_ATTRS
1902 _mm_move_sd(__m128d __a, __m128d __b)
1903 {
1904   return (__m128d){ __b[0], __a[1] };
1905 }
1906
1907 /// \brief Stores the lower 64 bits of a 128-bit vector of [2 x double] to a
1908 ///    memory location.
1909 ///
1910 /// \headerfile <x86intrin.h>
1911 ///
1912 /// This intrinsic corresponds to the <c> VMOVSD / MOVSD </c> instruction.
1913 ///
1914 /// \param __dp
1915 ///    A pointer to a 64-bit memory location.
1916 /// \param __a
1917 ///    A 128-bit vector of [2 x double] containing the value to be stored.
1918 static __inline__ void __DEFAULT_FN_ATTRS
1919 _mm_store_sd(double *__dp, __m128d __a)
1920 {
1921   struct __mm_store_sd_struct {
1922     double __u;
1923   } __attribute__((__packed__, __may_alias__));
1924   ((struct __mm_store_sd_struct*)__dp)->__u = __a[0];
1925 }
1926
1927 /// \brief Moves packed double-precision values from a 128-bit vector of
1928 ///    [2 x double] to a memory location.
1929 ///
1930 /// \headerfile <x86intrin.h>
1931 ///
1932 /// This intrinsic corresponds to the <c>VMOVAPD / MOVAPS</c> instruction.
1933 ///
1934 /// \param __dp
1935 ///    A pointer to an aligned memory location that can store two
1936 ///    double-precision values.
1937 /// \param __a
1938 ///    A packed 128-bit vector of [2 x double] containing the values to be
1939 ///    moved.
1940 static __inline__ void __DEFAULT_FN_ATTRS
1941 _mm_store_pd(double *__dp, __m128d __a)
1942 {
1943   *(__m128d*)__dp = __a;
1944 }
1945
1946 /// \brief Moves the lower 64 bits of a 128-bit vector of [2 x double] twice to
1947 ///    the upper and lower 64 bits of a memory location.
1948 ///
1949 /// \headerfile <x86intrin.h>
1950 ///
1951 /// This intrinsic corresponds to the
1952 ///   <c> VMOVDDUP + VMOVAPD / MOVLHPS + MOVAPS </c> instruction.
1953 ///
1954 /// \param __dp
1955 ///    A pointer to a memory location that can store two double-precision
1956 ///    values.
1957 /// \param __a
1958 ///    A 128-bit vector of [2 x double] whose lower 64 bits are copied to each
1959 ///    of the values in \a __dp.
1960 static __inline__ void __DEFAULT_FN_ATTRS
1961 _mm_store1_pd(double *__dp, __m128d __a)
1962 {
1963   __a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
1964   _mm_store_pd(__dp, __a);
1965 }
1966
1967 /// \brief Moves the lower 64 bits of a 128-bit vector of [2 x double] twice to
1968 ///    the upper and lower 64 bits of a memory location.
1969 ///
1970 /// \headerfile <x86intrin.h>
1971 ///
1972 /// This intrinsic corresponds to the
1973 ///   <c> VMOVDDUP + VMOVAPD / MOVLHPS + MOVAPS </c> instruction.
1974 ///
1975 /// \param __dp
1976 ///    A pointer to a memory location that can store two double-precision
1977 ///    values.
1978 /// \param __a
1979 ///    A 128-bit vector of [2 x double] whose lower 64 bits are copied to each
1980 ///    of the values in \a __dp.
1981 static __inline__ void __DEFAULT_FN_ATTRS
1982 _mm_store_pd1(double *__dp, __m128d __a)
1983 {
1984   return _mm_store1_pd(__dp, __a);
1985 }
1986
1987 /// \brief Stores a 128-bit vector of [2 x double] into an unaligned memory
1988 ///    location.
1989 ///
1990 /// \headerfile <x86intrin.h>
1991 ///
1992 /// This intrinsic corresponds to the <c> VMOVUPD / MOVUPD </c> instruction.
1993 ///
1994 /// \param __dp
1995 ///    A pointer to a 128-bit memory location. The address of the memory
1996 ///    location does not have to be aligned.
1997 /// \param __a
1998 ///    A 128-bit vector of [2 x double] containing the values to be stored.
1999 static __inline__ void __DEFAULT_FN_ATTRS
2000 _mm_storeu_pd(double *__dp, __m128d __a)
2001 {
2002   struct __storeu_pd {
2003     __m128d __v;
2004   } __attribute__((__packed__, __may_alias__));
2005   ((struct __storeu_pd*)__dp)->__v = __a;
2006 }
2007
2008 /// \brief Stores two double-precision values, in reverse order, from a 128-bit
2009 ///    vector of [2 x double] to a 16-byte aligned memory location.
2010 ///
2011 /// \headerfile <x86intrin.h>
2012 ///
2013 /// This intrinsic corresponds to a shuffling instruction followed by a
2014 /// <c> VMOVAPD / MOVAPD </c> instruction.
2015 ///
2016 /// \param __dp
2017 ///    A pointer to a 16-byte aligned memory location that can store two
2018 ///    double-precision values.
2019 /// \param __a
2020 ///    A 128-bit vector of [2 x double] containing the values to be reversed and
2021 ///    stored.
2022 static __inline__ void __DEFAULT_FN_ATTRS
2023 _mm_storer_pd(double *__dp, __m128d __a)
2024 {
2025   __a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 1, 0);
2026   *(__m128d *)__dp = __a;
2027 }
2028
2029 /// \brief Stores the upper 64 bits of a 128-bit vector of [2 x double] to a
2030 ///    memory location.
2031 ///
2032 /// \headerfile <x86intrin.h>
2033 ///
2034 /// This intrinsic corresponds to the <c> VMOVHPD / MOVHPD </c> instruction.
2035 ///
2036 /// \param __dp
2037 ///    A pointer to a 64-bit memory location.
2038 /// \param __a
2039 ///    A 128-bit vector of [2 x double] containing the value to be stored.
2040 static __inline__ void __DEFAULT_FN_ATTRS
2041 _mm_storeh_pd(double *__dp, __m128d __a)
2042 {
2043   struct __mm_storeh_pd_struct {
2044     double __u;
2045   } __attribute__((__packed__, __may_alias__));
2046   ((struct __mm_storeh_pd_struct*)__dp)->__u = __a[1];
2047 }
2048
2049 /// \brief Stores the lower 64 bits of a 128-bit vector of [2 x double] to a
2050 ///    memory location.
2051 ///
2052 /// \headerfile <x86intrin.h>
2053 ///
2054 /// This intrinsic corresponds to the <c> VMOVLPD / MOVLPD </c> instruction.
2055 ///
2056 /// \param __dp
2057 ///    A pointer to a 64-bit memory location.
2058 /// \param __a
2059 ///    A 128-bit vector of [2 x double] containing the value to be stored.
2060 static __inline__ void __DEFAULT_FN_ATTRS
2061 _mm_storel_pd(double *__dp, __m128d __a)
2062 {
2063   struct __mm_storeh_pd_struct {
2064     double __u;
2065   } __attribute__((__packed__, __may_alias__));
2066   ((struct __mm_storeh_pd_struct*)__dp)->__u = __a[0];
2067 }
2068
2069 /// \brief Adds the corresponding elements of two 128-bit vectors of [16 x i8],
2070 ///    saving the lower 8 bits of each sum in the corresponding element of a
2071 ///    128-bit result vector of [16 x i8].
2072 ///
2073 ///    The integer elements of both parameters can be either signed or unsigned.
2074 ///
2075 /// \headerfile <x86intrin.h>
2076 ///
2077 /// This intrinsic corresponds to the <c> VPADDB / PADDB </c> instruction.
2078 ///
2079 /// \param __a
2080 ///    A 128-bit vector of [16 x i8].
2081 /// \param __b
2082 ///    A 128-bit vector of [16 x i8].
2083 /// \returns A 128-bit vector of [16 x i8] containing the sums of both
2084 ///    parameters.
2085 static __inline__ __m128i __DEFAULT_FN_ATTRS
2086 _mm_add_epi8(__m128i __a, __m128i __b)
2087 {
2088   return (__m128i)((__v16qu)__a + (__v16qu)__b);
2089 }
2090
2091 /// \brief Adds the corresponding elements of two 128-bit vectors of [8 x i16],
2092 ///    saving the lower 16 bits of each sum in the corresponding element of a
2093 ///    128-bit result vector of [8 x i16].
2094 ///
2095 ///    The integer elements of both parameters can be either signed or unsigned.
2096 ///
2097 /// \headerfile <x86intrin.h>
2098 ///
2099 /// This intrinsic corresponds to the <c> VPADDW / PADDW </c> instruction.
2100 ///
2101 /// \param __a
2102 ///    A 128-bit vector of [8 x i16].
2103 /// \param __b
2104 ///    A 128-bit vector of [8 x i16].
2105 /// \returns A 128-bit vector of [8 x i16] containing the sums of both
2106 ///    parameters.
2107 static __inline__ __m128i __DEFAULT_FN_ATTRS
2108 _mm_add_epi16(__m128i __a, __m128i __b)
2109 {
2110   return (__m128i)((__v8hu)__a + (__v8hu)__b);
2111 }
2112
2113 /// \brief Adds the corresponding elements of two 128-bit vectors of [4 x i32],
2114 ///    saving the lower 32 bits of each sum in the corresponding element of a
2115 ///    128-bit result vector of [4 x i32].
2116 ///
2117 ///    The integer elements of both parameters can be either signed or unsigned.
2118 ///
2119 /// \headerfile <x86intrin.h>
2120 ///
2121 /// This intrinsic corresponds to the <c> VPADDD / PADDD </c> instruction.
2122 ///
2123 /// \param __a
2124 ///    A 128-bit vector of [4 x i32].
2125 /// \param __b
2126 ///    A 128-bit vector of [4 x i32].
2127 /// \returns A 128-bit vector of [4 x i32] containing the sums of both
2128 ///    parameters.
2129 static __inline__ __m128i __DEFAULT_FN_ATTRS
2130 _mm_add_epi32(__m128i __a, __m128i __b)
2131 {
2132   return (__m128i)((__v4su)__a + (__v4su)__b);
2133 }
2134
2135 /// \brief Adds two signed or unsigned 64-bit integer values, returning the
2136 ///    lower 64 bits of the sum.
2137 ///
2138 /// \headerfile <x86intrin.h>
2139 ///
2140 /// This intrinsic corresponds to the <c> PADDQ </c> instruction.
2141 ///
2142 /// \param __a
2143 ///    A 64-bit integer.
2144 /// \param __b
2145 ///    A 64-bit integer.
2146 /// \returns A 64-bit integer containing the sum of both parameters.
2147 static __inline__ __m64 __DEFAULT_FN_ATTRS
2148 _mm_add_si64(__m64 __a, __m64 __b)
2149 {
2150   return (__m64)__builtin_ia32_paddq((__v1di)__a, (__v1di)__b);
2151 }
2152
2153 /// \brief Adds the corresponding elements of two 128-bit vectors of [2 x i64],
2154 ///    saving the lower 64 bits of each sum in the corresponding element of a
2155 ///    128-bit result vector of [2 x i64].
2156 ///
2157 ///    The integer elements of both parameters can be either signed or unsigned.
2158 ///
2159 /// \headerfile <x86intrin.h>
2160 ///
2161 /// This intrinsic corresponds to the <c> VPADDQ / PADDQ </c> instruction.
2162 ///
2163 /// \param __a
2164 ///    A 128-bit vector of [2 x i64].
2165 /// \param __b
2166 ///    A 128-bit vector of [2 x i64].
2167 /// \returns A 128-bit vector of [2 x i64] containing the sums of both
2168 ///    parameters.
2169 static __inline__ __m128i __DEFAULT_FN_ATTRS
2170 _mm_add_epi64(__m128i __a, __m128i __b)
2171 {
2172   return (__m128i)((__v2du)__a + (__v2du)__b);
2173 }
2174
2175 /// \brief Adds, with saturation, the corresponding elements of two 128-bit
2176 ///    signed [16 x i8] vectors, saving each sum in the corresponding element of
2177 ///    a 128-bit result vector of [16 x i8]. Positive sums greater than 7Fh are
2178 ///    saturated to 7Fh. Negative sums less than 80h are saturated to 80h.
2179 ///
2180 /// \headerfile <x86intrin.h>
2181 ///
2182 /// This intrinsic corresponds to the <c> VPADDSB / PADDSB </c> instruction.
2183 ///
2184 /// \param __a
2185 ///    A 128-bit signed [16 x i8] vector.
2186 /// \param __b
2187 ///    A 128-bit signed [16 x i8] vector.
2188 /// \returns A 128-bit signed [16 x i8] vector containing the saturated sums of
2189 ///    both parameters.
2190 static __inline__ __m128i __DEFAULT_FN_ATTRS
2191 _mm_adds_epi8(__m128i __a, __m128i __b)
2192 {
2193   return (__m128i)__builtin_ia32_paddsb128((__v16qi)__a, (__v16qi)__b);
2194 }
2195
2196 /// \brief Adds, with saturation, the corresponding elements of two 128-bit
2197 ///    signed [8 x i16] vectors, saving each sum in the corresponding element of
2198 ///    a 128-bit result vector of [8 x i16]. Positive sums greater than 7FFFh
2199 ///    are saturated to 7FFFh. Negative sums less than 8000h are saturated to
2200 ///    8000h.
2201 ///
2202 /// \headerfile <x86intrin.h>
2203 ///
2204 /// This intrinsic corresponds to the <c> VPADDSW / PADDSW </c> instruction.
2205 ///
2206 /// \param __a
2207 ///    A 128-bit signed [8 x i16] vector.
2208 /// \param __b
2209 ///    A 128-bit signed [8 x i16] vector.
2210 /// \returns A 128-bit signed [8 x i16] vector containing the saturated sums of
2211 ///    both parameters.
2212 static __inline__ __m128i __DEFAULT_FN_ATTRS
2213 _mm_adds_epi16(__m128i __a, __m128i __b)
2214 {
2215   return (__m128i)__builtin_ia32_paddsw128((__v8hi)__a, (__v8hi)__b);
2216 }
2217
2218 /// \brief Adds, with saturation, the corresponding elements of two 128-bit
2219 ///    unsigned [16 x i8] vectors, saving each sum in the corresponding element
2220 ///    of a 128-bit result vector of [16 x i8]. Positive sums greater than FFh
2221 ///    are saturated to FFh. Negative sums are saturated to 00h.
2222 ///
2223 /// \headerfile <x86intrin.h>
2224 ///
2225 /// This intrinsic corresponds to the <c> VPADDUSB / PADDUSB </c> instruction.
2226 ///
2227 /// \param __a
2228 ///    A 128-bit unsigned [16 x i8] vector.
2229 /// \param __b
2230 ///    A 128-bit unsigned [16 x i8] vector.
2231 /// \returns A 128-bit unsigned [16 x i8] vector containing the saturated sums
2232 ///    of both parameters.
2233 static __inline__ __m128i __DEFAULT_FN_ATTRS
2234 _mm_adds_epu8(__m128i __a, __m128i __b)
2235 {
2236   return (__m128i)__builtin_ia32_paddusb128((__v16qi)__a, (__v16qi)__b);
2237 }
2238
2239 /// \brief Adds, with saturation, the corresponding elements of two 128-bit
2240 ///    unsigned [8 x i16] vectors, saving each sum in the corresponding element
2241 ///    of a 128-bit result vector of [8 x i16]. Positive sums greater than FFFFh
2242 ///    are saturated to FFFFh. Negative sums are saturated to 0000h.
2243 ///
2244 /// \headerfile <x86intrin.h>
2245 ///
2246 /// This intrinsic corresponds to the <c> VPADDUSB / PADDUSB </c> instruction.
2247 ///
2248 /// \param __a
2249 ///    A 128-bit unsigned [8 x i16] vector.
2250 /// \param __b
2251 ///    A 128-bit unsigned [8 x i16] vector.
2252 /// \returns A 128-bit unsigned [8 x i16] vector containing the saturated sums
2253 ///    of both parameters.
2254 static __inline__ __m128i __DEFAULT_FN_ATTRS
2255 _mm_adds_epu16(__m128i __a, __m128i __b)
2256 {
2257   return (__m128i)__builtin_ia32_paddusw128((__v8hi)__a, (__v8hi)__b);
2258 }
2259
2260 /// \brief Computes the rounded avarages of corresponding elements of two
2261 ///    128-bit unsigned [16 x i8] vectors, saving each result in the
2262 ///    corresponding element of a 128-bit result vector of [16 x i8].
2263 ///
2264 /// \headerfile <x86intrin.h>
2265 ///
2266 /// This intrinsic corresponds to the <c> VPAVGB / PAVGB </c> instruction.
2267 ///
2268 /// \param __a
2269 ///    A 128-bit unsigned [16 x i8] vector.
2270 /// \param __b
2271 ///    A 128-bit unsigned [16 x i8] vector.
2272 /// \returns A 128-bit unsigned [16 x i8] vector containing the rounded
2273 ///    averages of both parameters.
2274 static __inline__ __m128i __DEFAULT_FN_ATTRS
2275 _mm_avg_epu8(__m128i __a, __m128i __b)
2276 {
2277   typedef unsigned short __v16hu __attribute__ ((__vector_size__ (32)));
2278   return (__m128i)__builtin_convertvector(
2279                ((__builtin_convertvector((__v16qu)__a, __v16hu) +
2280                  __builtin_convertvector((__v16qu)__b, __v16hu)) + 1)
2281                  >> 1, __v16qu);
2282 }
2283
2284 /// \brief Computes the rounded avarages of corresponding elements of two
2285 ///    128-bit unsigned [8 x i16] vectors, saving each result in the
2286 ///    corresponding element of a 128-bit result vector of [8 x i16].
2287 ///
2288 /// \headerfile <x86intrin.h>
2289 ///
2290 /// This intrinsic corresponds to the <c> VPAVGW / PAVGW </c> instruction.
2291 ///
2292 /// \param __a
2293 ///    A 128-bit unsigned [8 x i16] vector.
2294 /// \param __b
2295 ///    A 128-bit unsigned [8 x i16] vector.
2296 /// \returns A 128-bit unsigned [8 x i16] vector containing the rounded
2297 ///    averages of both parameters.
2298 static __inline__ __m128i __DEFAULT_FN_ATTRS
2299 _mm_avg_epu16(__m128i __a, __m128i __b)
2300 {
2301   typedef unsigned int __v8su __attribute__ ((__vector_size__ (32)));
2302   return (__m128i)__builtin_convertvector(
2303                ((__builtin_convertvector((__v8hu)__a, __v8su) +
2304                  __builtin_convertvector((__v8hu)__b, __v8su)) + 1)
2305                  >> 1, __v8hu);
2306 }
2307
2308 /// \brief Multiplies the corresponding elements of two 128-bit signed [8 x i16]
2309 ///    vectors, producing eight intermediate 32-bit signed integer products, and
2310 ///    adds the consecutive pairs of 32-bit products to form a 128-bit signed
2311 ///    [4 x i32] vector.
2312 ///
2313 ///    For example, bits [15:0] of both parameters are multiplied producing a
2314 ///    32-bit product, bits [31:16] of both parameters are multiplied producing
2315 ///    a 32-bit product, and the sum of those two products becomes bits [31:0]
2316 ///    of the result.
2317 ///
2318 /// \headerfile <x86intrin.h>
2319 ///
2320 /// This intrinsic corresponds to the <c> VPMADDWD / PMADDWD </c> instruction.
2321 ///
2322 /// \param __a
2323 ///    A 128-bit signed [8 x i16] vector.
2324 /// \param __b
2325 ///    A 128-bit signed [8 x i16] vector.
2326 /// \returns A 128-bit signed [4 x i32] vector containing the sums of products
2327 ///    of both parameters.
2328 static __inline__ __m128i __DEFAULT_FN_ATTRS
2329 _mm_madd_epi16(__m128i __a, __m128i __b)
2330 {
2331   return (__m128i)__builtin_ia32_pmaddwd128((__v8hi)__a, (__v8hi)__b);
2332 }
2333
2334 /// \brief Compares corresponding elements of two 128-bit signed [8 x i16]
2335 ///    vectors, saving the greater value from each comparison in the
2336 ///    corresponding element of a 128-bit result vector of [8 x i16].
2337 ///
2338 /// \headerfile <x86intrin.h>
2339 ///
2340 /// This intrinsic corresponds to the <c> VPMAXSW / PMAXSW </c> instruction.
2341 ///
2342 /// \param __a
2343 ///    A 128-bit signed [8 x i16] vector.
2344 /// \param __b
2345 ///    A 128-bit signed [8 x i16] vector.
2346 /// \returns A 128-bit signed [8 x i16] vector containing the greater value of
2347 ///    each comparison.
2348 static __inline__ __m128i __DEFAULT_FN_ATTRS
2349 _mm_max_epi16(__m128i __a, __m128i __b)
2350 {
2351   return (__m128i)__builtin_ia32_pmaxsw128((__v8hi)__a, (__v8hi)__b);
2352 }
2353
2354 /// \brief Compares corresponding elements of two 128-bit unsigned [16 x i8]
2355 ///    vectors, saving the greater value from each comparison in the
2356 ///    corresponding element of a 128-bit result vector of [16 x i8].
2357 ///
2358 /// \headerfile <x86intrin.h>
2359 ///
2360 /// This intrinsic corresponds to the <c> VPMAXUB / PMAXUB </c> instruction.
2361 ///
2362 /// \param __a
2363 ///    A 128-bit unsigned [16 x i8] vector.
2364 /// \param __b
2365 ///    A 128-bit unsigned [16 x i8] vector.
2366 /// \returns A 128-bit unsigned [16 x i8] vector containing the greater value of
2367 ///    each comparison.
2368 static __inline__ __m128i __DEFAULT_FN_ATTRS
2369 _mm_max_epu8(__m128i __a, __m128i __b)
2370 {
2371   return (__m128i)__builtin_ia32_pmaxub128((__v16qi)__a, (__v16qi)__b);
2372 }
2373
2374 /// \brief Compares corresponding elements of two 128-bit signed [8 x i16]
2375 ///    vectors, saving the smaller value from each comparison in the
2376 ///    corresponding element of a 128-bit result vector of [8 x i16].
2377 ///
2378 /// \headerfile <x86intrin.h>
2379 ///
2380 /// This intrinsic corresponds to the <c> VPMINSW / PMINSW </c> instruction.
2381 ///
2382 /// \param __a
2383 ///    A 128-bit signed [8 x i16] vector.
2384 /// \param __b
2385 ///    A 128-bit signed [8 x i16] vector.
2386 /// \returns A 128-bit signed [8 x i16] vector containing the smaller value of
2387 ///    each comparison.
2388 static __inline__ __m128i __DEFAULT_FN_ATTRS
2389 _mm_min_epi16(__m128i __a, __m128i __b)
2390 {
2391   return (__m128i)__builtin_ia32_pminsw128((__v8hi)__a, (__v8hi)__b);
2392 }
2393
2394 /// \brief Compares corresponding elements of two 128-bit unsigned [16 x i8]
2395 ///    vectors, saving the smaller value from each comparison in the
2396 ///    corresponding element of a 128-bit result vector of [16 x i8].
2397 ///
2398 /// \headerfile <x86intrin.h>
2399 ///
2400 /// This intrinsic corresponds to the <c> VPMINUB / PMINUB </c> instruction.
2401 ///
2402 /// \param __a
2403 ///    A 128-bit unsigned [16 x i8] vector.
2404 /// \param __b
2405 ///    A 128-bit unsigned [16 x i8] vector.
2406 /// \returns A 128-bit unsigned [16 x i8] vector containing the smaller value of
2407 ///    each comparison.
2408 static __inline__ __m128i __DEFAULT_FN_ATTRS
2409 _mm_min_epu8(__m128i __a, __m128i __b)
2410 {
2411   return (__m128i)__builtin_ia32_pminub128((__v16qi)__a, (__v16qi)__b);
2412 }
2413
2414 /// \brief Multiplies the corresponding elements of two signed [8 x i16]
2415 ///    vectors, saving the upper 16 bits of each 32-bit product in the
2416 ///    corresponding element of a 128-bit signed [8 x i16] result vector.
2417 ///
2418 /// \headerfile <x86intrin.h>
2419 ///
2420 /// This intrinsic corresponds to the <c> VPMULHW / PMULHW </c> instruction.
2421 ///
2422 /// \param __a
2423 ///    A 128-bit signed [8 x i16] vector.
2424 /// \param __b
2425 ///    A 128-bit signed [8 x i16] vector.
2426 /// \returns A 128-bit signed [8 x i16] vector containing the upper 16 bits of
2427 ///    each of the eight 32-bit products.
2428 static __inline__ __m128i __DEFAULT_FN_ATTRS
2429 _mm_mulhi_epi16(__m128i __a, __m128i __b)
2430 {
2431   return (__m128i)__builtin_ia32_pmulhw128((__v8hi)__a, (__v8hi)__b);
2432 }
2433
2434 /// \brief Multiplies the corresponding elements of two unsigned [8 x i16]
2435 ///    vectors, saving the upper 16 bits of each 32-bit product in the
2436 ///    corresponding element of a 128-bit unsigned [8 x i16] result vector.
2437 ///
2438 /// \headerfile <x86intrin.h>
2439 ///
2440 /// This intrinsic corresponds to the <c> VPMULHUW / PMULHUW </c> instruction.
2441 ///
2442 /// \param __a
2443 ///    A 128-bit unsigned [8 x i16] vector.
2444 /// \param __b
2445 ///    A 128-bit unsigned [8 x i16] vector.
2446 /// \returns A 128-bit unsigned [8 x i16] vector containing the upper 16 bits
2447 ///    of each of the eight 32-bit products.
2448 static __inline__ __m128i __DEFAULT_FN_ATTRS
2449 _mm_mulhi_epu16(__m128i __a, __m128i __b)
2450 {
2451   return (__m128i)__builtin_ia32_pmulhuw128((__v8hi)__a, (__v8hi)__b);
2452 }
2453
2454 /// \brief Multiplies the corresponding elements of two signed [8 x i16]
2455 ///    vectors, saving the lower 16 bits of each 32-bit product in the
2456 ///    corresponding element of a 128-bit signed [8 x i16] result vector.
2457 ///
2458 /// \headerfile <x86intrin.h>
2459 ///
2460 /// This intrinsic corresponds to the <c> VPMULLW / PMULLW </c> instruction.
2461 ///
2462 /// \param __a
2463 ///    A 128-bit signed [8 x i16] vector.
2464 /// \param __b
2465 ///    A 128-bit signed [8 x i16] vector.
2466 /// \returns A 128-bit signed [8 x i16] vector containing the lower 16 bits of
2467 ///    each of the eight 32-bit products.
2468 static __inline__ __m128i __DEFAULT_FN_ATTRS
2469 _mm_mullo_epi16(__m128i __a, __m128i __b)
2470 {
2471   return (__m128i)((__v8hu)__a * (__v8hu)__b);
2472 }
2473
2474 /// \brief Multiplies 32-bit unsigned integer values contained in the lower bits
2475 ///    of the two 64-bit integer vectors and returns the 64-bit unsigned
2476 ///    product.
2477 ///
2478 /// \headerfile <x86intrin.h>
2479 ///
2480 /// This intrinsic corresponds to the <c> PMULUDQ </c> instruction.
2481 ///
2482 /// \param __a
2483 ///    A 64-bit integer containing one of the source operands.
2484 /// \param __b
2485 ///    A 64-bit integer containing one of the source operands.
2486 /// \returns A 64-bit integer vector containing the product of both operands.
2487 static __inline__ __m64 __DEFAULT_FN_ATTRS
2488 _mm_mul_su32(__m64 __a, __m64 __b)
2489 {
2490   return __builtin_ia32_pmuludq((__v2si)__a, (__v2si)__b);
2491 }
2492
2493 /// \brief Multiplies 32-bit unsigned integer values contained in the lower
2494 ///    bits of the corresponding elements of two [2 x i64] vectors, and returns
2495 ///    the 64-bit products in the corresponding elements of a [2 x i64] vector.
2496 ///
2497 /// \headerfile <x86intrin.h>
2498 ///
2499 /// This intrinsic corresponds to the <c> VPMULUDQ / PMULUDQ </c> instruction.
2500 ///
2501 /// \param __a
2502 ///    A [2 x i64] vector containing one of the source operands.
2503 /// \param __b
2504 ///    A [2 x i64] vector containing one of the source operands.
2505 /// \returns A [2 x i64] vector containing the product of both operands.
2506 static __inline__ __m128i __DEFAULT_FN_ATTRS
2507 _mm_mul_epu32(__m128i __a, __m128i __b)
2508 {
2509   return __builtin_ia32_pmuludq128((__v4si)__a, (__v4si)__b);
2510 }
2511
2512 /// \brief Computes the absolute differences of corresponding 8-bit integer
2513 ///    values in two 128-bit vectors. Sums the first 8 absolute differences, and
2514 ///    separately sums the second 8 absolute differences. Packs these two
2515 ///    unsigned 16-bit integer sums into the upper and lower elements of a
2516 ///    [2 x i64] vector.
2517 ///
2518 /// \headerfile <x86intrin.h>
2519 ///
2520 /// This intrinsic corresponds to the <c> VPSADBW / PSADBW </c> instruction.
2521 ///
2522 /// \param __a
2523 ///    A 128-bit integer vector containing one of the source operands.
2524 /// \param __b
2525 ///    A 128-bit integer vector containing one of the source operands.
2526 /// \returns A [2 x i64] vector containing the sums of the sets of absolute
2527 ///    differences between both operands.
2528 static __inline__ __m128i __DEFAULT_FN_ATTRS
2529 _mm_sad_epu8(__m128i __a, __m128i __b)
2530 {
2531   return __builtin_ia32_psadbw128((__v16qi)__a, (__v16qi)__b);
2532 }
2533
2534 /// \brief Subtracts the corresponding 8-bit integer values in the operands.
2535 ///
2536 /// \headerfile <x86intrin.h>
2537 ///
2538 /// This intrinsic corresponds to the <c> VPSUBB / PSUBB </c> instruction.
2539 ///
2540 /// \param __a
2541 ///    A 128-bit integer vector containing the minuends.
2542 /// \param __b
2543 ///    A 128-bit integer vector containing the subtrahends.
2544 /// \returns A 128-bit integer vector containing the differences of the values
2545 ///    in the operands.
2546 static __inline__ __m128i __DEFAULT_FN_ATTRS
2547 _mm_sub_epi8(__m128i __a, __m128i __b)
2548 {
2549   return (__m128i)((__v16qu)__a - (__v16qu)__b);
2550 }
2551
2552 /// \brief Subtracts the corresponding 16-bit integer values in the operands.
2553 ///
2554 /// \headerfile <x86intrin.h>
2555 ///
2556 /// This intrinsic corresponds to the <c> VPSUBW / PSUBW </c> instruction.
2557 ///
2558 /// \param __a
2559 ///    A 128-bit integer vector containing the minuends.
2560 /// \param __b
2561 ///    A 128-bit integer vector containing the subtrahends.
2562 /// \returns A 128-bit integer vector containing the differences of the values
2563 ///    in the operands.
2564 static __inline__ __m128i __DEFAULT_FN_ATTRS
2565 _mm_sub_epi16(__m128i __a, __m128i __b)
2566 {
2567   return (__m128i)((__v8hu)__a - (__v8hu)__b);
2568 }
2569
2570 /// \brief Subtracts the corresponding 32-bit integer values in the operands.
2571 ///
2572 /// \headerfile <x86intrin.h>
2573 ///
2574 /// This intrinsic corresponds to the <c> VPSUBD / PSUBD </c> instruction.
2575 ///
2576 /// \param __a
2577 ///    A 128-bit integer vector containing the minuends.
2578 /// \param __b
2579 ///    A 128-bit integer vector containing the subtrahends.
2580 /// \returns A 128-bit integer vector containing the differences of the values
2581 ///    in the operands.
2582 static __inline__ __m128i __DEFAULT_FN_ATTRS
2583 _mm_sub_epi32(__m128i __a, __m128i __b)
2584 {
2585   return (__m128i)((__v4su)__a - (__v4su)__b);
2586 }
2587
2588 /// \brief Subtracts signed or unsigned 64-bit integer values and writes the
2589 ///    difference to the corresponding bits in the destination.
2590 ///
2591 /// \headerfile <x86intrin.h>
2592 ///
2593 /// This intrinsic corresponds to the <c> PSUBQ </c> instruction.
2594 ///
2595 /// \param __a
2596 ///    A 64-bit integer vector containing the minuend.
2597 /// \param __b
2598 ///    A 64-bit integer vector containing the subtrahend.
2599 /// \returns A 64-bit integer vector containing the difference of the values in
2600 ///    the operands.
2601 static __inline__ __m64 __DEFAULT_FN_ATTRS
2602 _mm_sub_si64(__m64 __a, __m64 __b)
2603 {
2604   return (__m64)__builtin_ia32_psubq((__v1di)__a, (__v1di)__b);
2605 }
2606
2607 /// \brief Subtracts the corresponding elements of two [2 x i64] vectors.
2608 ///
2609 /// \headerfile <x86intrin.h>
2610 ///
2611 /// This intrinsic corresponds to the <c> VPSUBQ / PSUBQ </c> instruction.
2612 ///
2613 /// \param __a
2614 ///    A 128-bit integer vector containing the minuends.
2615 /// \param __b
2616 ///    A 128-bit integer vector containing the subtrahends.
2617 /// \returns A 128-bit integer vector containing the differences of the values
2618 ///    in the operands.
2619 static __inline__ __m128i __DEFAULT_FN_ATTRS
2620 _mm_sub_epi64(__m128i __a, __m128i __b)
2621 {
2622   return (__m128i)((__v2du)__a - (__v2du)__b);
2623 }
2624
2625 /// \brief Subtracts corresponding 8-bit signed integer values in the input and
2626 ///    returns the differences in the corresponding bytes in the destination.
2627 ///    Differences greater than 7Fh are saturated to 7Fh, and differences less
2628 ///    than 80h are saturated to 80h.
2629 ///
2630 /// \headerfile <x86intrin.h>
2631 ///
2632 /// This intrinsic corresponds to the <c> VPSUBSB / PSUBSB </c> instruction.
2633 ///
2634 /// \param __a
2635 ///    A 128-bit integer vector containing the minuends.
2636 /// \param __b
2637 ///    A 128-bit integer vector containing the subtrahends.
2638 /// \returns A 128-bit integer vector containing the differences of the values
2639 ///    in the operands.
2640 static __inline__ __m128i __DEFAULT_FN_ATTRS
2641 _mm_subs_epi8(__m128i __a, __m128i __b)
2642 {
2643   return (__m128i)__builtin_ia32_psubsb128((__v16qi)__a, (__v16qi)__b);
2644 }
2645
2646 /// \brief Subtracts corresponding 16-bit signed integer values in the input and
2647 ///    returns the differences in the corresponding bytes in the destination.
2648 ///    Differences greater than 7FFFh are saturated to 7FFFh, and values less
2649 ///    than 8000h are saturated to 8000h.
2650 ///
2651 /// \headerfile <x86intrin.h>
2652 ///
2653 /// This intrinsic corresponds to the <c> VPSUBSW / PSUBSW </c> instruction.
2654 ///
2655 /// \param __a
2656 ///    A 128-bit integer vector containing the minuends.
2657 /// \param __b
2658 ///    A 128-bit integer vector containing the subtrahends.
2659 /// \returns A 128-bit integer vector containing the differences of the values
2660 ///    in the operands.
2661 static __inline__ __m128i __DEFAULT_FN_ATTRS
2662 _mm_subs_epi16(__m128i __a, __m128i __b)
2663 {
2664   return (__m128i)__builtin_ia32_psubsw128((__v8hi)__a, (__v8hi)__b);
2665 }
2666
2667 /// \brief Subtracts corresponding 8-bit unsigned integer values in the input
2668 ///    and returns the differences in the corresponding bytes in the
2669 ///    destination. Differences less than 00h are saturated to 00h.
2670 ///
2671 /// \headerfile <x86intrin.h>
2672 ///
2673 /// This intrinsic corresponds to the <c> VPSUBUSB / PSUBUSB </c> instruction.
2674 ///
2675 /// \param __a
2676 ///    A 128-bit integer vector containing the minuends.
2677 /// \param __b
2678 ///    A 128-bit integer vector containing the subtrahends.
2679 /// \returns A 128-bit integer vector containing the unsigned integer
2680 ///    differences of the values in the operands.
2681 static __inline__ __m128i __DEFAULT_FN_ATTRS
2682 _mm_subs_epu8(__m128i __a, __m128i __b)
2683 {
2684   return (__m128i)__builtin_ia32_psubusb128((__v16qi)__a, (__v16qi)__b);
2685 }
2686
2687 /// \brief Subtracts corresponding 16-bit unsigned integer values in the input
2688 ///    and returns the differences in the corresponding bytes in the
2689 ///    destination. Differences less than 0000h are saturated to 0000h.
2690 ///
2691 /// \headerfile <x86intrin.h>
2692 ///
2693 /// This intrinsic corresponds to the <c> VPSUBUSW / PSUBUSW </c> instruction.
2694 ///
2695 /// \param __a
2696 ///    A 128-bit integer vector containing the minuends.
2697 /// \param __b
2698 ///    A 128-bit integer vector containing the subtrahends.
2699 /// \returns A 128-bit integer vector containing the unsigned integer
2700 ///    differences of the values in the operands.
2701 static __inline__ __m128i __DEFAULT_FN_ATTRS
2702 _mm_subs_epu16(__m128i __a, __m128i __b)
2703 {
2704   return (__m128i)__builtin_ia32_psubusw128((__v8hi)__a, (__v8hi)__b);
2705 }
2706
2707 /// \brief Performs a bitwise AND of two 128-bit integer vectors.
2708 ///
2709 /// \headerfile <x86intrin.h>
2710 ///
2711 /// This intrinsic corresponds to the <c> VPAND / PAND </c> instruction.
2712 ///
2713 /// \param __a
2714 ///    A 128-bit integer vector containing one of the source operands.
2715 /// \param __b
2716 ///    A 128-bit integer vector containing one of the source operands.
2717 /// \returns A 128-bit integer vector containing the bitwise AND of the values
2718 ///    in both operands.
2719 static __inline__ __m128i __DEFAULT_FN_ATTRS
2720 _mm_and_si128(__m128i __a, __m128i __b)
2721 {
2722   return (__m128i)((__v2du)__a & (__v2du)__b);
2723 }
2724
2725 /// \brief Performs a bitwise AND of two 128-bit integer vectors, using the
2726 ///    one's complement of the values contained in the first source operand.
2727 ///
2728 /// \headerfile <x86intrin.h>
2729 ///
2730 /// This intrinsic corresponds to the <c> VPANDN / PANDN </c> instruction.
2731 ///
2732 /// \param __a
2733 ///    A 128-bit vector containing the left source operand. The one's complement
2734 ///    of this value is used in the bitwise AND.
2735 /// \param __b
2736 ///    A 128-bit vector containing the right source operand.
2737 /// \returns A 128-bit integer vector containing the bitwise AND of the one's
2738 ///    complement of the first operand and the values in the second operand.
2739 static __inline__ __m128i __DEFAULT_FN_ATTRS
2740 _mm_andnot_si128(__m128i __a, __m128i __b)
2741 {
2742   return (__m128i)(~(__v2du)__a & (__v2du)__b);
2743 }
2744 /// \brief Performs a bitwise OR of two 128-bit integer vectors.
2745 ///
2746 /// \headerfile <x86intrin.h>
2747 ///
2748 /// This intrinsic corresponds to the <c> VPOR / POR </c> instruction.
2749 ///
2750 /// \param __a
2751 ///    A 128-bit integer vector containing one of the source operands.
2752 /// \param __b
2753 ///    A 128-bit integer vector containing one of the source operands.
2754 /// \returns A 128-bit integer vector containing the bitwise OR of the values
2755 ///    in both operands.
2756 static __inline__ __m128i __DEFAULT_FN_ATTRS
2757 _mm_or_si128(__m128i __a, __m128i __b)
2758 {
2759   return (__m128i)((__v2du)__a | (__v2du)__b);
2760 }
2761
2762 /// \brief Performs a bitwise exclusive OR of two 128-bit integer vectors.
2763 ///
2764 /// \headerfile <x86intrin.h>
2765 ///
2766 /// This intrinsic corresponds to the <c> VPXOR / PXOR </c> instruction.
2767 ///
2768 /// \param __a
2769 ///    A 128-bit integer vector containing one of the source operands.
2770 /// \param __b
2771 ///    A 128-bit integer vector containing one of the source operands.
2772 /// \returns A 128-bit integer vector containing the bitwise exclusive OR of the
2773 ///    values in both operands.
2774 static __inline__ __m128i __DEFAULT_FN_ATTRS
2775 _mm_xor_si128(__m128i __a, __m128i __b)
2776 {
2777   return (__m128i)((__v2du)__a ^ (__v2du)__b);
2778 }
2779
2780 /// \brief Left-shifts the 128-bit integer vector operand by the specified
2781 ///    number of bytes. Low-order bits are cleared.
2782 ///
2783 /// \headerfile <x86intrin.h>
2784 ///
2785 /// \code
2786 /// __m128i _mm_slli_si128(__m128i a, const int imm);
2787 /// \endcode
2788 ///
2789 /// This intrinsic corresponds to the <c> VPSLLDQ / PSLLDQ </c> instruction.
2790 ///
2791 /// \param a
2792 ///    A 128-bit integer vector containing the source operand.
2793 /// \param imm
2794 ///    An immediate value specifying the number of bytes to left-shift operand
2795 ///    \a a.
2796 /// \returns A 128-bit integer vector containing the left-shifted value.
2797 #define _mm_slli_si128(a, imm) __extension__ ({                              \
2798   (__m128i)__builtin_shufflevector(                                          \
2799                                  (__v16qi)_mm_setzero_si128(),               \
2800                                  (__v16qi)(__m128i)(a),                      \
2801                                  ((char)(imm)&0xF0) ?  0 : 16 - (char)(imm), \
2802                                  ((char)(imm)&0xF0) ?  1 : 17 - (char)(imm), \
2803                                  ((char)(imm)&0xF0) ?  2 : 18 - (char)(imm), \
2804                                  ((char)(imm)&0xF0) ?  3 : 19 - (char)(imm), \
2805                                  ((char)(imm)&0xF0) ?  4 : 20 - (char)(imm), \
2806                                  ((char)(imm)&0xF0) ?  5 : 21 - (char)(imm), \
2807                                  ((char)(imm)&0xF0) ?  6 : 22 - (char)(imm), \
2808                                  ((char)(imm)&0xF0) ?  7 : 23 - (char)(imm), \
2809                                  ((char)(imm)&0xF0) ?  8 : 24 - (char)(imm), \
2810                                  ((char)(imm)&0xF0) ?  9 : 25 - (char)(imm), \
2811                                  ((char)(imm)&0xF0) ? 10 : 26 - (char)(imm), \
2812                                  ((char)(imm)&0xF0) ? 11 : 27 - (char)(imm), \
2813                                  ((char)(imm)&0xF0) ? 12 : 28 - (char)(imm), \
2814                                  ((char)(imm)&0xF0) ? 13 : 29 - (char)(imm), \
2815                                  ((char)(imm)&0xF0) ? 14 : 30 - (char)(imm), \
2816                                  ((char)(imm)&0xF0) ? 15 : 31 - (char)(imm)); })
2817
2818 #define _mm_bslli_si128(a, imm) \
2819   _mm_slli_si128((a), (imm))
2820
2821 /// \brief Left-shifts each 16-bit value in the 128-bit integer vector operand
2822 ///    by the specified number of bits. Low-order bits are cleared.
2823 ///
2824 /// \headerfile <x86intrin.h>
2825 ///
2826 /// This intrinsic corresponds to the <c> VPSLLW / PSLLW </c> instruction.
2827 ///
2828 /// \param __a
2829 ///    A 128-bit integer vector containing the source operand.
2830 /// \param __count
2831 ///    An integer value specifying the number of bits to left-shift each value
2832 ///    in operand \a __a.
2833 /// \returns A 128-bit integer vector containing the left-shifted values.
2834 static __inline__ __m128i __DEFAULT_FN_ATTRS
2835 _mm_slli_epi16(__m128i __a, int __count)
2836 {
2837   return (__m128i)__builtin_ia32_psllwi128((__v8hi)__a, __count);
2838 }
2839
2840 /// \brief Left-shifts each 16-bit value in the 128-bit integer vector operand
2841 ///    by the specified number of bits. Low-order bits are cleared.
2842 ///
2843 /// \headerfile <x86intrin.h>
2844 ///
2845 /// This intrinsic corresponds to the <c> VPSLLW / PSLLW </c> instruction.
2846 ///
2847 /// \param __a
2848 ///    A 128-bit integer vector containing the source operand.
2849 /// \param __count
2850 ///    A 128-bit integer vector in which bits [63:0] specify the number of bits
2851 ///    to left-shift each value in operand \a __a.
2852 /// \returns A 128-bit integer vector containing the left-shifted values.
2853 static __inline__ __m128i __DEFAULT_FN_ATTRS
2854 _mm_sll_epi16(__m128i __a, __m128i __count)
2855 {
2856   return (__m128i)__builtin_ia32_psllw128((__v8hi)__a, (__v8hi)__count);
2857 }
2858
2859 /// \brief Left-shifts each 32-bit value in the 128-bit integer vector operand
2860 ///    by the specified number of bits. Low-order bits are cleared.
2861 ///
2862 /// \headerfile <x86intrin.h>
2863 ///
2864 /// This intrinsic corresponds to the <c> VPSLLD / PSLLD </c> instruction.
2865 ///
2866 /// \param __a
2867 ///    A 128-bit integer vector containing the source operand.
2868 /// \param __count
2869 ///    An integer value specifying the number of bits to left-shift each value
2870 ///    in operand \a __a.
2871 /// \returns A 128-bit integer vector containing the left-shifted values.
2872 static __inline__ __m128i __DEFAULT_FN_ATTRS
2873 _mm_slli_epi32(__m128i __a, int __count)
2874 {
2875   return (__m128i)__builtin_ia32_pslldi128((__v4si)__a, __count);
2876 }
2877
2878 /// \brief Left-shifts each 32-bit value in the 128-bit integer vector operand
2879 ///    by the specified number of bits. Low-order bits are cleared.
2880 ///
2881 /// \headerfile <x86intrin.h>
2882 ///
2883 /// This intrinsic corresponds to the <c> VPSLLD / PSLLD </c> instruction.
2884 ///
2885 /// \param __a
2886 ///    A 128-bit integer vector containing the source operand.
2887 /// \param __count
2888 ///    A 128-bit integer vector in which bits [63:0] specify the number of bits
2889 ///    to left-shift each value in operand \a __a.
2890 /// \returns A 128-bit integer vector containing the left-shifted values.
2891 static __inline__ __m128i __DEFAULT_FN_ATTRS
2892 _mm_sll_epi32(__m128i __a, __m128i __count)
2893 {
2894   return (__m128i)__builtin_ia32_pslld128((__v4si)__a, (__v4si)__count);
2895 }
2896
2897 /// \brief Left-shifts each 64-bit value in the 128-bit integer vector operand
2898 ///    by the specified number of bits. Low-order bits are cleared.
2899 ///
2900 /// \headerfile <x86intrin.h>
2901 ///
2902 /// This intrinsic corresponds to the <c> VPSLLQ / PSLLQ </c> instruction.
2903 ///
2904 /// \param __a
2905 ///    A 128-bit integer vector containing the source operand.
2906 /// \param __count
2907 ///    An integer value specifying the number of bits to left-shift each value
2908 ///    in operand \a __a.
2909 /// \returns A 128-bit integer vector containing the left-shifted values.
2910 static __inline__ __m128i __DEFAULT_FN_ATTRS
2911 _mm_slli_epi64(__m128i __a, int __count)
2912 {
2913   return __builtin_ia32_psllqi128((__v2di)__a, __count);
2914 }
2915
2916 /// \brief Left-shifts each 64-bit value in the 128-bit integer vector operand
2917 ///    by the specified number of bits. Low-order bits are cleared.
2918 ///
2919 /// \headerfile <x86intrin.h>
2920 ///
2921 /// This intrinsic corresponds to the <c> VPSLLQ / PSLLQ </c> instruction.
2922 ///
2923 /// \param __a
2924 ///    A 128-bit integer vector containing the source operand.
2925 /// \param __count
2926 ///    A 128-bit integer vector in which bits [63:0] specify the number of bits
2927 ///    to left-shift each value in operand \a __a.
2928 /// \returns A 128-bit integer vector containing the left-shifted values.
2929 static __inline__ __m128i __DEFAULT_FN_ATTRS
2930 _mm_sll_epi64(__m128i __a, __m128i __count)
2931 {
2932   return __builtin_ia32_psllq128((__v2di)__a, (__v2di)__count);
2933 }
2934
2935 /// \brief Right-shifts each 16-bit value in the 128-bit integer vector operand
2936 ///    by the specified number of bits. High-order bits are filled with the sign
2937 ///    bit of the initial value.
2938 ///
2939 /// \headerfile <x86intrin.h>
2940 ///
2941 /// This intrinsic corresponds to the <c> VPSRAW / PSRAW </c> instruction.
2942 ///
2943 /// \param __a
2944 ///    A 128-bit integer vector containing the source operand.
2945 /// \param __count
2946 ///    An integer value specifying the number of bits to right-shift each value
2947 ///    in operand \a __a.
2948 /// \returns A 128-bit integer vector containing the right-shifted values.
2949 static __inline__ __m128i __DEFAULT_FN_ATTRS
2950 _mm_srai_epi16(__m128i __a, int __count)
2951 {
2952   return (__m128i)__builtin_ia32_psrawi128((__v8hi)__a, __count);
2953 }
2954
2955 /// \brief Right-shifts each 16-bit value in the 128-bit integer vector operand
2956 ///    by the specified number of bits. High-order bits are filled with the sign
2957 ///    bit of the initial value.
2958 ///
2959 /// \headerfile <x86intrin.h>
2960 ///
2961 /// This intrinsic corresponds to the <c> VPSRAW / PSRAW </c> instruction.
2962 ///
2963 /// \param __a
2964 ///    A 128-bit integer vector containing the source operand.
2965 /// \param __count
2966 ///    A 128-bit integer vector in which bits [63:0] specify the number of bits
2967 ///    to right-shift each value in operand \a __a.
2968 /// \returns A 128-bit integer vector containing the right-shifted values.
2969 static __inline__ __m128i __DEFAULT_FN_ATTRS
2970 _mm_sra_epi16(__m128i __a, __m128i __count)
2971 {
2972   return (__m128i)__builtin_ia32_psraw128((__v8hi)__a, (__v8hi)__count);
2973 }
2974
2975 /// \brief Right-shifts each 32-bit value in the 128-bit integer vector operand
2976 ///    by the specified number of bits. High-order bits are filled with the sign
2977 ///    bit of the initial value.
2978 ///
2979 /// \headerfile <x86intrin.h>
2980 ///
2981 /// This intrinsic corresponds to the <c> VPSRAD / PSRAD </c> instruction.
2982 ///
2983 /// \param __a
2984 ///    A 128-bit integer vector containing the source operand.
2985 /// \param __count
2986 ///    An integer value specifying the number of bits to right-shift each value
2987 ///    in operand \a __a.
2988 /// \returns A 128-bit integer vector containing the right-shifted values.
2989 static __inline__ __m128i __DEFAULT_FN_ATTRS
2990 _mm_srai_epi32(__m128i __a, int __count)
2991 {
2992   return (__m128i)__builtin_ia32_psradi128((__v4si)__a, __count);
2993 }
2994
2995 /// \brief Right-shifts each 32-bit value in the 128-bit integer vector operand
2996 ///    by the specified number of bits. High-order bits are filled with the sign
2997 ///    bit of the initial value.
2998 ///
2999 /// \headerfile <x86intrin.h>
3000 ///
3001 /// This intrinsic corresponds to the <c> VPSRAD / PSRAD </c> instruction.
3002 ///
3003 /// \param __a
3004 ///    A 128-bit integer vector containing the source operand.
3005 /// \param __count
3006 ///    A 128-bit integer vector in which bits [63:0] specify the number of bits
3007 ///    to right-shift each value in operand \a __a.
3008 /// \returns A 128-bit integer vector containing the right-shifted values.
3009 static __inline__ __m128i __DEFAULT_FN_ATTRS
3010 _mm_sra_epi32(__m128i __a, __m128i __count)
3011 {
3012   return (__m128i)__builtin_ia32_psrad128((__v4si)__a, (__v4si)__count);
3013 }
3014
3015 /// \brief Right-shifts the 128-bit integer vector operand by the specified
3016 ///    number of bytes. High-order bits are cleared.
3017 ///
3018 /// \headerfile <x86intrin.h>
3019 ///
3020 /// \code
3021 /// __m128i _mm_srli_si128(__m128i a, const int imm);
3022 /// \endcode
3023 ///
3024 /// This intrinsic corresponds to the <c> VPSRLDQ / PSRLDQ </c> instruction.
3025 ///
3026 /// \param a
3027 ///    A 128-bit integer vector containing the source operand.
3028 /// \param imm
3029 ///    An immediate value specifying the number of bytes to right-shift operand
3030 ///    \a a.
3031 /// \returns A 128-bit integer vector containing the right-shifted value.
3032 #define _mm_srli_si128(a, imm) __extension__ ({                              \
3033   (__m128i)__builtin_shufflevector(                                          \
3034                                  (__v16qi)(__m128i)(a),                      \
3035                                  (__v16qi)_mm_setzero_si128(),               \
3036                                  ((char)(imm)&0xF0) ? 16 : (char)(imm) + 0,  \
3037                                  ((char)(imm)&0xF0) ? 17 : (char)(imm) + 1,  \
3038                                  ((char)(imm)&0xF0) ? 18 : (char)(imm) + 2,  \
3039                                  ((char)(imm)&0xF0) ? 19 : (char)(imm) + 3,  \
3040                                  ((char)(imm)&0xF0) ? 20 : (char)(imm) + 4,  \
3041                                  ((char)(imm)&0xF0) ? 21 : (char)(imm) + 5,  \
3042                                  ((char)(imm)&0xF0) ? 22 : (char)(imm) + 6,  \
3043                                  ((char)(imm)&0xF0) ? 23 : (char)(imm) + 7,  \
3044                                  ((char)(imm)&0xF0) ? 24 : (char)(imm) + 8,  \
3045                                  ((char)(imm)&0xF0) ? 25 : (char)(imm) + 9,  \
3046                                  ((char)(imm)&0xF0) ? 26 : (char)(imm) + 10, \
3047                                  ((char)(imm)&0xF0) ? 27 : (char)(imm) + 11, \
3048                                  ((char)(imm)&0xF0) ? 28 : (char)(imm) + 12, \
3049                                  ((char)(imm)&0xF0) ? 29 : (char)(imm) + 13, \
3050                                  ((char)(imm)&0xF0) ? 30 : (char)(imm) + 14, \
3051                                  ((char)(imm)&0xF0) ? 31 : (char)(imm) + 15); })
3052
3053 #define _mm_bsrli_si128(a, imm) \
3054   _mm_srli_si128((a), (imm))
3055
3056 /// \brief Right-shifts each of 16-bit values in the 128-bit integer vector
3057 ///    operand by the specified number of bits. High-order bits are cleared.
3058 ///
3059 /// \headerfile <x86intrin.h>
3060 ///
3061 /// This intrinsic corresponds to the <c> VPSRLW / PSRLW </c> instruction.
3062 ///
3063 /// \param __a
3064 ///    A 128-bit integer vector containing the source operand.
3065 /// \param __count
3066 ///    An integer value specifying the number of bits to right-shift each value
3067 ///    in operand \a __a.
3068 /// \returns A 128-bit integer vector containing the right-shifted values.
3069 static __inline__ __m128i __DEFAULT_FN_ATTRS
3070 _mm_srli_epi16(__m128i __a, int __count)
3071 {
3072   return (__m128i)__builtin_ia32_psrlwi128((__v8hi)__a, __count);
3073 }
3074
3075 /// \brief Right-shifts each of 16-bit values in the 128-bit integer vector
3076 ///    operand by the specified number of bits. High-order bits are cleared.
3077 ///
3078 /// \headerfile <x86intrin.h>
3079 ///
3080 /// This intrinsic corresponds to the <c> VPSRLW / PSRLW </c> instruction.
3081 ///
3082 /// \param __a
3083 ///    A 128-bit integer vector containing the source operand.
3084 /// \param __count
3085 ///    A 128-bit integer vector in which bits [63:0] specify the number of bits
3086 ///    to right-shift each value in operand \a __a.
3087 /// \returns A 128-bit integer vector containing the right-shifted values.
3088 static __inline__ __m128i __DEFAULT_FN_ATTRS
3089 _mm_srl_epi16(__m128i __a, __m128i __count)
3090 {
3091   return (__m128i)__builtin_ia32_psrlw128((__v8hi)__a, (__v8hi)__count);
3092 }
3093
3094 /// \brief Right-shifts each of 32-bit values in the 128-bit integer vector
3095 ///    operand by the specified number of bits. High-order bits are cleared.
3096 ///
3097 /// \headerfile <x86intrin.h>
3098 ///
3099 /// This intrinsic corresponds to the <c> VPSRLD / PSRLD </c> instruction.
3100 ///
3101 /// \param __a
3102 ///    A 128-bit integer vector containing the source operand.
3103 /// \param __count
3104 ///    An integer value specifying the number of bits to right-shift each value
3105 ///    in operand \a __a.
3106 /// \returns A 128-bit integer vector containing the right-shifted values.
3107 static __inline__ __m128i __DEFAULT_FN_ATTRS
3108 _mm_srli_epi32(__m128i __a, int __count)
3109 {
3110   return (__m128i)__builtin_ia32_psrldi128((__v4si)__a, __count);
3111 }
3112
3113 /// \brief Right-shifts each of 32-bit values in the 128-bit integer vector
3114 ///    operand by the specified number of bits. High-order bits are cleared.
3115 ///
3116 /// \headerfile <x86intrin.h>
3117 ///
3118 /// This intrinsic corresponds to the <c> VPSRLD / PSRLD </c> instruction.
3119 ///
3120 /// \param __a
3121 ///    A 128-bit integer vector containing the source operand.
3122 /// \param __count
3123 ///    A 128-bit integer vector in which bits [63:0] specify the number of bits
3124 ///    to right-shift each value in operand \a __a.
3125 /// \returns A 128-bit integer vector containing the right-shifted values.
3126 static __inline__ __m128i __DEFAULT_FN_ATTRS
3127 _mm_srl_epi32(__m128i __a, __m128i __count)
3128 {
3129   return (__m128i)__builtin_ia32_psrld128((__v4si)__a, (__v4si)__count);
3130 }
3131
3132 /// \brief Right-shifts each of 64-bit values in the 128-bit integer vector
3133 ///    operand by the specified number of bits. High-order bits are cleared.
3134 ///
3135 /// \headerfile <x86intrin.h>
3136 ///
3137 /// This intrinsic corresponds to the <c> VPSRLQ / PSRLQ </c> instruction.
3138 ///
3139 /// \param __a
3140 ///    A 128-bit integer vector containing the source operand.
3141 /// \param __count
3142 ///    An integer value specifying the number of bits to right-shift each value
3143 ///    in operand \a __a.
3144 /// \returns A 128-bit integer vector containing the right-shifted values.
3145 static __inline__ __m128i __DEFAULT_FN_ATTRS
3146 _mm_srli_epi64(__m128i __a, int __count)
3147 {
3148   return __builtin_ia32_psrlqi128((__v2di)__a, __count);
3149 }
3150
3151 /// \brief Right-shifts each of 64-bit values in the 128-bit integer vector
3152 ///    operand by the specified number of bits. High-order bits are cleared.
3153 ///
3154 /// \headerfile <x86intrin.h>
3155 ///
3156 /// This intrinsic corresponds to the <c> VPSRLQ / PSRLQ </c> instruction.
3157 ///
3158 /// \param __a
3159 ///    A 128-bit integer vector containing the source operand.
3160 /// \param __count
3161 ///    A 128-bit integer vector in which bits [63:0] specify the number of bits
3162 ///    to right-shift each value in operand \a __a.
3163 /// \returns A 128-bit integer vector containing the right-shifted values.
3164 static __inline__ __m128i __DEFAULT_FN_ATTRS
3165 _mm_srl_epi64(__m128i __a, __m128i __count)
3166 {
3167   return __builtin_ia32_psrlq128((__v2di)__a, (__v2di)__count);
3168 }
3169
3170 /// \brief Compares each of the corresponding 8-bit values of the 128-bit
3171 ///    integer vectors for equality. Each comparison yields 0h for false, FFh
3172 ///    for true.
3173 ///
3174 /// \headerfile <x86intrin.h>
3175 ///
3176 /// This intrinsic corresponds to the <c> VPCMPEQB / PCMPEQB </c> instruction.
3177 ///
3178 /// \param __a
3179 ///    A 128-bit integer vector.
3180 /// \param __b
3181 ///    A 128-bit integer vector.
3182 /// \returns A 128-bit integer vector containing the comparison results.
3183 static __inline__ __m128i __DEFAULT_FN_ATTRS
3184 _mm_cmpeq_epi8(__m128i __a, __m128i __b)
3185 {
3186   return (__m128i)((__v16qi)__a == (__v16qi)__b);
3187 }
3188
3189 /// \brief Compares each of the corresponding 16-bit values of the 128-bit
3190 ///    integer vectors for equality. Each comparison yields 0h for false, FFFFh
3191 ///    for true.
3192 ///
3193 /// \headerfile <x86intrin.h>
3194 ///
3195 /// This intrinsic corresponds to the <c> VPCMPEQW / PCMPEQW </c> instruction.
3196 ///
3197 /// \param __a
3198 ///    A 128-bit integer vector.
3199 /// \param __b
3200 ///    A 128-bit integer vector.
3201 /// \returns A 128-bit integer vector containing the comparison results.
3202 static __inline__ __m128i __DEFAULT_FN_ATTRS
3203 _mm_cmpeq_epi16(__m128i __a, __m128i __b)
3204 {
3205   return (__m128i)((__v8hi)__a == (__v8hi)__b);
3206 }
3207
3208 /// \brief Compares each of the corresponding 32-bit values of the 128-bit
3209 ///    integer vectors for equality. Each comparison yields 0h for false,
3210 ///    FFFFFFFFh for true.
3211 ///
3212 /// \headerfile <x86intrin.h>
3213 ///
3214 /// This intrinsic corresponds to the <c> VPCMPEQD / PCMPEQD </c> instruction.
3215 ///
3216 /// \param __a
3217 ///    A 128-bit integer vector.
3218 /// \param __b
3219 ///    A 128-bit integer vector.
3220 /// \returns A 128-bit integer vector containing the comparison results.
3221 static __inline__ __m128i __DEFAULT_FN_ATTRS
3222 _mm_cmpeq_epi32(__m128i __a, __m128i __b)
3223 {
3224   return (__m128i)((__v4si)__a == (__v4si)__b);
3225 }
3226
3227 /// \brief Compares each of the corresponding signed 8-bit values of the 128-bit
3228 ///    integer vectors to determine if the values in the first operand are
3229 ///    greater than those in the second operand. Each comparison yields 0h for
3230 ///    false, FFh for true.
3231 ///
3232 /// \headerfile <x86intrin.h>
3233 ///
3234 /// This intrinsic corresponds to the <c> VPCMPGTB / PCMPGTB </c> instruction.
3235 ///
3236 /// \param __a
3237 ///    A 128-bit integer vector.
3238 /// \param __b
3239 ///    A 128-bit integer vector.
3240 /// \returns A 128-bit integer vector containing the comparison results.
3241 static __inline__ __m128i __DEFAULT_FN_ATTRS
3242 _mm_cmpgt_epi8(__m128i __a, __m128i __b)
3243 {
3244   /* This function always performs a signed comparison, but __v16qi is a char
3245      which may be signed or unsigned, so use __v16qs. */
3246   return (__m128i)((__v16qs)__a > (__v16qs)__b);
3247 }
3248
3249 /// \brief Compares each of the corresponding signed 16-bit values of the
3250 ///    128-bit integer vectors to determine if the values in the first operand
3251 ///    are greater than those in the second operand.
3252 ///
3253 ///    Each comparison yields 0h for false, FFFFh for true.
3254 ///
3255 /// \headerfile <x86intrin.h>
3256 ///
3257 /// This intrinsic corresponds to the <c> VPCMPGTW / PCMPGTW </c> instruction.
3258 ///
3259 /// \param __a
3260 ///    A 128-bit integer vector.
3261 /// \param __b
3262 ///    A 128-bit integer vector.
3263 /// \returns A 128-bit integer vector containing the comparison results.
3264 static __inline__ __m128i __DEFAULT_FN_ATTRS
3265 _mm_cmpgt_epi16(__m128i __a, __m128i __b)
3266 {
3267   return (__m128i)((__v8hi)__a > (__v8hi)__b);
3268 }
3269
3270 /// \brief Compares each of the corresponding signed 32-bit values of the
3271 ///    128-bit integer vectors to determine if the values in the first operand
3272 ///    are greater than those in the second operand.
3273 ///
3274 ///    Each comparison yields 0h for false, FFFFFFFFh for true.
3275 ///
3276 /// \headerfile <x86intrin.h>
3277 ///
3278 /// This intrinsic corresponds to the <c> VPCMPGTD / PCMPGTD </c> instruction.
3279 ///
3280 /// \param __a
3281 ///    A 128-bit integer vector.
3282 /// \param __b
3283 ///    A 128-bit integer vector.
3284 /// \returns A 128-bit integer vector containing the comparison results.
3285 static __inline__ __m128i __DEFAULT_FN_ATTRS
3286 _mm_cmpgt_epi32(__m128i __a, __m128i __b)
3287 {
3288   return (__m128i)((__v4si)__a > (__v4si)__b);
3289 }
3290
3291 /// \brief Compares each of the corresponding signed 8-bit values of the 128-bit
3292 ///    integer vectors to determine if the values in the first operand are less
3293 ///    than those in the second operand.
3294 ///
3295 ///    Each comparison yields 0h for false, FFh for true.
3296 ///
3297 /// \headerfile <x86intrin.h>
3298 ///
3299 /// This intrinsic corresponds to the <c> VPCMPGTB / PCMPGTB </c> instruction.
3300 ///
3301 /// \param __a
3302 ///    A 128-bit integer vector.
3303 /// \param __b
3304 ///    A 128-bit integer vector.
3305 /// \returns A 128-bit integer vector containing the comparison results.
3306 static __inline__ __m128i __DEFAULT_FN_ATTRS
3307 _mm_cmplt_epi8(__m128i __a, __m128i __b)
3308 {
3309   return _mm_cmpgt_epi8(__b, __a);
3310 }
3311
3312 /// \brief Compares each of the corresponding signed 16-bit values of the
3313 ///    128-bit integer vectors to determine if the values in the first operand
3314 ///    are less than those in the second operand.
3315 ///
3316 ///    Each comparison yields 0h for false, FFFFh for true.
3317 ///
3318 /// \headerfile <x86intrin.h>
3319 ///
3320 /// This intrinsic corresponds to the <c> VPCMPGTW / PCMPGTW </c> instruction.
3321 ///
3322 /// \param __a
3323 ///    A 128-bit integer vector.
3324 /// \param __b
3325 ///    A 128-bit integer vector.
3326 /// \returns A 128-bit integer vector containing the comparison results.
3327 static __inline__ __m128i __DEFAULT_FN_ATTRS
3328 _mm_cmplt_epi16(__m128i __a, __m128i __b)
3329 {
3330   return _mm_cmpgt_epi16(__b, __a);
3331 }
3332
3333 /// \brief Compares each of the corresponding signed 32-bit values of the
3334 ///    128-bit integer vectors to determine if the values in the first operand
3335 ///    are less than those in the second operand.
3336 ///
3337 ///    Each comparison yields 0h for false, FFFFFFFFh for true.
3338 ///
3339 /// \headerfile <x86intrin.h>
3340 ///
3341 /// This intrinsic corresponds to the <c> VPCMPGTD / PCMPGTD </c> instruction.
3342 ///
3343 /// \param __a
3344 ///    A 128-bit integer vector.
3345 /// \param __b
3346 ///    A 128-bit integer vector.
3347 /// \returns A 128-bit integer vector containing the comparison results.
3348 static __inline__ __m128i __DEFAULT_FN_ATTRS
3349 _mm_cmplt_epi32(__m128i __a, __m128i __b)
3350 {
3351   return _mm_cmpgt_epi32(__b, __a);
3352 }
3353
3354 #ifdef __x86_64__
3355 /// \brief Converts a 64-bit signed integer value from the second operand into a
3356 ///    double-precision value and returns it in the lower element of a [2 x
3357 ///    double] vector; the upper element of the returned vector is copied from
3358 ///    the upper element of the first operand.
3359 ///
3360 /// \headerfile <x86intrin.h>
3361 ///
3362 /// This intrinsic corresponds to the <c> VCVTSI2SD / CVTSI2SD </c> instruction.
3363 ///
3364 /// \param __a
3365 ///    A 128-bit vector of [2 x double]. The upper 64 bits of this operand are
3366 ///    copied to the upper 64 bits of the destination.
3367 /// \param __b
3368 ///    A 64-bit signed integer operand containing the value to be converted.
3369 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
3370 ///    converted value of the second operand. The upper 64 bits are copied from
3371 ///    the upper 64 bits of the first operand.
3372 static __inline__ __m128d __DEFAULT_FN_ATTRS
3373 _mm_cvtsi64_sd(__m128d __a, long long __b)
3374 {
3375   __a[0] = __b;
3376   return __a;
3377 }
3378
3379 /// \brief Converts the first (lower) element of a vector of [2 x double] into a
3380 ///    64-bit signed integer value, according to the current rounding mode.
3381 ///
3382 /// \headerfile <x86intrin.h>
3383 ///
3384 /// This intrinsic corresponds to the <c> VCVTSD2SI / CVTSD2SI </c> instruction.
3385 ///
3386 /// \param __a
3387 ///    A 128-bit vector of [2 x double]. The lower 64 bits are used in the
3388 ///    conversion.
3389 /// \returns A 64-bit signed integer containing the converted value.
3390 static __inline__ long long __DEFAULT_FN_ATTRS
3391 _mm_cvtsd_si64(__m128d __a)
3392 {
3393   return __builtin_ia32_cvtsd2si64((__v2df)__a);
3394 }
3395
3396 /// \brief Converts the first (lower) element of a vector of [2 x double] into a
3397 ///    64-bit signed integer value, truncating the result when it is inexact.
3398 ///
3399 /// \headerfile <x86intrin.h>
3400 ///
3401 /// This intrinsic corresponds to the <c> VCVTTSD2SI / CVTTSD2SI </c>
3402 ///   instruction.
3403 ///
3404 /// \param __a
3405 ///    A 128-bit vector of [2 x double]. The lower 64 bits are used in the
3406 ///    conversion.
3407 /// \returns A 64-bit signed integer containing the converted value.
3408 static __inline__ long long __DEFAULT_FN_ATTRS
3409 _mm_cvttsd_si64(__m128d __a)
3410 {
3411   return __builtin_ia32_cvttsd2si64((__v2df)__a);
3412 }
3413 #endif
3414
3415 /// \brief Converts a vector of [4 x i32] into a vector of [4 x float].
3416 ///
3417 /// \headerfile <x86intrin.h>
3418 ///
3419 /// This intrinsic corresponds to the <c> VCVTDQ2PS / CVTDQ2PS </c> instruction.
3420 ///
3421 /// \param __a
3422 ///    A 128-bit integer vector.
3423 /// \returns A 128-bit vector of [4 x float] containing the converted values.
3424 static __inline__ __m128 __DEFAULT_FN_ATTRS
3425 _mm_cvtepi32_ps(__m128i __a)
3426 {
3427   return __builtin_ia32_cvtdq2ps((__v4si)__a);
3428 }
3429
3430 /// \brief Converts a vector of [4 x float] into a vector of [4 x i32].
3431 ///
3432 /// \headerfile <x86intrin.h>
3433 ///
3434 /// This intrinsic corresponds to the <c> VCVTPS2DQ / CVTPS2DQ </c> instruction.
3435 ///
3436 /// \param __a
3437 ///    A 128-bit vector of [4 x float].
3438 /// \returns A 128-bit integer vector of [4 x i32] containing the converted
3439 ///    values.
3440 static __inline__ __m128i __DEFAULT_FN_ATTRS
3441 _mm_cvtps_epi32(__m128 __a)
3442 {
3443   return (__m128i)__builtin_ia32_cvtps2dq((__v4sf)__a);
3444 }
3445
3446 /// \brief Converts a vector of [4 x float] into a vector of [4 x i32],
3447 ///    truncating the result when it is inexact.
3448 ///
3449 /// \headerfile <x86intrin.h>
3450 ///
3451 /// This intrinsic corresponds to the <c> VCVTTPS2DQ / CVTTPS2DQ </c>
3452 ///   instruction.
3453 ///
3454 /// \param __a
3455 ///    A 128-bit vector of [4 x float].
3456 /// \returns A 128-bit vector of [4 x i32] containing the converted values.
3457 static __inline__ __m128i __DEFAULT_FN_ATTRS
3458 _mm_cvttps_epi32(__m128 __a)
3459 {
3460   return (__m128i)__builtin_ia32_cvttps2dq((__v4sf)__a);
3461 }
3462
3463 /// \brief Returns a vector of [4 x i32] where the lowest element is the input
3464 ///    operand and the remaining elements are zero.
3465 ///
3466 /// \headerfile <x86intrin.h>
3467 ///
3468 /// This intrinsic corresponds to the <c> VMOVD / MOVD </c> instruction.
3469 ///
3470 /// \param __a
3471 ///    A 32-bit signed integer operand.
3472 /// \returns A 128-bit vector of [4 x i32].
3473 static __inline__ __m128i __DEFAULT_FN_ATTRS
3474 _mm_cvtsi32_si128(int __a)
3475 {
3476   return (__m128i)(__v4si){ __a, 0, 0, 0 };
3477 }
3478
3479 #ifdef __x86_64__
3480 /// \brief Returns a vector of [2 x i64] where the lower element is the input
3481 ///    operand and the upper element is zero.
3482 ///
3483 /// \headerfile <x86intrin.h>
3484 ///
3485 /// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
3486 ///
3487 /// \param __a
3488 ///    A 64-bit signed integer operand containing the value to be converted.
3489 /// \returns A 128-bit vector of [2 x i64] containing the converted value.
3490 static __inline__ __m128i __DEFAULT_FN_ATTRS
3491 _mm_cvtsi64_si128(long long __a)
3492 {
3493   return (__m128i){ __a, 0 };
3494 }
3495 #endif
3496
3497 /// \brief Moves the least significant 32 bits of a vector of [4 x i32] to a
3498 ///    32-bit signed integer value.
3499 ///
3500 /// \headerfile <x86intrin.h>
3501 ///
3502 /// This intrinsic corresponds to the <c> VMOVD / MOVD </c> instruction.
3503 ///
3504 /// \param __a
3505 ///    A vector of [4 x i32]. The least significant 32 bits are moved to the
3506 ///    destination.
3507 /// \returns A 32-bit signed integer containing the moved value.
3508 static __inline__ int __DEFAULT_FN_ATTRS
3509 _mm_cvtsi128_si32(__m128i __a)
3510 {
3511   __v4si __b = (__v4si)__a;
3512   return __b[0];
3513 }
3514
3515 #ifdef __x86_64__
3516 /// \brief Moves the least significant 64 bits of a vector of [2 x i64] to a
3517 ///    64-bit signed integer value.
3518 ///
3519 /// \headerfile <x86intrin.h>
3520 ///
3521 /// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
3522 ///
3523 /// \param __a
3524 ///    A vector of [2 x i64]. The least significant 64 bits are moved to the
3525 ///    destination.
3526 /// \returns A 64-bit signed integer containing the moved value.
3527 static __inline__ long long __DEFAULT_FN_ATTRS
3528 _mm_cvtsi128_si64(__m128i __a)
3529 {
3530   return __a[0];
3531 }
3532 #endif
3533
3534 /// \brief Moves packed integer values from an aligned 128-bit memory location
3535 ///    to elements in a 128-bit integer vector.
3536 ///
3537 /// \headerfile <x86intrin.h>
3538 ///
3539 /// This intrinsic corresponds to the <c> VMOVDQA / MOVDQA </c> instruction.
3540 ///
3541 /// \param __p
3542 ///    An aligned pointer to a memory location containing integer values.
3543 /// \returns A 128-bit integer vector containing the moved values.
3544 static __inline__ __m128i __DEFAULT_FN_ATTRS
3545 _mm_load_si128(__m128i const *__p)
3546 {
3547   return *__p;
3548 }
3549
3550 /// \brief Moves packed integer values from an unaligned 128-bit memory location
3551 ///    to elements in a 128-bit integer vector.
3552 ///
3553 /// \headerfile <x86intrin.h>
3554 ///
3555 /// This intrinsic corresponds to the <c> VMOVDQU / MOVDQU </c> instruction.
3556 ///
3557 /// \param __p
3558 ///    A pointer to a memory location containing integer values.
3559 /// \returns A 128-bit integer vector containing the moved values.
3560 static __inline__ __m128i __DEFAULT_FN_ATTRS
3561 _mm_loadu_si128(__m128i const *__p)
3562 {
3563   struct __loadu_si128 {
3564     __m128i __v;
3565   } __attribute__((__packed__, __may_alias__));
3566   return ((struct __loadu_si128*)__p)->__v;
3567 }
3568
3569 /// \brief Returns a vector of [2 x i64] where the lower element is taken from
3570 ///    the lower element of the operand, and the upper element is zero.
3571 ///
3572 /// \headerfile <x86intrin.h>
3573 ///
3574 /// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
3575 ///
3576 /// \param __p
3577 ///    A 128-bit vector of [2 x i64]. Bits [63:0] are written to bits [63:0] of
3578 ///    the destination.
3579 /// \returns A 128-bit vector of [2 x i64]. The lower order bits contain the
3580 ///    moved value. The higher order bits are cleared.
3581 static __inline__ __m128i __DEFAULT_FN_ATTRS
3582 _mm_loadl_epi64(__m128i const *__p)
3583 {
3584   struct __mm_loadl_epi64_struct {
3585     long long __u;
3586   } __attribute__((__packed__, __may_alias__));
3587   return (__m128i) { ((struct __mm_loadl_epi64_struct*)__p)->__u, 0};
3588 }
3589
3590 /// \brief Generates a 128-bit vector of [4 x i32] with unspecified content.
3591 ///    This could be used as an argument to another intrinsic function where the
3592 ///    argument is required but the value is not actually used.
3593 ///
3594 /// \headerfile <x86intrin.h>
3595 ///
3596 /// This intrinsic has no corresponding instruction.
3597 ///
3598 /// \returns A 128-bit vector of [4 x i32] with unspecified content.
3599 static __inline__ __m128i __DEFAULT_FN_ATTRS
3600 _mm_undefined_si128(void)
3601 {
3602   return (__m128i)__builtin_ia32_undef128();
3603 }
3604
3605 /// \brief Initializes both 64-bit values in a 128-bit vector of [2 x i64] with
3606 ///    the specified 64-bit integer values.
3607 ///
3608 /// \headerfile <x86intrin.h>
3609 ///
3610 /// This intrinsic is a utility function and does not correspond to a specific
3611 ///    instruction.
3612 ///
3613 /// \param __q1
3614 ///    A 64-bit integer value used to initialize the upper 64 bits of the
3615 ///    destination vector of [2 x i64].
3616 /// \param __q0
3617 ///    A 64-bit integer value used to initialize the lower 64 bits of the
3618 ///    destination vector of [2 x i64].
3619 /// \returns An initialized 128-bit vector of [2 x i64] containing the values
3620 ///    provided in the operands.
3621 static __inline__ __m128i __DEFAULT_FN_ATTRS
3622 _mm_set_epi64x(long long __q1, long long __q0)
3623 {
3624   return (__m128i){ __q0, __q1 };
3625 }
3626
3627 /// \brief Initializes both 64-bit values in a 128-bit vector of [2 x i64] with
3628 ///    the specified 64-bit integer values.
3629 ///
3630 /// \headerfile <x86intrin.h>
3631 ///
3632 /// This intrinsic is a utility function and does not correspond to a specific
3633 ///    instruction.
3634 ///
3635 /// \param __q1
3636 ///    A 64-bit integer value used to initialize the upper 64 bits of the
3637 ///    destination vector of [2 x i64].
3638 /// \param __q0
3639 ///    A 64-bit integer value used to initialize the lower 64 bits of the
3640 ///    destination vector of [2 x i64].
3641 /// \returns An initialized 128-bit vector of [2 x i64] containing the values
3642 ///    provided in the operands.
3643 static __inline__ __m128i __DEFAULT_FN_ATTRS
3644 _mm_set_epi64(__m64 __q1, __m64 __q0)
3645 {
3646   return (__m128i){ (long long)__q0, (long long)__q1 };
3647 }
3648
3649 /// \brief Initializes the 32-bit values in a 128-bit vector of [4 x i32] with
3650 ///    the specified 32-bit integer values.
3651 ///
3652 /// \headerfile <x86intrin.h>
3653 ///
3654 /// This intrinsic is a utility function and does not correspond to a specific
3655 ///    instruction.
3656 ///
3657 /// \param __i3
3658 ///    A 32-bit integer value used to initialize bits [127:96] of the
3659 ///    destination vector.
3660 /// \param __i2
3661 ///    A 32-bit integer value used to initialize bits [95:64] of the destination
3662 ///    vector.
3663 /// \param __i1
3664 ///    A 32-bit integer value used to initialize bits [63:32] of the destination
3665 ///    vector.
3666 /// \param __i0
3667 ///    A 32-bit integer value used to initialize bits [31:0] of the destination
3668 ///    vector.
3669 /// \returns An initialized 128-bit vector of [4 x i32] containing the values
3670 ///    provided in the operands.
3671 static __inline__ __m128i __DEFAULT_FN_ATTRS
3672 _mm_set_epi32(int __i3, int __i2, int __i1, int __i0)
3673 {
3674   return (__m128i)(__v4si){ __i0, __i1, __i2, __i3};
3675 }
3676
3677 /// \brief Initializes the 16-bit values in a 128-bit vector of [8 x i16] with
3678 ///    the specified 16-bit integer values.
3679 ///
3680 /// \headerfile <x86intrin.h>
3681 ///
3682 /// This intrinsic is a utility function and does not correspond to a specific
3683 ///    instruction.
3684 ///
3685 /// \param __w7
3686 ///    A 16-bit integer value used to initialize bits [127:112] of the
3687 ///    destination vector.
3688 /// \param __w6
3689 ///    A 16-bit integer value used to initialize bits [111:96] of the
3690 ///    destination vector.
3691 /// \param __w5
3692 ///    A 16-bit integer value used to initialize bits [95:80] of the destination
3693 ///    vector.
3694 /// \param __w4
3695 ///    A 16-bit integer value used to initialize bits [79:64] of the destination
3696 ///    vector.
3697 /// \param __w3
3698 ///    A 16-bit integer value used to initialize bits [63:48] of the destination
3699 ///    vector.
3700 /// \param __w2
3701 ///    A 16-bit integer value used to initialize bits [47:32] of the destination
3702 ///    vector.
3703 /// \param __w1
3704 ///    A 16-bit integer value used to initialize bits [31:16] of the destination
3705 ///    vector.
3706 /// \param __w0
3707 ///    A 16-bit integer value used to initialize bits [15:0] of the destination
3708 ///    vector.
3709 /// \returns An initialized 128-bit vector of [8 x i16] containing the values
3710 ///    provided in the operands.
3711 static __inline__ __m128i __DEFAULT_FN_ATTRS
3712 _mm_set_epi16(short __w7, short __w6, short __w5, short __w4, short __w3, short __w2, short __w1, short __w0)
3713 {
3714   return (__m128i)(__v8hi){ __w0, __w1, __w2, __w3, __w4, __w5, __w6, __w7 };
3715 }
3716
3717 /// \brief Initializes the 8-bit values in a 128-bit vector of [16 x i8] with
3718 ///    the specified 8-bit integer values.
3719 ///
3720 /// \headerfile <x86intrin.h>
3721 ///
3722 /// This intrinsic is a utility function and does not correspond to a specific
3723 ///    instruction.
3724 ///
3725 /// \param __b15
3726 ///    Initializes bits [127:120] of the destination vector.
3727 /// \param __b14
3728 ///    Initializes bits [119:112] of the destination vector.
3729 /// \param __b13
3730 ///    Initializes bits [111:104] of the destination vector.
3731 /// \param __b12
3732 ///    Initializes bits [103:96] of the destination vector.
3733 /// \param __b11
3734 ///    Initializes bits [95:88] of the destination vector.
3735 /// \param __b10
3736 ///    Initializes bits [87:80] of the destination vector.
3737 /// \param __b9
3738 ///    Initializes bits [79:72] of the destination vector.
3739 /// \param __b8
3740 ///    Initializes bits [71:64] of the destination vector.
3741 /// \param __b7
3742 ///    Initializes bits [63:56] of the destination vector.
3743 /// \param __b6
3744 ///    Initializes bits [55:48] of the destination vector.
3745 /// \param __b5
3746 ///    Initializes bits [47:40] of the destination vector.
3747 /// \param __b4
3748 ///    Initializes bits [39:32] of the destination vector.
3749 /// \param __b3
3750 ///    Initializes bits [31:24] of the destination vector.
3751 /// \param __b2
3752 ///    Initializes bits [23:16] of the destination vector.
3753 /// \param __b1
3754 ///    Initializes bits [15:8] of the destination vector.
3755 /// \param __b0
3756 ///    Initializes bits [7:0] of the destination vector.
3757 /// \returns An initialized 128-bit vector of [16 x i8] containing the values
3758 ///    provided in the operands.
3759 static __inline__ __m128i __DEFAULT_FN_ATTRS
3760 _mm_set_epi8(char __b15, char __b14, char __b13, char __b12, char __b11, char __b10, char __b9, char __b8, char __b7, char __b6, char __b5, char __b4, char __b3, char __b2, char __b1, char __b0)
3761 {
3762   return (__m128i)(__v16qi){ __b0, __b1, __b2, __b3, __b4, __b5, __b6, __b7, __b8, __b9, __b10, __b11, __b12, __b13, __b14, __b15 };
3763 }
3764
3765 /// \brief Initializes both values in a 128-bit integer vector with the
3766 ///    specified 64-bit integer value.
3767 ///
3768 /// \headerfile <x86intrin.h>
3769 ///
3770 /// This intrinsic is a utility function and does not correspond to a specific
3771 ///    instruction.
3772 ///
3773 /// \param __q
3774 ///    Integer value used to initialize the elements of the destination integer
3775 ///    vector.
3776 /// \returns An initialized 128-bit integer vector of [2 x i64] with both
3777 ///    elements containing the value provided in the operand.
3778 static __inline__ __m128i __DEFAULT_FN_ATTRS
3779 _mm_set1_epi64x(long long __q)
3780 {
3781   return (__m128i){ __q, __q };
3782 }
3783
3784 /// \brief Initializes both values in a 128-bit vector of [2 x i64] with the
3785 ///    specified 64-bit value.
3786 ///
3787 /// \headerfile <x86intrin.h>
3788 ///
3789 /// This intrinsic is a utility function and does not correspond to a specific
3790 ///    instruction.
3791 ///
3792 /// \param __q
3793 ///    A 64-bit value used to initialize the elements of the destination integer
3794 ///    vector.
3795 /// \returns An initialized 128-bit vector of [2 x i64] with all elements
3796 ///    containing the value provided in the operand.
3797 static __inline__ __m128i __DEFAULT_FN_ATTRS
3798 _mm_set1_epi64(__m64 __q)
3799 {
3800   return (__m128i){ (long long)__q, (long long)__q };
3801 }
3802
3803 /// \brief Initializes all values in a 128-bit vector of [4 x i32] with the
3804 ///    specified 32-bit value.
3805 ///
3806 /// \headerfile <x86intrin.h>
3807 ///
3808 /// This intrinsic is a utility function and does not correspond to a specific
3809 ///    instruction.
3810 ///
3811 /// \param __i
3812 ///    A 32-bit value used to initialize the elements of the destination integer
3813 ///    vector.
3814 /// \returns An initialized 128-bit vector of [4 x i32] with all elements
3815 ///    containing the value provided in the operand.
3816 static __inline__ __m128i __DEFAULT_FN_ATTRS
3817 _mm_set1_epi32(int __i)
3818 {
3819   return (__m128i)(__v4si){ __i, __i, __i, __i };
3820 }
3821
3822 /// \brief Initializes all values in a 128-bit vector of [8 x i16] with the
3823 ///    specified 16-bit value.
3824 ///
3825 /// \headerfile <x86intrin.h>
3826 ///
3827 /// This intrinsic is a utility function and does not correspond to a specific
3828 ///    instruction.
3829 ///
3830 /// \param __w
3831 ///    A 16-bit value used to initialize the elements of the destination integer
3832 ///    vector.
3833 /// \returns An initialized 128-bit vector of [8 x i16] with all elements
3834 ///    containing the value provided in the operand.
3835 static __inline__ __m128i __DEFAULT_FN_ATTRS
3836 _mm_set1_epi16(short __w)
3837 {
3838   return (__m128i)(__v8hi){ __w, __w, __w, __w, __w, __w, __w, __w };
3839 }
3840
3841 /// \brief Initializes all values in a 128-bit vector of [16 x i8] with the
3842 ///    specified 8-bit value.
3843 ///
3844 /// \headerfile <x86intrin.h>
3845 ///
3846 /// This intrinsic is a utility function and does not correspond to a specific
3847 ///    instruction.
3848 ///
3849 /// \param __b
3850 ///    An 8-bit value used to initialize the elements of the destination integer
3851 ///    vector.
3852 /// \returns An initialized 128-bit vector of [16 x i8] with all elements
3853 ///    containing the value provided in the operand.
3854 static __inline__ __m128i __DEFAULT_FN_ATTRS
3855 _mm_set1_epi8(char __b)
3856 {
3857   return (__m128i)(__v16qi){ __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b };
3858 }
3859
3860 /// \brief Constructs a 128-bit integer vector, initialized in reverse order
3861 ///     with the specified 64-bit integral values.
3862 ///
3863 /// \headerfile <x86intrin.h>
3864 ///
3865 /// This intrinsic does not correspond to a specific instruction.
3866 ///
3867 /// \param __q0
3868 ///    A 64-bit integral value used to initialize the lower 64 bits of the
3869 ///    result.
3870 /// \param __q1
3871 ///    A 64-bit integral value used to initialize the upper 64 bits of the
3872 ///    result.
3873 /// \returns An initialized 128-bit integer vector.
3874 static __inline__ __m128i __DEFAULT_FN_ATTRS
3875 _mm_setr_epi64(__m64 __q0, __m64 __q1)
3876 {
3877   return (__m128i){ (long long)__q0, (long long)__q1 };
3878 }
3879
3880 /// \brief Constructs a 128-bit integer vector, initialized in reverse order
3881 ///     with the specified 32-bit integral values.
3882 ///
3883 /// \headerfile <x86intrin.h>
3884 ///
3885 /// This intrinsic is a utility function and does not correspond to a specific
3886 ///    instruction.
3887 ///
3888 /// \param __i0
3889 ///    A 32-bit integral value used to initialize bits [31:0] of the result.
3890 /// \param __i1
3891 ///    A 32-bit integral value used to initialize bits [63:32] of the result.
3892 /// \param __i2
3893 ///    A 32-bit integral value used to initialize bits [95:64] of the result.
3894 /// \param __i3
3895 ///    A 32-bit integral value used to initialize bits [127:96] of the result.
3896 /// \returns An initialized 128-bit integer vector.
3897 static __inline__ __m128i __DEFAULT_FN_ATTRS
3898 _mm_setr_epi32(int __i0, int __i1, int __i2, int __i3)
3899 {
3900   return (__m128i)(__v4si){ __i0, __i1, __i2, __i3};
3901 }
3902
3903 /// \brief Constructs a 128-bit integer vector, initialized in reverse order
3904 ///     with the specified 16-bit integral values.
3905 ///
3906 /// \headerfile <x86intrin.h>
3907 ///
3908 /// This intrinsic is a utility function and does not correspond to a specific
3909 ///    instruction.
3910 ///
3911 /// \param __w0
3912 ///    A 16-bit integral value used to initialize bits [15:0] of the result.
3913 /// \param __w1
3914 ///    A 16-bit integral value used to initialize bits [31:16] of the result.
3915 /// \param __w2
3916 ///    A 16-bit integral value used to initialize bits [47:32] of the result.
3917 /// \param __w3
3918 ///    A 16-bit integral value used to initialize bits [63:48] of the result.
3919 /// \param __w4
3920 ///    A 16-bit integral value used to initialize bits [79:64] of the result.
3921 /// \param __w5
3922 ///    A 16-bit integral value used to initialize bits [95:80] of the result.
3923 /// \param __w6
3924 ///    A 16-bit integral value used to initialize bits [111:96] of the result.
3925 /// \param __w7
3926 ///    A 16-bit integral value used to initialize bits [127:112] of the result.
3927 /// \returns An initialized 128-bit integer vector.
3928 static __inline__ __m128i __DEFAULT_FN_ATTRS
3929 _mm_setr_epi16(short __w0, short __w1, short __w2, short __w3, short __w4, short __w5, short __w6, short __w7)
3930 {
3931   return (__m128i)(__v8hi){ __w0, __w1, __w2, __w3, __w4, __w5, __w6, __w7 };
3932 }
3933
3934 /// \brief Constructs a 128-bit integer vector, initialized in reverse order
3935 ///     with the specified 8-bit integral values.
3936 ///
3937 /// \headerfile <x86intrin.h>
3938 ///
3939 /// This intrinsic is a utility function and does not correspond to a specific
3940 ///    instruction.
3941 ///
3942 /// \param __b0
3943 ///    An 8-bit integral value used to initialize bits [7:0] of the result.
3944 /// \param __b1
3945 ///    An 8-bit integral value used to initialize bits [15:8] of the result.
3946 /// \param __b2
3947 ///    An 8-bit integral value used to initialize bits [23:16] of the result.
3948 /// \param __b3
3949 ///    An 8-bit integral value used to initialize bits [31:24] of the result.
3950 /// \param __b4
3951 ///    An 8-bit integral value used to initialize bits [39:32] of the result.
3952 /// \param __b5
3953 ///    An 8-bit integral value used to initialize bits [47:40] of the result.
3954 /// \param __b6
3955 ///    An 8-bit integral value used to initialize bits [55:48] of the result.
3956 /// \param __b7
3957 ///    An 8-bit integral value used to initialize bits [63:56] of the result.
3958 /// \param __b8
3959 ///    An 8-bit integral value used to initialize bits [71:64] of the result.
3960 /// \param __b9
3961 ///    An 8-bit integral value used to initialize bits [79:72] of the result.
3962 /// \param __b10
3963 ///    An 8-bit integral value used to initialize bits [87:80] of the result.
3964 /// \param __b11
3965 ///    An 8-bit integral value used to initialize bits [95:88] of the result.
3966 /// \param __b12
3967 ///    An 8-bit integral value used to initialize bits [103:96] of the result.
3968 /// \param __b13
3969 ///    An 8-bit integral value used to initialize bits [111:104] of the result.
3970 /// \param __b14
3971 ///    An 8-bit integral value used to initialize bits [119:112] of the result.
3972 /// \param __b15
3973 ///    An 8-bit integral value used to initialize bits [127:120] of the result.
3974 /// \returns An initialized 128-bit integer vector.
3975 static __inline__ __m128i __DEFAULT_FN_ATTRS
3976 _mm_setr_epi8(char __b0, char __b1, char __b2, char __b3, char __b4, char __b5, char __b6, char __b7, char __b8, char __b9, char __b10, char __b11, char __b12, char __b13, char __b14, char __b15)
3977 {
3978   return (__m128i)(__v16qi){ __b0, __b1, __b2, __b3, __b4, __b5, __b6, __b7, __b8, __b9, __b10, __b11, __b12, __b13, __b14, __b15 };
3979 }
3980
3981 /// \brief Creates a 128-bit integer vector initialized to zero.
3982 ///
3983 /// \headerfile <x86intrin.h>
3984 ///
3985 /// This intrinsic corresponds to the <c> VXORPS / XORPS </c> instruction.
3986 ///
3987 /// \returns An initialized 128-bit integer vector with all elements set to
3988 ///    zero.
3989 static __inline__ __m128i __DEFAULT_FN_ATTRS
3990 _mm_setzero_si128(void)
3991 {
3992   return (__m128i){ 0LL, 0LL };
3993 }
3994
3995 /// \brief Stores a 128-bit integer vector to a memory location aligned on a
3996 ///    128-bit boundary.
3997 ///
3998 /// \headerfile <x86intrin.h>
3999 ///
4000 /// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS </c> instruction.
4001 ///
4002 /// \param __p
4003 ///    A pointer to an aligned memory location that will receive the integer
4004 ///    values.
4005 /// \param __b
4006 ///    A 128-bit integer vector containing the values to be moved.
4007 static __inline__ void __DEFAULT_FN_ATTRS
4008 _mm_store_si128(__m128i *__p, __m128i __b)
4009 {
4010   *__p = __b;
4011 }
4012
4013 /// \brief Stores a 128-bit integer vector to an unaligned memory location.
4014 ///
4015 /// \headerfile <x86intrin.h>
4016 ///
4017 /// This intrinsic corresponds to the <c> VMOVUPS / MOVUPS </c> instruction.
4018 ///
4019 /// \param __p
4020 ///    A pointer to a memory location that will receive the integer values.
4021 /// \param __b
4022 ///    A 128-bit integer vector containing the values to be moved.
4023 static __inline__ void __DEFAULT_FN_ATTRS
4024 _mm_storeu_si128(__m128i *__p, __m128i __b)
4025 {
4026   struct __storeu_si128 {
4027     __m128i __v;
4028   } __attribute__((__packed__, __may_alias__));
4029   ((struct __storeu_si128*)__p)->__v = __b;
4030 }
4031
4032 /// \brief Moves bytes selected by the mask from the first operand to the
4033 ///    specified unaligned memory location. When a mask bit is 1, the
4034 ///    corresponding byte is written, otherwise it is not written.
4035 ///
4036 ///    To minimize caching, the data is flagged as non-temporal (unlikely to be
4037 ///    used again soon). Exception and trap behavior for elements not selected
4038 ///    for storage to memory are implementation dependent.
4039 ///
4040 /// \headerfile <x86intrin.h>
4041 ///
4042 /// This intrinsic corresponds to the <c> VMASKMOVDQU / MASKMOVDQU </c>
4043 ///   instruction.
4044 ///
4045 /// \param __d
4046 ///    A 128-bit integer vector containing the values to be moved.
4047 /// \param __n
4048 ///    A 128-bit integer vector containing the mask. The most significant bit of
4049 ///    each byte represents the mask bits.
4050 /// \param __p
4051 ///    A pointer to an unaligned 128-bit memory location where the specified
4052 ///    values are moved.
4053 static __inline__ void __DEFAULT_FN_ATTRS
4054 _mm_maskmoveu_si128(__m128i __d, __m128i __n, char *__p)
4055 {
4056   __builtin_ia32_maskmovdqu((__v16qi)__d, (__v16qi)__n, __p);
4057 }
4058
4059 /// \brief Stores the lower 64 bits of a 128-bit integer vector of [2 x i64] to
4060 ///    a memory location.
4061 ///
4062 /// \headerfile <x86intrin.h>
4063 ///
4064 /// This intrinsic corresponds to the <c> VMOVLPS / MOVLPS </c> instruction.
4065 ///
4066 /// \param __p
4067 ///    A pointer to a 64-bit memory location that will receive the lower 64 bits
4068 ///    of the integer vector parameter.
4069 /// \param __a
4070 ///    A 128-bit integer vector of [2 x i64]. The lower 64 bits contain the
4071 ///    value to be stored.
4072 static __inline__ void __DEFAULT_FN_ATTRS
4073 _mm_storel_epi64(__m128i *__p, __m128i __a)
4074 {
4075   struct __mm_storel_epi64_struct {
4076     long long __u;
4077   } __attribute__((__packed__, __may_alias__));
4078   ((struct __mm_storel_epi64_struct*)__p)->__u = __a[0];
4079 }
4080
4081 /// \brief Stores a 128-bit floating point vector of [2 x double] to a 128-bit
4082 ///    aligned memory location.
4083 ///
4084 ///    To minimize caching, the data is flagged as non-temporal (unlikely to be
4085 ///    used again soon).
4086 ///
4087 /// \headerfile <x86intrin.h>
4088 ///
4089 /// This intrinsic corresponds to the <c> VMOVNTPS / MOVNTPS </c> instruction.
4090 ///
4091 /// \param __p
4092 ///    A pointer to the 128-bit aligned memory location used to store the value.
4093 /// \param __a
4094 ///    A vector of [2 x double] containing the 64-bit values to be stored.
4095 static __inline__ void __DEFAULT_FN_ATTRS
4096 _mm_stream_pd(double *__p, __m128d __a)
4097 {
4098   __builtin_nontemporal_store((__v2df)__a, (__v2df*)__p);
4099 }
4100
4101 /// \brief Stores a 128-bit integer vector to a 128-bit aligned memory location.
4102 ///
4103 ///    To minimize caching, the data is flagged as non-temporal (unlikely to be
4104 ///    used again soon).
4105 ///
4106 /// \headerfile <x86intrin.h>
4107 ///
4108 /// This intrinsic corresponds to the <c> VMOVNTPS / MOVNTPS </c> instruction.
4109 ///
4110 /// \param __p
4111 ///    A pointer to the 128-bit aligned memory location used to store the value.
4112 /// \param __a
4113 ///    A 128-bit integer vector containing the values to be stored.
4114 static __inline__ void __DEFAULT_FN_ATTRS
4115 _mm_stream_si128(__m128i *__p, __m128i __a)
4116 {
4117   __builtin_nontemporal_store((__v2di)__a, (__v2di*)__p);
4118 }
4119
4120 /// \brief Stores a 32-bit integer value in the specified memory location.
4121 ///
4122 ///    To minimize caching, the data is flagged as non-temporal (unlikely to be
4123 ///    used again soon).
4124 ///
4125 /// \headerfile <x86intrin.h>
4126 ///
4127 /// This intrinsic corresponds to the <c> MOVNTI </c> instruction.
4128 ///
4129 /// \param __p
4130 ///    A pointer to the 32-bit memory location used to store the value.
4131 /// \param __a
4132 ///    A 32-bit integer containing the value to be stored.
4133 static __inline__ void __DEFAULT_FN_ATTRS
4134 _mm_stream_si32(int *__p, int __a)
4135 {
4136   __builtin_ia32_movnti(__p, __a);
4137 }
4138
4139 #ifdef __x86_64__
4140 /// \brief Stores a 64-bit integer value in the specified memory location.
4141 ///
4142 ///    To minimize caching, the data is flagged as non-temporal (unlikely to be
4143 ///    used again soon).
4144 ///
4145 /// \headerfile <x86intrin.h>
4146 ///
4147 /// This intrinsic corresponds to the <c> MOVNTIQ </c> instruction.
4148 ///
4149 /// \param __p
4150 ///    A pointer to the 64-bit memory location used to store the value.
4151 /// \param __a
4152 ///    A 64-bit integer containing the value to be stored.
4153 static __inline__ void __DEFAULT_FN_ATTRS
4154 _mm_stream_si64(long long *__p, long long __a)
4155 {
4156   __builtin_ia32_movnti64(__p, __a);
4157 }
4158 #endif
4159
4160 #if defined(__cplusplus)
4161 extern "C" {
4162 #endif
4163
4164 /// \brief The cache line containing \a __p is flushed and invalidated from all
4165 ///    caches in the coherency domain.
4166 ///
4167 /// \headerfile <x86intrin.h>
4168 ///
4169 /// This intrinsic corresponds to the <c> CLFLUSH </c> instruction.
4170 ///
4171 /// \param __p
4172 ///    A pointer to the memory location used to identify the cache line to be
4173 ///    flushed.
4174 void _mm_clflush(void const * __p);
4175
4176 /// \brief Forces strong memory ordering (serialization) between load
4177 ///    instructions preceding this instruction and load instructions following
4178 ///    this instruction, ensuring the system completes all previous loads before
4179 ///    executing subsequent loads.
4180 ///
4181 /// \headerfile <x86intrin.h>
4182 ///
4183 /// This intrinsic corresponds to the <c> LFENCE </c> instruction.
4184 ///
4185 void _mm_lfence(void);
4186
4187 /// \brief Forces strong memory ordering (serialization) between load and store
4188 ///    instructions preceding this instruction and load and store instructions
4189 ///    following this instruction, ensuring that the system completes all
4190 ///    previous memory accesses before executing subsequent memory accesses.
4191 ///
4192 /// \headerfile <x86intrin.h>
4193 ///
4194 /// This intrinsic corresponds to the <c> MFENCE </c> instruction.
4195 ///
4196 void _mm_mfence(void);
4197
4198 #if defined(__cplusplus)
4199 } // extern "C"
4200 #endif
4201
4202 /// \brief Converts 16-bit signed integers from both 128-bit integer vector
4203 ///    operands into 8-bit signed integers, and packs the results into the
4204 ///    destination. Positive values greater than 0x7F are saturated to 0x7F.
4205 ///    Negative values less than 0x80 are saturated to 0x80.
4206 ///
4207 /// \headerfile <x86intrin.h>
4208 ///
4209 /// This intrinsic corresponds to the <c> VPACKSSWB / PACKSSWB </c> instruction.
4210 ///
4211 /// \param __a
4212 ///   A 128-bit integer vector of [8 x i16]. Each 16-bit element is treated as
4213 ///   a signed integer and is converted to a 8-bit signed integer with
4214 ///   saturation. Values greater than 0x7F are saturated to 0x7F. Values less
4215 ///   than 0x80 are saturated to 0x80. The converted [8 x i8] values are
4216 ///   written to the lower 64 bits of the result.
4217 /// \param __b
4218 ///   A 128-bit integer vector of [8 x i16]. Each 16-bit element is treated as
4219 ///   a signed integer and is converted to a 8-bit signed integer with
4220 ///   saturation. Values greater than 0x7F are saturated to 0x7F. Values less
4221 ///   than 0x80 are saturated to 0x80. The converted [8 x i8] values are
4222 ///   written to the higher 64 bits of the result.
4223 /// \returns A 128-bit vector of [16 x i8] containing the converted values.
4224 static __inline__ __m128i __DEFAULT_FN_ATTRS
4225 _mm_packs_epi16(__m128i __a, __m128i __b)
4226 {
4227   return (__m128i)__builtin_ia32_packsswb128((__v8hi)__a, (__v8hi)__b);
4228 }
4229
4230 /// \brief Converts 32-bit signed integers from both 128-bit integer vector
4231 ///    operands into 16-bit signed integers, and packs the results into the
4232 ///    destination. Positive values greater than 0x7FFF are saturated to 0x7FFF.
4233 ///    Negative values less than 0x8000 are saturated to 0x8000.
4234 ///
4235 /// \headerfile <x86intrin.h>
4236 ///
4237 /// This intrinsic corresponds to the <c> VPACKSSDW / PACKSSDW </c> instruction.
4238 ///
4239 /// \param __a
4240 ///    A 128-bit integer vector of [4 x i32]. Each 32-bit element is treated as
4241 ///    a signed integer and is converted to a 16-bit signed integer with
4242 ///    saturation. Values greater than 0x7FFF are saturated to 0x7FFF. Values
4243 ///    less than 0x8000 are saturated to 0x8000. The converted [4 x i16] values
4244 ///    are written to the lower 64 bits of the result.
4245 /// \param __b
4246 ///    A 128-bit integer vector of [4 x i32]. Each 32-bit element is treated as
4247 ///    a signed integer and is converted to a 16-bit signed integer with
4248 ///    saturation. Values greater than 0x7FFF are saturated to 0x7FFF. Values
4249 ///    less than 0x8000 are saturated to 0x8000. The converted [4 x i16] values
4250 ///    are written to the higher 64 bits of the result.
4251 /// \returns A 128-bit vector of [8 x i16] containing the converted values.
4252 static __inline__ __m128i __DEFAULT_FN_ATTRS
4253 _mm_packs_epi32(__m128i __a, __m128i __b)
4254 {
4255   return (__m128i)__builtin_ia32_packssdw128((__v4si)__a, (__v4si)__b);
4256 }
4257
4258 /// \brief Converts 16-bit signed integers from both 128-bit integer vector
4259 ///    operands into 8-bit unsigned integers, and packs the results into the
4260 ///    destination. Values greater than 0xFF are saturated to 0xFF. Values less
4261 ///    than 0x00 are saturated to 0x00.
4262 ///
4263 /// \headerfile <x86intrin.h>
4264 ///
4265 /// This intrinsic corresponds to the <c> VPACKUSWB / PACKUSWB </c> instruction.
4266 ///
4267 /// \param __a
4268 ///    A 128-bit integer vector of [8 x i16]. Each 16-bit element is treated as
4269 ///    a signed integer and is converted to an 8-bit unsigned integer with
4270 ///    saturation. Values greater than 0xFF are saturated to 0xFF. Values less
4271 ///    than 0x00 are saturated to 0x00. The converted [8 x i8] values are
4272 ///    written to the lower 64 bits of the result.
4273 /// \param __b
4274 ///    A 128-bit integer vector of [8 x i16]. Each 16-bit element is treated as
4275 ///    a signed integer and is converted to an 8-bit unsigned integer with
4276 ///    saturation. Values greater than 0xFF are saturated to 0xFF. Values less
4277 ///    than 0x00 are saturated to 0x00. The converted [8 x i8] values are
4278 ///    written to the higher 64 bits of the result.
4279 /// \returns A 128-bit vector of [16 x i8] containing the converted values.
4280 static __inline__ __m128i __DEFAULT_FN_ATTRS
4281 _mm_packus_epi16(__m128i __a, __m128i __b)
4282 {
4283   return (__m128i)__builtin_ia32_packuswb128((__v8hi)__a, (__v8hi)__b);
4284 }
4285
4286 /// \brief Extracts 16 bits from a 128-bit integer vector of [8 x i16], using
4287 ///    the immediate-value parameter as a selector.
4288 ///
4289 /// \headerfile <x86intrin.h>
4290 ///
4291 /// This intrinsic corresponds to the <c> VPEXTRW / PEXTRW </c> instruction.
4292 ///
4293 /// \param __a
4294 ///    A 128-bit integer vector.
4295 /// \param __imm
4296 ///    An immediate value. Bits [2:0] selects values from \a __a to be assigned
4297 ///    to bits[15:0] of the result. \n
4298 ///    000: assign values from bits [15:0] of \a __a. \n
4299 ///    001: assign values from bits [31:16] of \a __a. \n
4300 ///    010: assign values from bits [47:32] of \a __a. \n
4301 ///    011: assign values from bits [63:48] of \a __a. \n
4302 ///    100: assign values from bits [79:64] of \a __a. \n
4303 ///    101: assign values from bits [95:80] of \a __a. \n
4304 ///    110: assign values from bits [111:96] of \a __a. \n
4305 ///    111: assign values from bits [127:112] of \a __a.
4306 /// \returns An integer, whose lower 16 bits are selected from the 128-bit
4307 ///    integer vector parameter and the remaining bits are assigned zeros.
4308 static __inline__ int __DEFAULT_FN_ATTRS
4309 _mm_extract_epi16(__m128i __a, int __imm)
4310 {
4311   __v8hi __b = (__v8hi)__a;
4312   return (unsigned short)__b[__imm & 7];
4313 }
4314
4315 /// \brief Constructs a 128-bit integer vector by first making a copy of the
4316 ///    128-bit integer vector parameter, and then inserting the lower 16 bits
4317 ///    of an integer parameter into an offset specified by the immediate-value
4318 ///    parameter.
4319 ///
4320 /// \headerfile <x86intrin.h>
4321 ///
4322 /// This intrinsic corresponds to the <c> VPINSRW / PINSRW </c> instruction.
4323 ///
4324 /// \param __a
4325 ///    A 128-bit integer vector of [8 x i16]. This vector is copied to the
4326 ///    result and then one of the eight elements in the result is replaced by
4327 ///    the lower 16 bits of \a __b.
4328 /// \param __b
4329 ///    An integer. The lower 16 bits of this parameter are written to the
4330 ///    result beginning at an offset specified by \a __imm.
4331 /// \param __imm
4332 ///    An immediate value specifying the bit offset in the result at which the
4333 ///    lower 16 bits of \a __b are written.
4334 /// \returns A 128-bit integer vector containing the constructed values.
4335 static __inline__ __m128i __DEFAULT_FN_ATTRS
4336 _mm_insert_epi16(__m128i __a, int __b, int __imm)
4337 {
4338   __v8hi __c = (__v8hi)__a;
4339   __c[__imm & 7] = __b;
4340   return (__m128i)__c;
4341 }
4342
4343 /// \brief Copies the values of the most significant bits from each 8-bit
4344 ///    element in a 128-bit integer vector of [16 x i8] to create a 16-bit mask
4345 ///    value, zero-extends the value, and writes it to the destination.
4346 ///
4347 /// \headerfile <x86intrin.h>
4348 ///
4349 /// This intrinsic corresponds to the <c> VPMOVMSKB / PMOVMSKB </c> instruction.
4350 ///
4351 /// \param __a
4352 ///    A 128-bit integer vector containing the values with bits to be extracted.
4353 /// \returns The most significant bits from each 8-bit element in \a __a,
4354 ///    written to bits [15:0]. The other bits are assigned zeros.
4355 static __inline__ int __DEFAULT_FN_ATTRS
4356 _mm_movemask_epi8(__m128i __a)
4357 {
4358   return __builtin_ia32_pmovmskb128((__v16qi)__a);
4359 }
4360
4361 /// \brief Constructs a 128-bit integer vector by shuffling four 32-bit
4362 ///    elements of a 128-bit integer vector parameter, using the immediate-value
4363 ///    parameter as a specifier.
4364 ///
4365 /// \headerfile <x86intrin.h>
4366 ///
4367 /// \code
4368 /// __m128i _mm_shuffle_epi32(__m128i a, const int imm);
4369 /// \endcode
4370 ///
4371 /// This intrinsic corresponds to the <c> VPSHUFD / PSHUFD </c> instruction.
4372 ///
4373 /// \param a
4374 ///    A 128-bit integer vector containing the values to be copied.
4375 /// \param imm
4376 ///    An immediate value containing an 8-bit value specifying which elements to
4377 ///    copy from a. The destinations within the 128-bit destination are assigned
4378 ///    values as follows: \n
4379 ///    Bits [1:0] are used to assign values to bits [31:0] of the result. \n
4380 ///    Bits [3:2] are used to assign values to bits [63:32] of the result. \n
4381 ///    Bits [5:4] are used to assign values to bits [95:64] of the result. \n
4382 ///    Bits [7:6] are used to assign values to bits [127:96] of the result. \n
4383 ///    Bit value assignments: \n
4384 ///    00: assign values from bits [31:0] of \a a. \n
4385 ///    01: assign values from bits [63:32] of \a a. \n
4386 ///    10: assign values from bits [95:64] of \a a. \n
4387 ///    11: assign values from bits [127:96] of \a a.
4388 /// \returns A 128-bit integer vector containing the shuffled values.
4389 #define _mm_shuffle_epi32(a, imm) __extension__ ({ \
4390   (__m128i)__builtin_shufflevector((__v4si)(__m128i)(a), \
4391                                    (__v4si)_mm_undefined_si128(), \
4392                                    ((imm) >> 0) & 0x3, ((imm) >> 2) & 0x3, \
4393                                    ((imm) >> 4) & 0x3, ((imm) >> 6) & 0x3); })
4394
4395 /// \brief Constructs a 128-bit integer vector by shuffling four lower 16-bit
4396 ///    elements of a 128-bit integer vector of [8 x i16], using the immediate
4397 ///    value parameter as a specifier.
4398 ///
4399 /// \headerfile <x86intrin.h>
4400 ///
4401 /// \code
4402 /// __m128i _mm_shufflelo_epi16(__m128i a, const int imm);
4403 /// \endcode
4404 ///
4405 /// This intrinsic corresponds to the <c> VPSHUFLW / PSHUFLW </c> instruction.
4406 ///
4407 /// \param a
4408 ///    A 128-bit integer vector of [8 x i16]. Bits [127:64] are copied to bits
4409 ///    [127:64] of the result.
4410 /// \param imm
4411 ///    An 8-bit immediate value specifying which elements to copy from \a a. \n
4412 ///    Bits[1:0] are used to assign values to bits [15:0] of the result. \n
4413 ///    Bits[3:2] are used to assign values to bits [31:16] of the result. \n
4414 ///    Bits[5:4] are used to assign values to bits [47:32] of the result. \n
4415 ///    Bits[7:6] are used to assign values to bits [63:48] of the result. \n
4416 ///    Bit value assignments: \n
4417 ///    00: assign values from bits [15:0] of \a a. \n
4418 ///    01: assign values from bits [31:16] of \a a. \n
4419 ///    10: assign values from bits [47:32] of \a a. \n
4420 ///    11: assign values from bits [63:48] of \a a. \n
4421 /// \returns A 128-bit integer vector containing the shuffled values.
4422 #define _mm_shufflelo_epi16(a, imm) __extension__ ({ \
4423   (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), \
4424                                    (__v8hi)_mm_undefined_si128(), \
4425                                    ((imm) >> 0) & 0x3, ((imm) >> 2) & 0x3, \
4426                                    ((imm) >> 4) & 0x3, ((imm) >> 6) & 0x3, \
4427                                    4, 5, 6, 7); })
4428
4429 /// \brief Constructs a 128-bit integer vector by shuffling four upper 16-bit
4430 ///    elements of a 128-bit integer vector of [8 x i16], using the immediate
4431 ///    value parameter as a specifier.
4432 ///
4433 /// \headerfile <x86intrin.h>
4434 ///
4435 /// \code
4436 /// __m128i _mm_shufflehi_epi16(__m128i a, const int imm);
4437 /// \endcode
4438 ///
4439 /// This intrinsic corresponds to the <c> VPSHUFHW / PSHUFHW </c> instruction.
4440 ///
4441 /// \param a
4442 ///    A 128-bit integer vector of [8 x i16]. Bits [63:0] are copied to bits
4443 ///    [63:0] of the result.
4444 /// \param imm
4445 ///    An 8-bit immediate value specifying which elements to copy from \a a. \n
4446 ///    Bits[1:0] are used to assign values to bits [79:64] of the result. \n
4447 ///    Bits[3:2] are used to assign values to bits [95:80] of the result. \n
4448 ///    Bits[5:4] are used to assign values to bits [111:96] of the result. \n
4449 ///    Bits[7:6] are used to assign values to bits [127:112] of the result. \n
4450 ///    Bit value assignments: \n
4451 ///    00: assign values from bits [79:64] of \a a. \n
4452 ///    01: assign values from bits [95:80] of \a a. \n
4453 ///    10: assign values from bits [111:96] of \a a. \n
4454 ///    11: assign values from bits [127:112] of \a a. \n
4455 /// \returns A 128-bit integer vector containing the shuffled values.
4456 #define _mm_shufflehi_epi16(a, imm) __extension__ ({ \
4457   (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), \
4458                                    (__v8hi)_mm_undefined_si128(), \
4459                                    0, 1, 2, 3, \
4460                                    4 + (((imm) >> 0) & 0x3), \
4461                                    4 + (((imm) >> 2) & 0x3), \
4462                                    4 + (((imm) >> 4) & 0x3), \
4463                                    4 + (((imm) >> 6) & 0x3)); })
4464
4465 /// \brief Unpacks the high-order (index 8-15) values from two 128-bit vectors
4466 ///    of [16 x i8] and interleaves them into a 128-bit vector of [16 x i8].
4467 ///
4468 /// \headerfile <x86intrin.h>
4469 ///
4470 /// This intrinsic corresponds to the <c> VPUNPCKHBW / PUNPCKHBW </c>
4471 ///   instruction.
4472 ///
4473 /// \param __a
4474 ///    A 128-bit vector of [16 x i8].
4475 ///    Bits [71:64] are written to bits [7:0] of the result. \n
4476 ///    Bits [79:72] are written to bits [23:16] of the result. \n
4477 ///    Bits [87:80] are written to bits [39:32] of the result. \n
4478 ///    Bits [95:88] are written to bits [55:48] of the result. \n
4479 ///    Bits [103:96] are written to bits [71:64] of the result. \n
4480 ///    Bits [111:104] are written to bits [87:80] of the result. \n
4481 ///    Bits [119:112] are written to bits [103:96] of the result. \n
4482 ///    Bits [127:120] are written to bits [119:112] of the result.
4483 /// \param __b
4484 ///    A 128-bit vector of [16 x i8]. \n
4485 ///    Bits [71:64] are written to bits [15:8] of the result. \n
4486 ///    Bits [79:72] are written to bits [31:24] of the result. \n
4487 ///    Bits [87:80] are written to bits [47:40] of the result. \n
4488 ///    Bits [95:88] are written to bits [63:56] of the result. \n
4489 ///    Bits [103:96] are written to bits [79:72] of the result. \n
4490 ///    Bits [111:104] are written to bits [95:88] of the result. \n
4491 ///    Bits [119:112] are written to bits [111:104] of the result. \n
4492 ///    Bits [127:120] are written to bits [127:120] of the result.
4493 /// \returns A 128-bit vector of [16 x i8] containing the interleaved values.
4494 static __inline__ __m128i __DEFAULT_FN_ATTRS
4495 _mm_unpackhi_epi8(__m128i __a, __m128i __b)
4496 {
4497   return (__m128i)__builtin_shufflevector((__v16qi)__a, (__v16qi)__b, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15);
4498 }
4499
4500 /// \brief Unpacks the high-order (index 4-7) values from two 128-bit vectors of
4501 ///    [8 x i16] and interleaves them into a 128-bit vector of [8 x i16].
4502 ///
4503 /// \headerfile <x86intrin.h>
4504 ///
4505 /// This intrinsic corresponds to the <c> VPUNPCKHWD / PUNPCKHWD </c>
4506 ///   instruction.
4507 ///
4508 /// \param __a
4509 ///    A 128-bit vector of [8 x i16].
4510 ///    Bits [79:64] are written to bits [15:0] of the result. \n
4511 ///    Bits [95:80] are written to bits [47:32] of the result. \n
4512 ///    Bits [111:96] are written to bits [79:64] of the result. \n
4513 ///    Bits [127:112] are written to bits [111:96] of the result.
4514 /// \param __b
4515 ///    A 128-bit vector of [8 x i16].
4516 ///    Bits [79:64] are written to bits [31:16] of the result. \n
4517 ///    Bits [95:80] are written to bits [63:48] of the result. \n
4518 ///    Bits [111:96] are written to bits [95:80] of the result. \n
4519 ///    Bits [127:112] are written to bits [127:112] of the result.
4520 /// \returns A 128-bit vector of [8 x i16] containing the interleaved values.
4521 static __inline__ __m128i __DEFAULT_FN_ATTRS
4522 _mm_unpackhi_epi16(__m128i __a, __m128i __b)
4523 {
4524   return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7);
4525 }
4526
4527 /// \brief Unpacks the high-order (index 2,3) values from two 128-bit vectors of
4528 ///    [4 x i32] and interleaves them into a 128-bit vector of [4 x i32].
4529 ///
4530 /// \headerfile <x86intrin.h>
4531 ///
4532 /// This intrinsic corresponds to the <c> VPUNPCKHDQ / PUNPCKHDQ </c>
4533 ///   instruction.
4534 ///
4535 /// \param __a
4536 ///    A 128-bit vector of [4 x i32]. \n
4537 ///    Bits [95:64] are written to bits [31:0] of the destination. \n
4538 ///    Bits [127:96] are written to bits [95:64] of the destination.
4539 /// \param __b
4540 ///    A 128-bit vector of [4 x i32]. \n
4541 ///    Bits [95:64] are written to bits [64:32] of the destination. \n
4542 ///    Bits [127:96] are written to bits [127:96] of the destination.
4543 /// \returns A 128-bit vector of [4 x i32] containing the interleaved values.
4544 static __inline__ __m128i __DEFAULT_FN_ATTRS
4545 _mm_unpackhi_epi32(__m128i __a, __m128i __b)
4546 {
4547   return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 2, 4+2, 3, 4+3);
4548 }
4549
4550 /// \brief Unpacks the high-order 64-bit elements from two 128-bit vectors of
4551 ///    [2 x i64] and interleaves them into a 128-bit vector of [2 x i64].
4552 ///
4553 /// \headerfile <x86intrin.h>
4554 ///
4555 /// This intrinsic corresponds to the <c> VPUNPCKHQDQ / PUNPCKHQDQ </c>
4556 ///   instruction.
4557 ///
4558 /// \param __a
4559 ///    A 128-bit vector of [2 x i64]. \n
4560 ///    Bits [127:64] are written to bits [63:0] of the destination.
4561 /// \param __b
4562 ///    A 128-bit vector of [2 x i64]. \n
4563 ///    Bits [127:64] are written to bits [127:64] of the destination.
4564 /// \returns A 128-bit vector of [2 x i64] containing the interleaved values.
4565 static __inline__ __m128i __DEFAULT_FN_ATTRS
4566 _mm_unpackhi_epi64(__m128i __a, __m128i __b)
4567 {
4568   return (__m128i)__builtin_shufflevector((__v2di)__a, (__v2di)__b, 1, 2+1);
4569 }
4570
4571 /// \brief Unpacks the low-order (index 0-7) values from two 128-bit vectors of
4572 ///    [16 x i8] and interleaves them into a 128-bit vector of [16 x i8].
4573 ///
4574 /// \headerfile <x86intrin.h>
4575 ///
4576 /// This intrinsic corresponds to the <c> VPUNPCKLBW / PUNPCKLBW </c>
4577 ///   instruction.
4578 ///
4579 /// \param __a
4580 ///    A 128-bit vector of [16 x i8]. \n
4581 ///    Bits [7:0] are written to bits [7:0] of the result. \n
4582 ///    Bits [15:8] are written to bits [23:16] of the result. \n
4583 ///    Bits [23:16] are written to bits [39:32] of the result. \n
4584 ///    Bits [31:24] are written to bits [55:48] of the result. \n
4585 ///    Bits [39:32] are written to bits [71:64] of the result. \n
4586 ///    Bits [47:40] are written to bits [87:80] of the result. \n
4587 ///    Bits [55:48] are written to bits [103:96] of the result. \n
4588 ///    Bits [63:56] are written to bits [119:112] of the result.
4589 /// \param __b
4590 ///    A 128-bit vector of [16 x i8].
4591 ///    Bits [7:0] are written to bits [15:8] of the result. \n
4592 ///    Bits [15:8] are written to bits [31:24] of the result. \n
4593 ///    Bits [23:16] are written to bits [47:40] of the result. \n
4594 ///    Bits [31:24] are written to bits [63:56] of the result. \n
4595 ///    Bits [39:32] are written to bits [79:72] of the result. \n
4596 ///    Bits [47:40] are written to bits [95:88] of the result. \n
4597 ///    Bits [55:48] are written to bits [111:104] of the result. \n
4598 ///    Bits [63:56] are written to bits [127:120] of the result.
4599 /// \returns A 128-bit vector of [16 x i8] containing the interleaved values.
4600 static __inline__ __m128i __DEFAULT_FN_ATTRS
4601 _mm_unpacklo_epi8(__m128i __a, __m128i __b)
4602 {
4603   return (__m128i)__builtin_shufflevector((__v16qi)__a, (__v16qi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7);
4604 }
4605
4606 /// \brief Unpacks the low-order (index 0-3) values from each of the two 128-bit
4607 ///    vectors of [8 x i16] and interleaves them into a 128-bit vector of
4608 ///    [8 x i16].
4609 ///
4610 /// \headerfile <x86intrin.h>
4611 ///
4612 /// This intrinsic corresponds to the <c> VPUNPCKLWD / PUNPCKLWD </c>
4613 ///   instruction.
4614 ///
4615 /// \param __a
4616 ///    A 128-bit vector of [8 x i16].
4617 ///    Bits [15:0] are written to bits [15:0] of the result. \n
4618 ///    Bits [31:16] are written to bits [47:32] of the result. \n
4619 ///    Bits [47:32] are written to bits [79:64] of the result. \n
4620 ///    Bits [63:48] are written to bits [111:96] of the result.
4621 /// \param __b
4622 ///    A 128-bit vector of [8 x i16].
4623 ///    Bits [15:0] are written to bits [31:16] of the result. \n
4624 ///    Bits [31:16] are written to bits [63:48] of the result. \n
4625 ///    Bits [47:32] are written to bits [95:80] of the result. \n
4626 ///    Bits [63:48] are written to bits [127:112] of the result.
4627 /// \returns A 128-bit vector of [8 x i16] containing the interleaved values.
4628 static __inline__ __m128i __DEFAULT_FN_ATTRS
4629 _mm_unpacklo_epi16(__m128i __a, __m128i __b)
4630 {
4631   return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3);
4632 }
4633
4634 /// \brief Unpacks the low-order (index 0,1) values from two 128-bit vectors of
4635 ///    [4 x i32] and interleaves them into a 128-bit vector of [4 x i32].
4636 ///
4637 /// \headerfile <x86intrin.h>
4638 ///
4639 /// This intrinsic corresponds to the <c> VPUNPCKLDQ / PUNPCKLDQ </c>
4640 ///   instruction.
4641 ///
4642 /// \param __a
4643 ///    A 128-bit vector of [4 x i32]. \n
4644 ///    Bits [31:0] are written to bits [31:0] of the destination. \n
4645 ///    Bits [63:32] are written to bits [95:64] of the destination.
4646 /// \param __b
4647 ///    A 128-bit vector of [4 x i32]. \n
4648 ///    Bits [31:0] are written to bits [64:32] of the destination. \n
4649 ///    Bits [63:32] are written to bits [127:96] of the destination.
4650 /// \returns A 128-bit vector of [4 x i32] containing the interleaved values.
4651 static __inline__ __m128i __DEFAULT_FN_ATTRS
4652 _mm_unpacklo_epi32(__m128i __a, __m128i __b)
4653 {
4654   return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 0, 4+0, 1, 4+1);
4655 }
4656
4657 /// \brief Unpacks the low-order 64-bit elements from two 128-bit vectors of
4658 ///    [2 x i64] and interleaves them into a 128-bit vector of [2 x i64].
4659 ///
4660 /// \headerfile <x86intrin.h>
4661 ///
4662 /// This intrinsic corresponds to the <c> VPUNPCKLQDQ / PUNPCKLQDQ </c>
4663 ///   instruction.
4664 ///
4665 /// \param __a
4666 ///    A 128-bit vector of [2 x i64]. \n
4667 ///    Bits [63:0] are written to bits [63:0] of the destination. \n
4668 /// \param __b
4669 ///    A 128-bit vector of [2 x i64]. \n
4670 ///    Bits [63:0] are written to bits [127:64] of the destination. \n
4671 /// \returns A 128-bit vector of [2 x i64] containing the interleaved values.
4672 static __inline__ __m128i __DEFAULT_FN_ATTRS
4673 _mm_unpacklo_epi64(__m128i __a, __m128i __b)
4674 {
4675   return (__m128i)__builtin_shufflevector((__v2di)__a, (__v2di)__b, 0, 2+0);
4676 }
4677
4678 /// \brief Returns the lower 64 bits of a 128-bit integer vector as a 64-bit
4679 ///    integer.
4680 ///
4681 /// \headerfile <x86intrin.h>
4682 ///
4683 /// This intrinsic corresponds to the <c> MOVDQ2Q </c> instruction.
4684 ///
4685 /// \param __a
4686 ///    A 128-bit integer vector operand. The lower 64 bits are moved to the
4687 ///    destination.
4688 /// \returns A 64-bit integer containing the lower 64 bits of the parameter.
4689 static __inline__ __m64 __DEFAULT_FN_ATTRS
4690 _mm_movepi64_pi64(__m128i __a)
4691 {
4692   return (__m64)__a[0];
4693 }
4694
4695 /// \brief Moves the 64-bit operand to a 128-bit integer vector, zeroing the
4696 ///    upper bits.
4697 ///
4698 /// \headerfile <x86intrin.h>
4699 ///
4700 /// This intrinsic corresponds to the <c> MOVD+VMOVQ </c> instruction.
4701 ///
4702 /// \param __a
4703 ///    A 64-bit value.
4704 /// \returns A 128-bit integer vector. The lower 64 bits contain the value from
4705 ///    the operand. The upper 64 bits are assigned zeros.
4706 static __inline__ __m128i __DEFAULT_FN_ATTRS
4707 _mm_movpi64_epi64(__m64 __a)
4708 {
4709   return (__m128i){ (long long)__a, 0 };
4710 }
4711
4712 /// \brief Moves the lower 64 bits of a 128-bit integer vector to a 128-bit
4713 ///    integer vector, zeroing the upper bits.
4714 ///
4715 /// \headerfile <x86intrin.h>
4716 ///
4717 /// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
4718 ///
4719 /// \param __a
4720 ///    A 128-bit integer vector operand. The lower 64 bits are moved to the
4721 ///    destination.
4722 /// \returns A 128-bit integer vector. The lower 64 bits contain the value from
4723 ///    the operand. The upper 64 bits are assigned zeros.
4724 static __inline__ __m128i __DEFAULT_FN_ATTRS
4725 _mm_move_epi64(__m128i __a)
4726 {
4727   return __builtin_shufflevector((__v2di)__a, (__m128i){ 0 }, 0, 2);
4728 }
4729
4730 /// \brief Unpacks the high-order 64-bit elements from two 128-bit vectors of
4731 ///    [2 x double] and interleaves them into a 128-bit vector of [2 x
4732 ///    double].
4733 ///
4734 /// \headerfile <x86intrin.h>
4735 ///
4736 /// This intrinsic corresponds to the <c> VUNPCKHPD / UNPCKHPD </c> instruction.
4737 ///
4738 /// \param __a
4739 ///    A 128-bit vector of [2 x double]. \n
4740 ///    Bits [127:64] are written to bits [63:0] of the destination.
4741 /// \param __b
4742 ///    A 128-bit vector of [2 x double]. \n
4743 ///    Bits [127:64] are written to bits [127:64] of the destination.
4744 /// \returns A 128-bit vector of [2 x double] containing the interleaved values.
4745 static __inline__ __m128d __DEFAULT_FN_ATTRS
4746 _mm_unpackhi_pd(__m128d __a, __m128d __b)
4747 {
4748   return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 1, 2+1);
4749 }
4750
4751 /// \brief Unpacks the low-order 64-bit elements from two 128-bit vectors
4752 ///    of [2 x double] and interleaves them into a 128-bit vector of [2 x
4753 ///    double].
4754 ///
4755 /// \headerfile <x86intrin.h>
4756 ///
4757 /// This intrinsic corresponds to the <c> VUNPCKLPD / UNPCKLPD </c> instruction.
4758 ///
4759 /// \param __a
4760 ///    A 128-bit vector of [2 x double]. \n
4761 ///    Bits [63:0] are written to bits [63:0] of the destination.
4762 /// \param __b
4763 ///    A 128-bit vector of [2 x double]. \n
4764 ///    Bits [63:0] are written to bits [127:64] of the destination.
4765 /// \returns A 128-bit vector of [2 x double] containing the interleaved values.
4766 static __inline__ __m128d __DEFAULT_FN_ATTRS
4767 _mm_unpacklo_pd(__m128d __a, __m128d __b)
4768 {
4769   return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 0, 2+0);
4770 }
4771
4772 /// \brief Extracts the sign bits of the double-precision values in the 128-bit
4773 ///    vector of [2 x double], zero-extends the value, and writes it to the
4774 ///    low-order bits of the destination.
4775 ///
4776 /// \headerfile <x86intrin.h>
4777 ///
4778 /// This intrinsic corresponds to the <c> VMOVMSKPD / MOVMSKPD </c> instruction.
4779 ///
4780 /// \param __a
4781 ///    A 128-bit vector of [2 x double] containing the values with sign bits to
4782 ///    be extracted.
4783 /// \returns The sign bits from each of the double-precision elements in \a __a,
4784 ///    written to bits [1:0]. The remaining bits are assigned values of zero.
4785 static __inline__ int __DEFAULT_FN_ATTRS
4786 _mm_movemask_pd(__m128d __a)
4787 {
4788   return __builtin_ia32_movmskpd((__v2df)__a);
4789 }
4790
4791
4792 /// \brief Constructs a 128-bit floating-point vector of [2 x double] from two
4793 ///    128-bit vector parameters of [2 x double], using the immediate-value
4794 ///     parameter as a specifier.
4795 ///
4796 /// \headerfile <x86intrin.h>
4797 ///
4798 /// \code
4799 /// __m128d _mm_shuffle_pd(__m128d a, __m128d b, const int i);
4800 /// \endcode
4801 ///
4802 /// This intrinsic corresponds to the <c> VSHUFPD / SHUFPD </c> instruction.
4803 ///
4804 /// \param a
4805 ///    A 128-bit vector of [2 x double].
4806 /// \param b
4807 ///    A 128-bit vector of [2 x double].
4808 /// \param i
4809 ///    An 8-bit immediate value. The least significant two bits specify which
4810 ///    elements to copy from \a a and \a b: \n
4811 ///    Bit[0] = 0: lower element of \a a copied to lower element of result. \n
4812 ///    Bit[0] = 1: upper element of \a a copied to lower element of result. \n
4813 ///    Bit[1] = 0: lower element of \a b copied to upper element of result. \n
4814 ///    Bit[1] = 1: upper element of \a b copied to upper element of result. \n
4815 /// \returns A 128-bit vector of [2 x double] containing the shuffled values.
4816 #define _mm_shuffle_pd(a, b, i) __extension__ ({ \
4817   (__m128d)__builtin_shufflevector((__v2df)(__m128d)(a), (__v2df)(__m128d)(b), \
4818                                    0 + (((i) >> 0) & 0x1), \
4819                                    2 + (((i) >> 1) & 0x1)); })
4820
4821 /// \brief Casts a 128-bit floating-point vector of [2 x double] into a 128-bit
4822 ///    floating-point vector of [4 x float].
4823 ///
4824 /// \headerfile <x86intrin.h>
4825 ///
4826 /// This intrinsic has no corresponding instruction.
4827 ///
4828 /// \param __a
4829 ///    A 128-bit floating-point vector of [2 x double].
4830 /// \returns A 128-bit floating-point vector of [4 x float] containing the same
4831 ///    bitwise pattern as the parameter.
4832 static __inline__ __m128 __DEFAULT_FN_ATTRS
4833 _mm_castpd_ps(__m128d __a)
4834 {
4835   return (__m128)__a;
4836 }
4837
4838 /// \brief Casts a 128-bit floating-point vector of [2 x double] into a 128-bit
4839 ///    integer vector.
4840 ///
4841 /// \headerfile <x86intrin.h>
4842 ///
4843 /// This intrinsic has no corresponding instruction.
4844 ///
4845 /// \param __a
4846 ///    A 128-bit floating-point vector of [2 x double].
4847 /// \returns A 128-bit integer vector containing the same bitwise pattern as the
4848 ///    parameter.
4849 static __inline__ __m128i __DEFAULT_FN_ATTRS
4850 _mm_castpd_si128(__m128d __a)
4851 {
4852   return (__m128i)__a;
4853 }
4854
4855 /// \brief Casts a 128-bit floating-point vector of [4 x float] into a 128-bit
4856 ///    floating-point vector of [2 x double].
4857 ///
4858 /// \headerfile <x86intrin.h>
4859 ///
4860 /// This intrinsic has no corresponding instruction.
4861 ///
4862 /// \param __a
4863 ///    A 128-bit floating-point vector of [4 x float].
4864 /// \returns A 128-bit floating-point vector of [2 x double] containing the same
4865 ///    bitwise pattern as the parameter.
4866 static __inline__ __m128d __DEFAULT_FN_ATTRS
4867 _mm_castps_pd(__m128 __a)
4868 {
4869   return (__m128d)__a;
4870 }
4871
4872 /// \brief Casts a 128-bit floating-point vector of [4 x float] into a 128-bit
4873 ///    integer vector.
4874 ///
4875 /// \headerfile <x86intrin.h>
4876 ///
4877 /// This intrinsic has no corresponding instruction.
4878 ///
4879 /// \param __a
4880 ///    A 128-bit floating-point vector of [4 x float].
4881 /// \returns A 128-bit integer vector containing the same bitwise pattern as the
4882 ///    parameter.
4883 static __inline__ __m128i __DEFAULT_FN_ATTRS
4884 _mm_castps_si128(__m128 __a)
4885 {
4886   return (__m128i)__a;
4887 }
4888
4889 /// \brief Casts a 128-bit integer vector into a 128-bit floating-point vector
4890 ///    of [4 x float].
4891 ///
4892 /// \headerfile <x86intrin.h>
4893 ///
4894 /// This intrinsic has no corresponding instruction.
4895 ///
4896 /// \param __a
4897 ///    A 128-bit integer vector.
4898 /// \returns A 128-bit floating-point vector of [4 x float] containing the same
4899 ///    bitwise pattern as the parameter.
4900 static __inline__ __m128 __DEFAULT_FN_ATTRS
4901 _mm_castsi128_ps(__m128i __a)
4902 {
4903   return (__m128)__a;
4904 }
4905
4906 /// \brief Casts a 128-bit integer vector into a 128-bit floating-point vector
4907 ///    of [2 x double].
4908 ///
4909 /// \headerfile <x86intrin.h>
4910 ///
4911 /// This intrinsic has no corresponding instruction.
4912 ///
4913 /// \param __a
4914 ///    A 128-bit integer vector.
4915 /// \returns A 128-bit floating-point vector of [2 x double] containing the same
4916 ///    bitwise pattern as the parameter.
4917 static __inline__ __m128d __DEFAULT_FN_ATTRS
4918 _mm_castsi128_pd(__m128i __a)
4919 {
4920   return (__m128d)__a;
4921 }
4922
4923 #if defined(__cplusplus)
4924 extern "C" {
4925 #endif
4926
4927 /// \brief Indicates that a spin loop is being executed for the purposes of
4928 ///    optimizing power consumption during the loop.
4929 ///
4930 /// \headerfile <x86intrin.h>
4931 ///
4932 /// This intrinsic corresponds to the <c> PAUSE </c> instruction.
4933 ///
4934 void _mm_pause(void);
4935
4936 #if defined(__cplusplus)
4937 } // extern "C"
4938 #endif
4939 #undef __DEFAULT_FN_ATTRS
4940
4941 #define _MM_SHUFFLE2(x, y) (((x) << 1) | (y))
4942
4943 #define _MM_DENORMALS_ZERO_ON   (0x0040)
4944 #define _MM_DENORMALS_ZERO_OFF  (0x0000)
4945
4946 #define _MM_DENORMALS_ZERO_MASK (0x0040)
4947
4948 #define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
4949 #define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x)))
4950
4951 #endif /* __EMMINTRIN_H */