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