xref: /aosp_15_r20/prebuilts/clang-tools/linux-x86/lib64/clang/19/include/avxintrin.h (revision bed243d3d9cd544cfb038bfa7be843dedc6e6bf7)
1 /*===---- avxintrin.h - AVX intrinsics -------------------------------------===
2  *
3  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4  * See https://llvm.org/LICENSE.txt for license information.
5  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6  *
7  *===-----------------------------------------------------------------------===
8  */
9 
10 #ifndef __IMMINTRIN_H
11 #error "Never use <avxintrin.h> directly; include <immintrin.h> instead."
12 #endif
13 
14 #ifndef __AVXINTRIN_H
15 #define __AVXINTRIN_H
16 
17 typedef double __v4df __attribute__ ((__vector_size__ (32)));
18 typedef float __v8sf __attribute__ ((__vector_size__ (32)));
19 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
20 typedef int __v8si __attribute__ ((__vector_size__ (32)));
21 typedef short __v16hi __attribute__ ((__vector_size__ (32)));
22 typedef char __v32qi __attribute__ ((__vector_size__ (32)));
23 
24 /* Unsigned types */
25 typedef unsigned long long __v4du __attribute__ ((__vector_size__ (32)));
26 typedef unsigned int __v8su __attribute__ ((__vector_size__ (32)));
27 typedef unsigned short __v16hu __attribute__ ((__vector_size__ (32)));
28 typedef unsigned char __v32qu __attribute__ ((__vector_size__ (32)));
29 
30 /* We need an explicitly signed variant for char. Note that this shouldn't
31  * appear in the interface though. */
32 typedef signed char __v32qs __attribute__((__vector_size__(32)));
33 
34 typedef float __m256 __attribute__ ((__vector_size__ (32), __aligned__(32)));
35 typedef double __m256d __attribute__((__vector_size__(32), __aligned__(32)));
36 typedef long long __m256i __attribute__((__vector_size__(32), __aligned__(32)));
37 
38 typedef float __m256_u __attribute__ ((__vector_size__ (32), __aligned__(1)));
39 typedef double __m256d_u __attribute__((__vector_size__(32), __aligned__(1)));
40 typedef long long __m256i_u __attribute__((__vector_size__(32), __aligned__(1)));
41 
42 #ifdef __SSE2__
43 /* Both _Float16 and __bf16 require SSE2 being enabled. */
44 typedef _Float16 __v16hf __attribute__((__vector_size__(32), __aligned__(32)));
45 typedef _Float16 __m256h __attribute__((__vector_size__(32), __aligned__(32)));
46 typedef _Float16 __m256h_u __attribute__((__vector_size__(32), __aligned__(1)));
47 
48 typedef __bf16 __v16bf __attribute__((__vector_size__(32), __aligned__(32)));
49 typedef __bf16 __m256bh __attribute__((__vector_size__(32), __aligned__(32)));
50 #endif
51 
52 /* Define the default attributes for the functions in this file. */
53 #define __DEFAULT_FN_ATTRS                                                     \
54   __attribute__((__always_inline__, __nodebug__, __target__("avx,no-evex512"), \
55                  __min_vector_width__(256)))
56 #define __DEFAULT_FN_ATTRS128                                                  \
57   __attribute__((__always_inline__, __nodebug__, __target__("avx,no-evex512"), \
58                  __min_vector_width__(128)))
59 
60 /* Arithmetic */
61 /// Adds two 256-bit vectors of [4 x double].
62 ///
63 /// \headerfile <x86intrin.h>
64 ///
65 /// This intrinsic corresponds to the <c> VADDPD </c> instruction.
66 ///
67 /// \param __a
68 ///    A 256-bit vector of [4 x double] containing one of the source operands.
69 /// \param __b
70 ///    A 256-bit vector of [4 x double] containing one of the source operands.
71 /// \returns A 256-bit vector of [4 x double] containing the sums of both
72 ///    operands.
73 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_add_pd(__m256d __a,__m256d __b)74 _mm256_add_pd(__m256d __a, __m256d __b)
75 {
76   return (__m256d)((__v4df)__a+(__v4df)__b);
77 }
78 
79 /// Adds two 256-bit vectors of [8 x float].
80 ///
81 /// \headerfile <x86intrin.h>
82 ///
83 /// This intrinsic corresponds to the <c> VADDPS </c> instruction.
84 ///
85 /// \param __a
86 ///    A 256-bit vector of [8 x float] containing one of the source operands.
87 /// \param __b
88 ///    A 256-bit vector of [8 x float] containing one of the source operands.
89 /// \returns A 256-bit vector of [8 x float] containing the sums of both
90 ///    operands.
91 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_add_ps(__m256 __a,__m256 __b)92 _mm256_add_ps(__m256 __a, __m256 __b)
93 {
94   return (__m256)((__v8sf)__a+(__v8sf)__b);
95 }
96 
97 /// Subtracts two 256-bit vectors of [4 x double].
98 ///
99 /// \headerfile <x86intrin.h>
100 ///
101 /// This intrinsic corresponds to the <c> VSUBPD </c> instruction.
102 ///
103 /// \param __a
104 ///    A 256-bit vector of [4 x double] containing the minuend.
105 /// \param __b
106 ///    A 256-bit vector of [4 x double] containing the subtrahend.
107 /// \returns A 256-bit vector of [4 x double] containing the differences between
108 ///    both operands.
109 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_sub_pd(__m256d __a,__m256d __b)110 _mm256_sub_pd(__m256d __a, __m256d __b)
111 {
112   return (__m256d)((__v4df)__a-(__v4df)__b);
113 }
114 
115 /// Subtracts two 256-bit vectors of [8 x float].
116 ///
117 /// \headerfile <x86intrin.h>
118 ///
119 /// This intrinsic corresponds to the <c> VSUBPS </c> instruction.
120 ///
121 /// \param __a
122 ///    A 256-bit vector of [8 x float] containing the minuend.
123 /// \param __b
124 ///    A 256-bit vector of [8 x float] containing the subtrahend.
125 /// \returns A 256-bit vector of [8 x float] containing the differences between
126 ///    both operands.
127 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_sub_ps(__m256 __a,__m256 __b)128 _mm256_sub_ps(__m256 __a, __m256 __b)
129 {
130   return (__m256)((__v8sf)__a-(__v8sf)__b);
131 }
132 
133 /// Adds the even-indexed values and subtracts the odd-indexed values of
134 ///    two 256-bit vectors of [4 x double].
135 ///
136 /// \headerfile <x86intrin.h>
137 ///
138 /// This intrinsic corresponds to the <c> VADDSUBPD </c> instruction.
139 ///
140 /// \param __a
141 ///    A 256-bit vector of [4 x double] containing the left source operand.
142 /// \param __b
143 ///    A 256-bit vector of [4 x double] containing the right source operand.
144 /// \returns A 256-bit vector of [4 x double] containing the alternating sums
145 ///    and differences between both operands.
146 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_addsub_pd(__m256d __a,__m256d __b)147 _mm256_addsub_pd(__m256d __a, __m256d __b)
148 {
149   return (__m256d)__builtin_ia32_addsubpd256((__v4df)__a, (__v4df)__b);
150 }
151 
152 /// Adds the even-indexed values and subtracts the odd-indexed values of
153 ///    two 256-bit vectors of [8 x float].
154 ///
155 /// \headerfile <x86intrin.h>
156 ///
157 /// This intrinsic corresponds to the <c> VADDSUBPS </c> instruction.
158 ///
159 /// \param __a
160 ///    A 256-bit vector of [8 x float] containing the left source operand.
161 /// \param __b
162 ///    A 256-bit vector of [8 x float] containing the right source operand.
163 /// \returns A 256-bit vector of [8 x float] containing the alternating sums and
164 ///    differences between both operands.
165 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_addsub_ps(__m256 __a,__m256 __b)166 _mm256_addsub_ps(__m256 __a, __m256 __b)
167 {
168   return (__m256)__builtin_ia32_addsubps256((__v8sf)__a, (__v8sf)__b);
169 }
170 
171 /// Divides two 256-bit vectors of [4 x double].
172 ///
173 /// \headerfile <x86intrin.h>
174 ///
175 /// This intrinsic corresponds to the <c> VDIVPD </c> instruction.
176 ///
177 /// \param __a
178 ///    A 256-bit vector of [4 x double] containing the dividend.
179 /// \param __b
180 ///    A 256-bit vector of [4 x double] containing the divisor.
181 /// \returns A 256-bit vector of [4 x double] containing the quotients of both
182 ///    operands.
183 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_div_pd(__m256d __a,__m256d __b)184 _mm256_div_pd(__m256d __a, __m256d __b)
185 {
186   return (__m256d)((__v4df)__a/(__v4df)__b);
187 }
188 
189 /// Divides two 256-bit vectors of [8 x float].
190 ///
191 /// \headerfile <x86intrin.h>
192 ///
193 /// This intrinsic corresponds to the <c> VDIVPS </c> instruction.
194 ///
195 /// \param __a
196 ///    A 256-bit vector of [8 x float] containing the dividend.
197 /// \param __b
198 ///    A 256-bit vector of [8 x float] containing the divisor.
199 /// \returns A 256-bit vector of [8 x float] containing the quotients of both
200 ///    operands.
201 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_div_ps(__m256 __a,__m256 __b)202 _mm256_div_ps(__m256 __a, __m256 __b)
203 {
204   return (__m256)((__v8sf)__a/(__v8sf)__b);
205 }
206 
207 /// Compares two 256-bit vectors of [4 x double] and returns the greater
208 ///    of each pair of values.
209 ///
210 /// \headerfile <x86intrin.h>
211 ///
212 /// This intrinsic corresponds to the <c> VMAXPD </c> instruction.
213 ///
214 /// \param __a
215 ///    A 256-bit vector of [4 x double] containing one of the operands.
216 /// \param __b
217 ///    A 256-bit vector of [4 x double] containing one of the operands.
218 /// \returns A 256-bit vector of [4 x double] containing the maximum values
219 ///    between both operands.
220 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_max_pd(__m256d __a,__m256d __b)221 _mm256_max_pd(__m256d __a, __m256d __b)
222 {
223   return (__m256d)__builtin_ia32_maxpd256((__v4df)__a, (__v4df)__b);
224 }
225 
226 /// Compares two 256-bit vectors of [8 x float] and returns the greater
227 ///    of each pair of values.
228 ///
229 /// \headerfile <x86intrin.h>
230 ///
231 /// This intrinsic corresponds to the <c> VMAXPS </c> instruction.
232 ///
233 /// \param __a
234 ///    A 256-bit vector of [8 x float] containing one of the operands.
235 /// \param __b
236 ///    A 256-bit vector of [8 x float] containing one of the operands.
237 /// \returns A 256-bit vector of [8 x float] containing the maximum values
238 ///    between both operands.
239 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_max_ps(__m256 __a,__m256 __b)240 _mm256_max_ps(__m256 __a, __m256 __b)
241 {
242   return (__m256)__builtin_ia32_maxps256((__v8sf)__a, (__v8sf)__b);
243 }
244 
245 /// Compares two 256-bit vectors of [4 x double] and returns the lesser
246 ///    of each pair of values.
247 ///
248 /// \headerfile <x86intrin.h>
249 ///
250 /// This intrinsic corresponds to the <c> VMINPD </c> instruction.
251 ///
252 /// \param __a
253 ///    A 256-bit vector of [4 x double] containing one of the operands.
254 /// \param __b
255 ///    A 256-bit vector of [4 x double] containing one of the operands.
256 /// \returns A 256-bit vector of [4 x double] containing the minimum values
257 ///    between both operands.
258 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_min_pd(__m256d __a,__m256d __b)259 _mm256_min_pd(__m256d __a, __m256d __b)
260 {
261   return (__m256d)__builtin_ia32_minpd256((__v4df)__a, (__v4df)__b);
262 }
263 
264 /// Compares two 256-bit vectors of [8 x float] and returns the lesser
265 ///    of each pair of values.
266 ///
267 /// \headerfile <x86intrin.h>
268 ///
269 /// This intrinsic corresponds to the <c> VMINPS </c> instruction.
270 ///
271 /// \param __a
272 ///    A 256-bit vector of [8 x float] containing one of the operands.
273 /// \param __b
274 ///    A 256-bit vector of [8 x float] containing one of the operands.
275 /// \returns A 256-bit vector of [8 x float] containing the minimum values
276 ///    between both operands.
277 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_min_ps(__m256 __a,__m256 __b)278 _mm256_min_ps(__m256 __a, __m256 __b)
279 {
280   return (__m256)__builtin_ia32_minps256((__v8sf)__a, (__v8sf)__b);
281 }
282 
283 /// Multiplies two 256-bit vectors of [4 x double].
284 ///
285 /// \headerfile <x86intrin.h>
286 ///
287 /// This intrinsic corresponds to the <c> VMULPD </c> instruction.
288 ///
289 /// \param __a
290 ///    A 256-bit vector of [4 x double] containing one of the operands.
291 /// \param __b
292 ///    A 256-bit vector of [4 x double] containing one of the operands.
293 /// \returns A 256-bit vector of [4 x double] containing the products of both
294 ///    operands.
295 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_mul_pd(__m256d __a,__m256d __b)296 _mm256_mul_pd(__m256d __a, __m256d __b)
297 {
298   return (__m256d)((__v4df)__a * (__v4df)__b);
299 }
300 
301 /// Multiplies two 256-bit vectors of [8 x float].
302 ///
303 /// \headerfile <x86intrin.h>
304 ///
305 /// This intrinsic corresponds to the <c> VMULPS </c> instruction.
306 ///
307 /// \param __a
308 ///    A 256-bit vector of [8 x float] containing one of the operands.
309 /// \param __b
310 ///    A 256-bit vector of [8 x float] containing one of the operands.
311 /// \returns A 256-bit vector of [8 x float] containing the products of both
312 ///    operands.
313 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_mul_ps(__m256 __a,__m256 __b)314 _mm256_mul_ps(__m256 __a, __m256 __b)
315 {
316   return (__m256)((__v8sf)__a * (__v8sf)__b);
317 }
318 
319 /// Calculates the square roots of the values in a 256-bit vector of
320 ///    [4 x double].
321 ///
322 /// \headerfile <x86intrin.h>
323 ///
324 /// This intrinsic corresponds to the <c> VSQRTPD </c> instruction.
325 ///
326 /// \param __a
327 ///    A 256-bit vector of [4 x double].
328 /// \returns A 256-bit vector of [4 x double] containing the square roots of the
329 ///    values in the operand.
330 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_sqrt_pd(__m256d __a)331 _mm256_sqrt_pd(__m256d __a)
332 {
333   return (__m256d)__builtin_ia32_sqrtpd256((__v4df)__a);
334 }
335 
336 /// Calculates the square roots of the values in a 256-bit vector of
337 ///    [8 x float].
338 ///
339 /// \headerfile <x86intrin.h>
340 ///
341 /// This intrinsic corresponds to the <c> VSQRTPS </c> instruction.
342 ///
343 /// \param __a
344 ///    A 256-bit vector of [8 x float].
345 /// \returns A 256-bit vector of [8 x float] containing the square roots of the
346 ///    values in the operand.
347 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_sqrt_ps(__m256 __a)348 _mm256_sqrt_ps(__m256 __a)
349 {
350   return (__m256)__builtin_ia32_sqrtps256((__v8sf)__a);
351 }
352 
353 /// Calculates the reciprocal square roots of the values in a 256-bit
354 ///    vector of [8 x float].
355 ///
356 /// \headerfile <x86intrin.h>
357 ///
358 /// This intrinsic corresponds to the <c> VRSQRTPS </c> instruction.
359 ///
360 /// \param __a
361 ///    A 256-bit vector of [8 x float].
362 /// \returns A 256-bit vector of [8 x float] containing the reciprocal square
363 ///    roots of the values in the operand.
364 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_rsqrt_ps(__m256 __a)365 _mm256_rsqrt_ps(__m256 __a)
366 {
367   return (__m256)__builtin_ia32_rsqrtps256((__v8sf)__a);
368 }
369 
370 /// Calculates the reciprocals of the values in a 256-bit vector of
371 ///    [8 x float].
372 ///
373 /// \headerfile <x86intrin.h>
374 ///
375 /// This intrinsic corresponds to the <c> VRCPPS </c> instruction.
376 ///
377 /// \param __a
378 ///    A 256-bit vector of [8 x float].
379 /// \returns A 256-bit vector of [8 x float] containing the reciprocals of the
380 ///    values in the operand.
381 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_rcp_ps(__m256 __a)382 _mm256_rcp_ps(__m256 __a)
383 {
384   return (__m256)__builtin_ia32_rcpps256((__v8sf)__a);
385 }
386 
387 /// Rounds the values in a 256-bit vector of [4 x double] as specified
388 ///    by the byte operand. The source values are rounded to integer values and
389 ///    returned as 64-bit double-precision floating-point values.
390 ///
391 /// \headerfile <x86intrin.h>
392 ///
393 /// \code
394 /// __m256d _mm256_round_pd(__m256d V, const int M);
395 /// \endcode
396 ///
397 /// This intrinsic corresponds to the <c> VROUNDPD </c> instruction.
398 ///
399 /// \param V
400 ///    A 256-bit vector of [4 x double].
401 /// \param M
402 ///    An integer value that specifies the rounding operation. \n
403 ///    Bits [7:4] are reserved. \n
404 ///    Bit [3] is a precision exception value: \n
405 ///      0: A normal PE exception is used. \n
406 ///      1: The PE field is not updated. \n
407 ///    Bit [2] is the rounding control source: \n
408 ///      0: Use bits [1:0] of \a M. \n
409 ///      1: Use the current MXCSR setting. \n
410 ///    Bits [1:0] contain the rounding control definition: \n
411 ///      00: Nearest. \n
412 ///      01: Downward (toward negative infinity). \n
413 ///      10: Upward (toward positive infinity). \n
414 ///      11: Truncated.
415 /// \returns A 256-bit vector of [4 x double] containing the rounded values.
416 #define _mm256_round_pd(V, M) \
417   ((__m256d)__builtin_ia32_roundpd256((__v4df)(__m256d)(V), (M)))
418 
419 /// Rounds the values stored in a 256-bit vector of [8 x float] as
420 ///    specified by the byte operand. The source values are rounded to integer
421 ///    values and returned as floating-point values.
422 ///
423 /// \headerfile <x86intrin.h>
424 ///
425 /// \code
426 /// __m256 _mm256_round_ps(__m256 V, const int M);
427 /// \endcode
428 ///
429 /// This intrinsic corresponds to the <c> VROUNDPS </c> instruction.
430 ///
431 /// \param V
432 ///    A 256-bit vector of [8 x float].
433 /// \param M
434 ///    An integer value that specifies the rounding operation. \n
435 ///    Bits [7:4] are reserved. \n
436 ///    Bit [3] is a precision exception value: \n
437 ///      0: A normal PE exception is used. \n
438 ///      1: The PE field is not updated. \n
439 ///    Bit [2] is the rounding control source: \n
440 ///      0: Use bits [1:0] of \a M. \n
441 ///      1: Use the current MXCSR setting. \n
442 ///    Bits [1:0] contain the rounding control definition: \n
443 ///      00: Nearest. \n
444 ///      01: Downward (toward negative infinity). \n
445 ///      10: Upward (toward positive infinity). \n
446 ///      11: Truncated.
447 /// \returns A 256-bit vector of [8 x float] containing the rounded values.
448 #define _mm256_round_ps(V, M) \
449   ((__m256)__builtin_ia32_roundps256((__v8sf)(__m256)(V), (M)))
450 
451 /// Rounds up the values stored in a 256-bit vector of [4 x double]. The
452 ///    source values are rounded up to integer values and returned as 64-bit
453 ///    double-precision floating-point values.
454 ///
455 /// \headerfile <x86intrin.h>
456 ///
457 /// \code
458 /// __m256d _mm256_ceil_pd(__m256d V);
459 /// \endcode
460 ///
461 /// This intrinsic corresponds to the <c> VROUNDPD </c> instruction.
462 ///
463 /// \param V
464 ///    A 256-bit vector of [4 x double].
465 /// \returns A 256-bit vector of [4 x double] containing the rounded up values.
466 #define _mm256_ceil_pd(V)  _mm256_round_pd((V), _MM_FROUND_CEIL)
467 
468 /// Rounds down the values stored in a 256-bit vector of [4 x double].
469 ///    The source values are rounded down to integer values and returned as
470 ///    64-bit double-precision floating-point values.
471 ///
472 /// \headerfile <x86intrin.h>
473 ///
474 /// \code
475 /// __m256d _mm256_floor_pd(__m256d V);
476 /// \endcode
477 ///
478 /// This intrinsic corresponds to the <c> VROUNDPD </c> instruction.
479 ///
480 /// \param V
481 ///    A 256-bit vector of [4 x double].
482 /// \returns A 256-bit vector of [4 x double] containing the rounded down
483 ///    values.
484 #define _mm256_floor_pd(V) _mm256_round_pd((V), _MM_FROUND_FLOOR)
485 
486 /// Rounds up the values stored in a 256-bit vector of [8 x float]. The
487 ///    source values are rounded up to integer values and returned as
488 ///    floating-point values.
489 ///
490 /// \headerfile <x86intrin.h>
491 ///
492 /// \code
493 /// __m256 _mm256_ceil_ps(__m256 V);
494 /// \endcode
495 ///
496 /// This intrinsic corresponds to the <c> VROUNDPS </c> instruction.
497 ///
498 /// \param V
499 ///    A 256-bit vector of [8 x float].
500 /// \returns A 256-bit vector of [8 x float] containing the rounded up values.
501 #define _mm256_ceil_ps(V)  _mm256_round_ps((V), _MM_FROUND_CEIL)
502 
503 /// Rounds down the values stored in a 256-bit vector of [8 x float]. The
504 ///    source values are rounded down to integer values and returned as
505 ///    floating-point values.
506 ///
507 /// \headerfile <x86intrin.h>
508 ///
509 /// \code
510 /// __m256 _mm256_floor_ps(__m256 V);
511 /// \endcode
512 ///
513 /// This intrinsic corresponds to the <c> VROUNDPS </c> instruction.
514 ///
515 /// \param V
516 ///    A 256-bit vector of [8 x float].
517 /// \returns A 256-bit vector of [8 x float] containing the rounded down values.
518 #define _mm256_floor_ps(V) _mm256_round_ps((V), _MM_FROUND_FLOOR)
519 
520 /* Logical */
521 /// Performs a bitwise AND of two 256-bit vectors of [4 x double].
522 ///
523 /// \headerfile <x86intrin.h>
524 ///
525 /// This intrinsic corresponds to the <c> VANDPD </c> instruction.
526 ///
527 /// \param __a
528 ///    A 256-bit vector of [4 x double] containing one of the source operands.
529 /// \param __b
530 ///    A 256-bit vector of [4 x double] containing one of the source operands.
531 /// \returns A 256-bit vector of [4 x double] containing the bitwise AND of the
532 ///    values between both operands.
533 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_and_pd(__m256d __a,__m256d __b)534 _mm256_and_pd(__m256d __a, __m256d __b)
535 {
536   return (__m256d)((__v4du)__a & (__v4du)__b);
537 }
538 
539 /// Performs a bitwise AND of two 256-bit vectors of [8 x float].
540 ///
541 /// \headerfile <x86intrin.h>
542 ///
543 /// This intrinsic corresponds to the <c> VANDPS </c> instruction.
544 ///
545 /// \param __a
546 ///    A 256-bit vector of [8 x float] containing one of the source operands.
547 /// \param __b
548 ///    A 256-bit vector of [8 x float] containing one of the source operands.
549 /// \returns A 256-bit vector of [8 x float] containing the bitwise AND of the
550 ///    values between both operands.
551 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_and_ps(__m256 __a,__m256 __b)552 _mm256_and_ps(__m256 __a, __m256 __b)
553 {
554   return (__m256)((__v8su)__a & (__v8su)__b);
555 }
556 
557 /// Performs a bitwise AND of two 256-bit vectors of [4 x double], using
558 ///    the one's complement of the values contained in the first source operand.
559 ///
560 /// \headerfile <x86intrin.h>
561 ///
562 /// This intrinsic corresponds to the <c> VANDNPD </c> instruction.
563 ///
564 /// \param __a
565 ///    A 256-bit vector of [4 x double] containing the left source operand. The
566 ///    one's complement of this value is used in the bitwise AND.
567 /// \param __b
568 ///    A 256-bit vector of [4 x double] containing the right source operand.
569 /// \returns A 256-bit vector of [4 x double] containing the bitwise AND of the
570 ///    values of the second operand and the one's complement of the first
571 ///    operand.
572 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_andnot_pd(__m256d __a,__m256d __b)573 _mm256_andnot_pd(__m256d __a, __m256d __b)
574 {
575   return (__m256d)(~(__v4du)__a & (__v4du)__b);
576 }
577 
578 /// Performs a bitwise AND of two 256-bit vectors of [8 x float], using
579 ///    the one's complement of the values contained in the first source operand.
580 ///
581 /// \headerfile <x86intrin.h>
582 ///
583 /// This intrinsic corresponds to the <c> VANDNPS </c> instruction.
584 ///
585 /// \param __a
586 ///    A 256-bit vector of [8 x float] containing the left source operand. The
587 ///    one's complement of this value is used in the bitwise AND.
588 /// \param __b
589 ///    A 256-bit vector of [8 x float] containing the right source operand.
590 /// \returns A 256-bit vector of [8 x float] containing the bitwise AND of the
591 ///    values of the second operand and the one's complement of the first
592 ///    operand.
593 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_andnot_ps(__m256 __a,__m256 __b)594 _mm256_andnot_ps(__m256 __a, __m256 __b)
595 {
596   return (__m256)(~(__v8su)__a & (__v8su)__b);
597 }
598 
599 /// Performs a bitwise OR of two 256-bit vectors of [4 x double].
600 ///
601 /// \headerfile <x86intrin.h>
602 ///
603 /// This intrinsic corresponds to the <c> VORPD </c> instruction.
604 ///
605 /// \param __a
606 ///    A 256-bit vector of [4 x double] containing one of the source operands.
607 /// \param __b
608 ///    A 256-bit vector of [4 x double] containing one of the source operands.
609 /// \returns A 256-bit vector of [4 x double] containing the bitwise OR of the
610 ///    values between both operands.
611 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_or_pd(__m256d __a,__m256d __b)612 _mm256_or_pd(__m256d __a, __m256d __b)
613 {
614   return (__m256d)((__v4du)__a | (__v4du)__b);
615 }
616 
617 /// Performs a bitwise OR of two 256-bit vectors of [8 x float].
618 ///
619 /// \headerfile <x86intrin.h>
620 ///
621 /// This intrinsic corresponds to the <c> VORPS </c> instruction.
622 ///
623 /// \param __a
624 ///    A 256-bit vector of [8 x float] containing one of the source operands.
625 /// \param __b
626 ///    A 256-bit vector of [8 x float] containing one of the source operands.
627 /// \returns A 256-bit vector of [8 x float] containing the bitwise OR of the
628 ///    values between both operands.
629 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_or_ps(__m256 __a,__m256 __b)630 _mm256_or_ps(__m256 __a, __m256 __b)
631 {
632   return (__m256)((__v8su)__a | (__v8su)__b);
633 }
634 
635 /// Performs a bitwise XOR of two 256-bit vectors of [4 x double].
636 ///
637 /// \headerfile <x86intrin.h>
638 ///
639 /// This intrinsic corresponds to the <c> VXORPD </c> instruction.
640 ///
641 /// \param __a
642 ///    A 256-bit vector of [4 x double] containing one of the source operands.
643 /// \param __b
644 ///    A 256-bit vector of [4 x double] containing one of the source operands.
645 /// \returns A 256-bit vector of [4 x double] containing the bitwise XOR of the
646 ///    values between both operands.
647 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_xor_pd(__m256d __a,__m256d __b)648 _mm256_xor_pd(__m256d __a, __m256d __b)
649 {
650   return (__m256d)((__v4du)__a ^ (__v4du)__b);
651 }
652 
653 /// Performs a bitwise XOR of two 256-bit vectors of [8 x float].
654 ///
655 /// \headerfile <x86intrin.h>
656 ///
657 /// This intrinsic corresponds to the <c> VXORPS </c> instruction.
658 ///
659 /// \param __a
660 ///    A 256-bit vector of [8 x float] containing one of the source operands.
661 /// \param __b
662 ///    A 256-bit vector of [8 x float] containing one of the source operands.
663 /// \returns A 256-bit vector of [8 x float] containing the bitwise XOR of the
664 ///    values between both operands.
665 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_xor_ps(__m256 __a,__m256 __b)666 _mm256_xor_ps(__m256 __a, __m256 __b)
667 {
668   return (__m256)((__v8su)__a ^ (__v8su)__b);
669 }
670 
671 /* Horizontal arithmetic */
672 /// Horizontally adds the adjacent pairs of values contained in two
673 ///    256-bit vectors of [4 x double].
674 ///
675 /// \headerfile <x86intrin.h>
676 ///
677 /// This intrinsic corresponds to the <c> VHADDPD </c> instruction.
678 ///
679 /// \param __a
680 ///    A 256-bit vector of [4 x double] containing one of the source operands.
681 ///    The horizontal sums of the values are returned in the even-indexed
682 ///    elements of a vector of [4 x double].
683 /// \param __b
684 ///    A 256-bit vector of [4 x double] containing one of the source operands.
685 ///    The horizontal sums of the values are returned in the odd-indexed
686 ///    elements of a vector of [4 x double].
687 /// \returns A 256-bit vector of [4 x double] containing the horizontal sums of
688 ///    both operands.
689 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_hadd_pd(__m256d __a,__m256d __b)690 _mm256_hadd_pd(__m256d __a, __m256d __b)
691 {
692   return (__m256d)__builtin_ia32_haddpd256((__v4df)__a, (__v4df)__b);
693 }
694 
695 /// Horizontally adds the adjacent pairs of values contained in two
696 ///    256-bit vectors of [8 x float].
697 ///
698 /// \headerfile <x86intrin.h>
699 ///
700 /// This intrinsic corresponds to the <c> VHADDPS </c> instruction.
701 ///
702 /// \param __a
703 ///    A 256-bit vector of [8 x float] containing one of the source operands.
704 ///    The horizontal sums of the values are returned in the elements with
705 ///    index 0, 1, 4, 5 of a vector of [8 x float].
706 /// \param __b
707 ///    A 256-bit vector of [8 x float] containing one of the source operands.
708 ///    The horizontal sums of the values are returned in the elements with
709 ///    index 2, 3, 6, 7 of a vector of [8 x float].
710 /// \returns A 256-bit vector of [8 x float] containing the horizontal sums of
711 ///    both operands.
712 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_hadd_ps(__m256 __a,__m256 __b)713 _mm256_hadd_ps(__m256 __a, __m256 __b)
714 {
715   return (__m256)__builtin_ia32_haddps256((__v8sf)__a, (__v8sf)__b);
716 }
717 
718 /// Horizontally subtracts the adjacent pairs of values contained in two
719 ///    256-bit vectors of [4 x double].
720 ///
721 /// \headerfile <x86intrin.h>
722 ///
723 /// This intrinsic corresponds to the <c> VHSUBPD </c> instruction.
724 ///
725 /// \param __a
726 ///    A 256-bit vector of [4 x double] containing one of the source operands.
727 ///    The horizontal differences between the values are returned in the
728 ///    even-indexed elements of a vector of [4 x double].
729 /// \param __b
730 ///    A 256-bit vector of [4 x double] containing one of the source operands.
731 ///    The horizontal differences between the values are returned in the
732 ///    odd-indexed elements of a vector of [4 x double].
733 /// \returns A 256-bit vector of [4 x double] containing the horizontal
734 ///    differences of both operands.
735 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_hsub_pd(__m256d __a,__m256d __b)736 _mm256_hsub_pd(__m256d __a, __m256d __b)
737 {
738   return (__m256d)__builtin_ia32_hsubpd256((__v4df)__a, (__v4df)__b);
739 }
740 
741 /// Horizontally subtracts the adjacent pairs of values contained in two
742 ///    256-bit vectors of [8 x float].
743 ///
744 /// \headerfile <x86intrin.h>
745 ///
746 /// This intrinsic corresponds to the <c> VHSUBPS </c> instruction.
747 ///
748 /// \param __a
749 ///    A 256-bit vector of [8 x float] containing one of the source operands.
750 ///    The horizontal differences between the values are returned in the
751 ///    elements with index 0, 1, 4, 5 of a vector of [8 x float].
752 /// \param __b
753 ///    A 256-bit vector of [8 x float] containing one of the source operands.
754 ///    The horizontal differences between the values are returned in the
755 ///    elements with index 2, 3, 6, 7 of a vector of [8 x float].
756 /// \returns A 256-bit vector of [8 x float] containing the horizontal
757 ///    differences of both operands.
758 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_hsub_ps(__m256 __a,__m256 __b)759 _mm256_hsub_ps(__m256 __a, __m256 __b)
760 {
761   return (__m256)__builtin_ia32_hsubps256((__v8sf)__a, (__v8sf)__b);
762 }
763 
764 /* Vector permutations */
765 /// Copies the values in a 128-bit vector of [2 x double] as specified
766 ///    by the 128-bit integer vector operand.
767 ///
768 /// \headerfile <x86intrin.h>
769 ///
770 /// This intrinsic corresponds to the <c> VPERMILPD </c> instruction.
771 ///
772 /// \param __a
773 ///    A 128-bit vector of [2 x double].
774 /// \param __c
775 ///    A 128-bit integer vector operand specifying how the values are to be
776 ///    copied. \n
777 ///    Bit [1]: \n
778 ///      0: Bits [63:0] of the source are copied to bits [63:0] of the returned
779 ///         vector. \n
780 ///      1: Bits [127:64] of the source are copied to bits [63:0] of the
781 ///         returned vector. \n
782 ///    Bit [65]: \n
783 ///      0: Bits [63:0] of the source are copied to bits [127:64] of the
784 ///         returned vector. \n
785 ///      1: Bits [127:64] of the source are copied to bits [127:64] of the
786 ///         returned vector.
787 /// \returns A 128-bit vector of [2 x double] containing the copied values.
788 static __inline __m128d __DEFAULT_FN_ATTRS128
_mm_permutevar_pd(__m128d __a,__m128i __c)789 _mm_permutevar_pd(__m128d __a, __m128i __c)
790 {
791   return (__m128d)__builtin_ia32_vpermilvarpd((__v2df)__a, (__v2di)__c);
792 }
793 
794 /// Copies the values in a 256-bit vector of [4 x double] as specified
795 ///    by the 256-bit integer vector operand.
796 ///
797 /// \headerfile <x86intrin.h>
798 ///
799 /// This intrinsic corresponds to the <c> VPERMILPD </c> instruction.
800 ///
801 /// \param __a
802 ///    A 256-bit vector of [4 x double].
803 /// \param __c
804 ///    A 256-bit integer vector operand specifying how the values are to be
805 ///    copied. \n
806 ///    Bit [1]: \n
807 ///      0: Bits [63:0] of the source are copied to bits [63:0] of the returned
808 ///         vector. \n
809 ///      1: Bits [127:64] of the source are copied to bits [63:0] of the
810 ///         returned vector. \n
811 ///    Bit [65]: \n
812 ///      0: Bits [63:0] of the source are copied to bits [127:64] of the
813 ///         returned vector. \n
814 ///      1: Bits [127:64] of the source are copied to bits [127:64] of the
815 ///         returned vector. \n
816 ///    Bit [129]: \n
817 ///      0: Bits [191:128] of the source are copied to bits [191:128] of the
818 ///         returned vector. \n
819 ///      1: Bits [255:192] of the source are copied to bits [191:128] of the
820 ///         returned vector. \n
821 ///    Bit [193]: \n
822 ///      0: Bits [191:128] of the source are copied to bits [255:192] of the
823 ///         returned vector. \n
824 ///      1: Bits [255:192] of the source are copied to bits [255:192] of the
825 ///    returned vector.
826 /// \returns A 256-bit vector of [4 x double] containing the copied values.
827 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_permutevar_pd(__m256d __a,__m256i __c)828 _mm256_permutevar_pd(__m256d __a, __m256i __c)
829 {
830   return (__m256d)__builtin_ia32_vpermilvarpd256((__v4df)__a, (__v4di)__c);
831 }
832 
833 /// Copies the values stored in a 128-bit vector of [4 x float] as
834 ///    specified by the 128-bit integer vector operand.
835 /// \headerfile <x86intrin.h>
836 ///
837 /// This intrinsic corresponds to the <c> VPERMILPS </c> instruction.
838 ///
839 /// \param __a
840 ///    A 128-bit vector of [4 x float].
841 /// \param __c
842 ///    A 128-bit integer vector operand specifying how the values are to be
843 ///    copied. \n
844 ///    Bits [1:0]: \n
845 ///      00: Bits [31:0] of the source are copied to bits [31:0] of the
846 ///          returned vector. \n
847 ///      01: Bits [63:32] of the source are copied to bits [31:0] of the
848 ///          returned vector. \n
849 ///      10: Bits [95:64] of the source are copied to bits [31:0] of the
850 ///          returned vector. \n
851 ///      11: Bits [127:96] of the source are copied to bits [31:0] of the
852 ///          returned vector. \n
853 ///    Bits [33:32]: \n
854 ///      00: Bits [31:0] of the source are copied to bits [63:32] of the
855 ///          returned vector. \n
856 ///      01: Bits [63:32] of the source are copied to bits [63:32] of the
857 ///          returned vector. \n
858 ///      10: Bits [95:64] of the source are copied to bits [63:32] of the
859 ///          returned vector. \n
860 ///      11: Bits [127:96] of the source are copied to bits [63:32] of the
861 ///          returned vector. \n
862 ///    Bits [65:64]: \n
863 ///      00: Bits [31:0] of the source are copied to bits [95:64] of the
864 ///          returned vector. \n
865 ///      01: Bits [63:32] of the source are copied to bits [95:64] of the
866 ///          returned vector. \n
867 ///      10: Bits [95:64] of the source are copied to bits [95:64] of the
868 ///          returned vector. \n
869 ///      11: Bits [127:96] of the source are copied to bits [95:64] of the
870 ///          returned vector. \n
871 ///    Bits [97:96]: \n
872 ///      00: Bits [31:0] of the source are copied to bits [127:96] of the
873 ///          returned vector. \n
874 ///      01: Bits [63:32] of the source are copied to bits [127:96] of the
875 ///          returned vector. \n
876 ///      10: Bits [95:64] of the source are copied to bits [127:96] of the
877 ///          returned vector. \n
878 ///      11: Bits [127:96] of the source are copied to bits [127:96] of the
879 ///          returned vector.
880 /// \returns A 128-bit vector of [4 x float] containing the copied values.
881 static __inline __m128 __DEFAULT_FN_ATTRS128
_mm_permutevar_ps(__m128 __a,__m128i __c)882 _mm_permutevar_ps(__m128 __a, __m128i __c)
883 {
884   return (__m128)__builtin_ia32_vpermilvarps((__v4sf)__a, (__v4si)__c);
885 }
886 
887 /// Copies the values stored in a 256-bit vector of [8 x float] as
888 ///    specified by the 256-bit integer vector operand.
889 ///
890 /// \headerfile <x86intrin.h>
891 ///
892 /// This intrinsic corresponds to the <c> VPERMILPS </c> instruction.
893 ///
894 /// \param __a
895 ///    A 256-bit vector of [8 x float].
896 /// \param __c
897 ///    A 256-bit integer vector operand specifying how the values are to be
898 ///    copied. \n
899 ///    Bits [1:0]: \n
900 ///      00: Bits [31:0] of the source are copied to bits [31:0] of the
901 ///          returned vector. \n
902 ///      01: Bits [63:32] of the source are copied to bits [31:0] of the
903 ///          returned vector. \n
904 ///      10: Bits [95:64] of the source are copied to bits [31:0] of the
905 ///          returned vector. \n
906 ///      11: Bits [127:96] of the source are copied to bits [31:0] of the
907 ///          returned vector. \n
908 ///    Bits [33:32]: \n
909 ///      00: Bits [31:0] of the source are copied to bits [63:32] of the
910 ///          returned vector. \n
911 ///      01: Bits [63:32] of the source are copied to bits [63:32] of the
912 ///          returned vector. \n
913 ///      10: Bits [95:64] of the source are copied to bits [63:32] of the
914 ///          returned vector. \n
915 ///      11: Bits [127:96] of the source are copied to bits [63:32] of the
916 ///          returned vector. \n
917 ///    Bits [65:64]: \n
918 ///      00: Bits [31:0] of the source are copied to bits [95:64] of the
919 ///          returned vector. \n
920 ///      01: Bits [63:32] of the source are copied to bits [95:64] of the
921 ///          returned vector. \n
922 ///      10: Bits [95:64] of the source are copied to bits [95:64] of the
923 ///          returned vector. \n
924 ///      11: Bits [127:96] of the source are copied to bits [95:64] of the
925 ///          returned vector. \n
926 ///    Bits [97:96]: \n
927 ///      00: Bits [31:0] of the source are copied to bits [127:96] of the
928 ///          returned vector. \n
929 ///      01: Bits [63:32] of the source are copied to bits [127:96] of the
930 ///          returned vector. \n
931 ///      10: Bits [95:64] of the source are copied to bits [127:96] of the
932 ///          returned vector. \n
933 ///      11: Bits [127:96] of the source are copied to bits [127:96] of the
934 ///          returned vector. \n
935 ///    Bits [129:128]: \n
936 ///      00: Bits [159:128] of the source are copied to bits [159:128] of the
937 ///          returned vector. \n
938 ///      01: Bits [191:160] of the source are copied to bits [159:128] of the
939 ///          returned vector. \n
940 ///      10: Bits [223:192] of the source are copied to bits [159:128] of the
941 ///          returned vector. \n
942 ///      11: Bits [255:224] of the source are copied to bits [159:128] of the
943 ///          returned vector. \n
944 ///    Bits [161:160]: \n
945 ///      00: Bits [159:128] of the source are copied to bits [191:160] of the
946 ///          returned vector. \n
947 ///      01: Bits [191:160] of the source are copied to bits [191:160] of the
948 ///          returned vector. \n
949 ///      10: Bits [223:192] of the source are copied to bits [191:160] of the
950 ///          returned vector. \n
951 ///      11: Bits [255:224] of the source are copied to bits [191:160] of the
952 ///          returned vector. \n
953 ///    Bits [193:192]: \n
954 ///      00: Bits [159:128] of the source are copied to bits [223:192] of the
955 ///          returned vector. \n
956 ///      01: Bits [191:160] of the source are copied to bits [223:192] of the
957 ///          returned vector. \n
958 ///      10: Bits [223:192] of the source are copied to bits [223:192] of the
959 ///          returned vector. \n
960 ///      11: Bits [255:224] of the source are copied to bits [223:192] of the
961 ///          returned vector. \n
962 ///    Bits [225:224]: \n
963 ///      00: Bits [159:128] of the source are copied to bits [255:224] of the
964 ///          returned vector. \n
965 ///      01: Bits [191:160] of the source are copied to bits [255:224] of the
966 ///          returned vector. \n
967 ///      10: Bits [223:192] of the source are copied to bits [255:224] of the
968 ///          returned vector. \n
969 ///      11: Bits [255:224] of the source are copied to bits [255:224] of the
970 ///          returned vector.
971 /// \returns A 256-bit vector of [8 x float] containing the copied values.
972 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_permutevar_ps(__m256 __a,__m256i __c)973 _mm256_permutevar_ps(__m256 __a, __m256i __c)
974 {
975   return (__m256)__builtin_ia32_vpermilvarps256((__v8sf)__a, (__v8si)__c);
976 }
977 
978 /// Copies the values in a 128-bit vector of [2 x double] as specified
979 ///    by the immediate integer operand.
980 ///
981 /// \headerfile <x86intrin.h>
982 ///
983 /// \code
984 /// __m128d _mm_permute_pd(__m128d A, const int C);
985 /// \endcode
986 ///
987 /// This intrinsic corresponds to the <c> VPERMILPD </c> instruction.
988 ///
989 /// \param A
990 ///    A 128-bit vector of [2 x double].
991 /// \param C
992 ///    An immediate integer operand specifying how the values are to be
993 ///    copied. \n
994 ///    Bit [0]: \n
995 ///      0: Bits [63:0] of the source are copied to bits [63:0] of the returned
996 ///         vector. \n
997 ///      1: Bits [127:64] of the source are copied to bits [63:0] of the
998 ///         returned vector. \n
999 ///    Bit [1]: \n
1000 ///      0: Bits [63:0] of the source are copied to bits [127:64] of the
1001 ///         returned vector. \n
1002 ///      1: Bits [127:64] of the source are copied to bits [127:64] of the
1003 ///         returned vector.
1004 /// \returns A 128-bit vector of [2 x double] containing the copied values.
1005 #define _mm_permute_pd(A, C) \
1006   ((__m128d)__builtin_ia32_vpermilpd((__v2df)(__m128d)(A), (int)(C)))
1007 
1008 /// Copies the values in a 256-bit vector of [4 x double] as specified by
1009 ///    the immediate integer operand.
1010 ///
1011 /// \headerfile <x86intrin.h>
1012 ///
1013 /// \code
1014 /// __m256d _mm256_permute_pd(__m256d A, const int C);
1015 /// \endcode
1016 ///
1017 /// This intrinsic corresponds to the <c> VPERMILPD </c> instruction.
1018 ///
1019 /// \param A
1020 ///    A 256-bit vector of [4 x double].
1021 /// \param C
1022 ///    An immediate integer operand specifying how the values are to be
1023 ///    copied. \n
1024 ///    Bit [0]: \n
1025 ///      0: Bits [63:0] of the source are copied to bits [63:0] of the returned
1026 ///         vector. \n
1027 ///      1: Bits [127:64] of the source are copied to bits [63:0] of the
1028 ///         returned vector. \n
1029 ///    Bit [1]: \n
1030 ///      0: Bits [63:0] of the source are copied to bits [127:64] of the
1031 ///         returned vector. \n
1032 ///      1: Bits [127:64] of the source are copied to bits [127:64] of the
1033 ///         returned vector. \n
1034 ///    Bit [2]: \n
1035 ///      0: Bits [191:128] of the source are copied to bits [191:128] of the
1036 ///         returned vector. \n
1037 ///      1: Bits [255:192] of the source are copied to bits [191:128] of the
1038 ///         returned vector. \n
1039 ///    Bit [3]: \n
1040 ///      0: Bits [191:128] of the source are copied to bits [255:192] of the
1041 ///         returned vector. \n
1042 ///      1: Bits [255:192] of the source are copied to bits [255:192] of the
1043 ///         returned vector.
1044 /// \returns A 256-bit vector of [4 x double] containing the copied values.
1045 #define _mm256_permute_pd(A, C) \
1046   ((__m256d)__builtin_ia32_vpermilpd256((__v4df)(__m256d)(A), (int)(C)))
1047 
1048 /// Copies the values in a 128-bit vector of [4 x float] as specified by
1049 ///    the immediate integer operand.
1050 ///
1051 /// \headerfile <x86intrin.h>
1052 ///
1053 /// \code
1054 /// __m128 _mm_permute_ps(__m128 A, const int C);
1055 /// \endcode
1056 ///
1057 /// This intrinsic corresponds to the <c> VPERMILPS </c> instruction.
1058 ///
1059 /// \param A
1060 ///    A 128-bit vector of [4 x float].
1061 /// \param C
1062 ///    An immediate integer operand specifying how the values are to be
1063 ///    copied. \n
1064 ///    Bits [1:0]: \n
1065 ///      00: Bits [31:0] of the source are copied to bits [31:0] of the
1066 ///          returned vector. \n
1067 ///      01: Bits [63:32] of the source are copied to bits [31:0] of the
1068 ///          returned vector. \n
1069 ///      10: Bits [95:64] of the source are copied to bits [31:0] of the
1070 ///          returned vector. \n
1071 ///      11: Bits [127:96] of the source are copied to bits [31:0] of the
1072 ///          returned vector. \n
1073 ///    Bits [3:2]: \n
1074 ///      00: Bits [31:0] of the source are copied to bits [63:32] of the
1075 ///          returned vector. \n
1076 ///      01: Bits [63:32] of the source are copied to bits [63:32] of the
1077 ///          returned vector. \n
1078 ///      10: Bits [95:64] of the source are copied to bits [63:32] of the
1079 ///          returned vector. \n
1080 ///      11: Bits [127:96] of the source are copied to bits [63:32] of the
1081 ///          returned vector. \n
1082 ///    Bits [5:4]: \n
1083 ///      00: Bits [31:0] of the source are copied to bits [95:64] of the
1084 ///          returned vector. \n
1085 ///      01: Bits [63:32] of the source are copied to bits [95:64] of the
1086 ///          returned vector. \n
1087 ///      10: Bits [95:64] of the source are copied to bits [95:64] of the
1088 ///          returned vector. \n
1089 ///      11: Bits [127:96] of the source are copied to bits [95:64] of the
1090 ///          returned vector. \n
1091 ///    Bits [7:6]: \n
1092 ///      00: Bits [31:0] of the source are copied to bits [127:96] of the
1093 ///          returned vector. \n
1094 ///      01: Bits [63:32] of the source are copied to bits [127:96] of the
1095 ///          returned vector. \n
1096 ///      10: Bits [95:64] of the source are copied to bits [127:96] of the
1097 ///          returned vector. \n
1098 ///      11: Bits [127:96] of the source are copied to bits [127:96] of the
1099 ///          returned vector.
1100 /// \returns A 128-bit vector of [4 x float] containing the copied values.
1101 #define _mm_permute_ps(A, C) \
1102   ((__m128)__builtin_ia32_vpermilps((__v4sf)(__m128)(A), (int)(C)))
1103 
1104 /// Copies the values in a 256-bit vector of [8 x float] as specified by
1105 ///    the immediate integer operand.
1106 ///
1107 /// \headerfile <x86intrin.h>
1108 ///
1109 /// \code
1110 /// __m256 _mm256_permute_ps(__m256 A, const int C);
1111 /// \endcode
1112 ///
1113 /// This intrinsic corresponds to the <c> VPERMILPS </c> instruction.
1114 ///
1115 /// \param A
1116 ///    A 256-bit vector of [8 x float].
1117 /// \param C
1118 ///    An immediate integer operand specifying how the values are to be
1119 ///    copied. \n
1120 ///    Bits [1:0]: \n
1121 ///      00: Bits [31:0] of the source are copied to bits [31:0] of the
1122 ///          returned vector. \n
1123 ///      01: Bits [63:32] of the source are copied to bits [31:0] of the
1124 ///          returned vector. \n
1125 ///      10: Bits [95:64] of the source are copied to bits [31:0] of the
1126 ///          returned vector. \n
1127 ///      11: Bits [127:96] of the source are copied to bits [31:0] of the
1128 ///          returned vector. \n
1129 ///    Bits [3:2]: \n
1130 ///      00: Bits [31:0] of the source are copied to bits [63:32] of the
1131 ///          returned vector. \n
1132 ///      01: Bits [63:32] of the source are copied to bits [63:32] of the
1133 ///          returned vector. \n
1134 ///      10: Bits [95:64] of the source are copied to bits [63:32] of the
1135 ///          returned vector. \n
1136 ///      11: Bits [127:96] of the source are copied to bits [63:32] of the
1137 ///          returned vector. \n
1138 ///    Bits [5:4]: \n
1139 ///      00: Bits [31:0] of the source are copied to bits [95:64] of the
1140 ///          returned vector. \n
1141 ///      01: Bits [63:32] of the source are copied to bits [95:64] of the
1142 ///          returned vector. \n
1143 ///      10: Bits [95:64] of the source are copied to bits [95:64] of the
1144 ///          returned vector. \n
1145 ///      11: Bits [127:96] of the source are copied to bits [95:64] of the
1146 ///          returned vector. \n
1147 ///    Bits [7:6]: \n
1148 ///      00: Bits [31:0] of the source are copied to bits [127:96] of the
1149 ///          returned vector. \n
1150 ///      01: Bits [63:32] of the source are copied to bits [127:96] of the
1151 ///          returned vector. \n
1152 ///      10: Bits [95:64] of the source are copied to bits [127:96] of the
1153 ///          returned vector. \n
1154 ///      11: Bits [127:96] of the source are copied to bits [127:96] of the
1155 ///          returned vector. \n
1156 ///    Bits [1:0]: \n
1157 ///      00: Bits [159:128] of the source are copied to bits [159:128] of the
1158 ///          returned vector. \n
1159 ///      01: Bits [191:160] of the source are copied to bits [159:128] of the
1160 ///          returned vector. \n
1161 ///      10: Bits [223:192] of the source are copied to bits [159:128] of the
1162 ///          returned vector. \n
1163 ///      11: Bits [255:224] of the source are copied to bits [159:128] of the
1164 ///          returned vector. \n
1165 ///    Bits [3:2]: \n
1166 ///      00: Bits [159:128] of the source are copied to bits [191:160] of the
1167 ///          returned vector. \n
1168 ///      01: Bits [191:160] of the source are copied to bits [191:160] of the
1169 ///          returned vector. \n
1170 ///      10: Bits [223:192] of the source are copied to bits [191:160] of the
1171 ///          returned vector. \n
1172 ///      11: Bits [255:224] of the source are copied to bits [191:160] of the
1173 ///          returned vector. \n
1174 ///    Bits [5:4]: \n
1175 ///      00: Bits [159:128] of the source are copied to bits [223:192] of the
1176 ///          returned vector. \n
1177 ///      01: Bits [191:160] of the source are copied to bits [223:192] of the
1178 ///          returned vector. \n
1179 ///      10: Bits [223:192] of the source are copied to bits [223:192] of the
1180 ///          returned vector. \n
1181 ///      11: Bits [255:224] of the source are copied to bits [223:192] of the
1182 ///          returned vector. \n
1183 ///    Bits [7:6]: \n
1184 ///      00: Bits [159:128] of the source are copied to bits [255:224] of the
1185 ///          returned vector. \n
1186 ///      01: Bits [191:160] of the source are copied to bits [255:224] of the
1187 ///          returned vector. \n
1188 ///      10: Bits [223:192] of the source are copied to bits [255:224] of the
1189 ///          returned vector. \n
1190 ///      11: Bits [255:224] of the source are copied to bits [255:224] of the
1191 ///          returned vector.
1192 /// \returns A 256-bit vector of [8 x float] containing the copied values.
1193 #define _mm256_permute_ps(A, C) \
1194   ((__m256)__builtin_ia32_vpermilps256((__v8sf)(__m256)(A), (int)(C)))
1195 
1196 /// Permutes 128-bit data values stored in two 256-bit vectors of
1197 ///    [4 x double], as specified by the immediate integer operand.
1198 ///
1199 /// \headerfile <x86intrin.h>
1200 ///
1201 /// \code
1202 /// __m256d _mm256_permute2f128_pd(__m256d V1, __m256d V2, const int M);
1203 /// \endcode
1204 ///
1205 /// This intrinsic corresponds to the <c> VPERM2F128 </c> instruction.
1206 ///
1207 /// \param V1
1208 ///    A 256-bit vector of [4 x double].
1209 /// \param V2
1210 ///    A 256-bit vector of [4 x double.
1211 /// \param M
1212 ///    An immediate integer operand specifying how the values are to be
1213 ///    permuted. \n
1214 ///    Bits [1:0]: \n
1215 ///      00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the
1216 ///          destination. \n
1217 ///      01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the
1218 ///          destination. \n
1219 ///      10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the
1220 ///          destination. \n
1221 ///      11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the
1222 ///          destination. \n
1223 ///    Bits [5:4]: \n
1224 ///      00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the
1225 ///          destination. \n
1226 ///      01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the
1227 ///          destination. \n
1228 ///      10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the
1229 ///          destination. \n
1230 ///      11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the
1231 ///          destination.
1232 /// \returns A 256-bit vector of [4 x double] containing the copied values.
1233 #define _mm256_permute2f128_pd(V1, V2, M) \
1234   ((__m256d)__builtin_ia32_vperm2f128_pd256((__v4df)(__m256d)(V1), \
1235                                             (__v4df)(__m256d)(V2), (int)(M)))
1236 
1237 /// Permutes 128-bit data values stored in two 256-bit vectors of
1238 ///    [8 x float], as specified by the immediate integer operand.
1239 ///
1240 /// \headerfile <x86intrin.h>
1241 ///
1242 /// \code
1243 /// __m256 _mm256_permute2f128_ps(__m256 V1, __m256 V2, const int M);
1244 /// \endcode
1245 ///
1246 /// This intrinsic corresponds to the <c> VPERM2F128 </c> instruction.
1247 ///
1248 /// \param V1
1249 ///    A 256-bit vector of [8 x float].
1250 /// \param V2
1251 ///    A 256-bit vector of [8 x float].
1252 /// \param M
1253 ///    An immediate integer operand specifying how the values are to be
1254 ///    permuted. \n
1255 ///    Bits [1:0]: \n
1256 ///    00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the
1257 ///    destination. \n
1258 ///    01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the
1259 ///    destination. \n
1260 ///    10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the
1261 ///    destination. \n
1262 ///    11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the
1263 ///    destination. \n
1264 ///    Bits [5:4]: \n
1265 ///    00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the
1266 ///    destination. \n
1267 ///    01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the
1268 ///    destination. \n
1269 ///    10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the
1270 ///    destination. \n
1271 ///    11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the
1272 ///    destination.
1273 /// \returns A 256-bit vector of [8 x float] containing the copied values.
1274 #define _mm256_permute2f128_ps(V1, V2, M) \
1275   ((__m256)__builtin_ia32_vperm2f128_ps256((__v8sf)(__m256)(V1), \
1276                                            (__v8sf)(__m256)(V2), (int)(M)))
1277 
1278 /// Permutes 128-bit data values stored in two 256-bit integer vectors,
1279 ///    as specified by the immediate integer operand.
1280 ///
1281 /// \headerfile <x86intrin.h>
1282 ///
1283 /// \code
1284 /// __m256i _mm256_permute2f128_si256(__m256i V1, __m256i V2, const int M);
1285 /// \endcode
1286 ///
1287 /// This intrinsic corresponds to the <c> VPERM2F128 </c> instruction.
1288 ///
1289 /// \param V1
1290 ///    A 256-bit integer vector.
1291 /// \param V2
1292 ///    A 256-bit integer vector.
1293 /// \param M
1294 ///    An immediate integer operand specifying how the values are to be copied.
1295 ///    Bits [1:0]: \n
1296 ///    00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the
1297 ///    destination. \n
1298 ///    01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the
1299 ///    destination. \n
1300 ///    10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the
1301 ///    destination. \n
1302 ///    11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the
1303 ///    destination. \n
1304 ///    Bits [5:4]: \n
1305 ///    00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the
1306 ///    destination. \n
1307 ///    01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the
1308 ///    destination. \n
1309 ///    10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the
1310 ///    destination. \n
1311 ///    11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the
1312 ///    destination.
1313 /// \returns A 256-bit integer vector containing the copied values.
1314 #define _mm256_permute2f128_si256(V1, V2, M) \
1315   ((__m256i)__builtin_ia32_vperm2f128_si256((__v8si)(__m256i)(V1), \
1316                                             (__v8si)(__m256i)(V2), (int)(M)))
1317 
1318 /* Vector Blend */
1319 /// Merges 64-bit double-precision data values stored in either of the
1320 ///    two 256-bit vectors of [4 x double], as specified by the immediate
1321 ///    integer operand.
1322 ///
1323 /// \headerfile <x86intrin.h>
1324 ///
1325 /// \code
1326 /// __m256d _mm256_blend_pd(__m256d V1, __m256d V2, const int M);
1327 /// \endcode
1328 ///
1329 /// This intrinsic corresponds to the <c> VBLENDPD </c> instruction.
1330 ///
1331 /// \param V1
1332 ///    A 256-bit vector of [4 x double].
1333 /// \param V2
1334 ///    A 256-bit vector of [4 x double].
1335 /// \param M
1336 ///    An immediate integer operand, with mask bits [3:0] specifying how the
1337 ///    values are to be copied. The position of the mask bit corresponds to the
1338 ///    index of a copied value. When a mask bit is 0, the corresponding 64-bit
1339 ///    element in operand \a V1 is copied to the same position in the
1340 ///    destination. When a mask bit is 1, the corresponding 64-bit element in
1341 ///    operand \a V2 is copied to the same position in the destination.
1342 /// \returns A 256-bit vector of [4 x double] containing the copied values.
1343 #define _mm256_blend_pd(V1, V2, M) \
1344   ((__m256d)__builtin_ia32_blendpd256((__v4df)(__m256d)(V1), \
1345                                       (__v4df)(__m256d)(V2), (int)(M)))
1346 
1347 /// Merges 32-bit single-precision data values stored in either of the
1348 ///    two 256-bit vectors of [8 x float], as specified by the immediate
1349 ///    integer operand.
1350 ///
1351 /// \headerfile <x86intrin.h>
1352 ///
1353 /// \code
1354 /// __m256 _mm256_blend_ps(__m256 V1, __m256 V2, const int M);
1355 /// \endcode
1356 ///
1357 /// This intrinsic corresponds to the <c> VBLENDPS </c> instruction.
1358 ///
1359 /// \param V1
1360 ///    A 256-bit vector of [8 x float].
1361 /// \param V2
1362 ///    A 256-bit vector of [8 x float].
1363 /// \param M
1364 ///    An immediate integer operand, with mask bits [7:0] specifying how the
1365 ///    values are to be copied. The position of the mask bit corresponds to the
1366 ///    index of a copied value. When a mask bit is 0, the corresponding 32-bit
1367 ///    element in operand \a V1 is copied to the same position in the
1368 ///    destination. When a mask bit is 1, the corresponding 32-bit element in
1369 ///    operand \a V2 is copied to the same position in the destination.
1370 /// \returns A 256-bit vector of [8 x float] containing the copied values.
1371 #define _mm256_blend_ps(V1, V2, M) \
1372   ((__m256)__builtin_ia32_blendps256((__v8sf)(__m256)(V1), \
1373                                      (__v8sf)(__m256)(V2), (int)(M)))
1374 
1375 /// Merges 64-bit double-precision data values stored in either of the
1376 ///    two 256-bit vectors of [4 x double], as specified by the 256-bit vector
1377 ///    operand.
1378 ///
1379 /// \headerfile <x86intrin.h>
1380 ///
1381 /// This intrinsic corresponds to the <c> VBLENDVPD </c> instruction.
1382 ///
1383 /// \param __a
1384 ///    A 256-bit vector of [4 x double].
1385 /// \param __b
1386 ///    A 256-bit vector of [4 x double].
1387 /// \param __c
1388 ///    A 256-bit vector operand, with mask bits 255, 191, 127, and 63 specifying
1389 ///    how the values are to be copied. The position of the mask bit corresponds
1390 ///    to the most significant bit of a copied value. When a mask bit is 0, the
1391 ///    corresponding 64-bit element in operand \a __a is copied to the same
1392 ///    position in the destination. When a mask bit is 1, the corresponding
1393 ///    64-bit element in operand \a __b is copied to the same position in the
1394 ///    destination.
1395 /// \returns A 256-bit vector of [4 x double] containing the copied values.
1396 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_blendv_pd(__m256d __a,__m256d __b,__m256d __c)1397 _mm256_blendv_pd(__m256d __a, __m256d __b, __m256d __c)
1398 {
1399   return (__m256d)__builtin_ia32_blendvpd256(
1400     (__v4df)__a, (__v4df)__b, (__v4df)__c);
1401 }
1402 
1403 /// Merges 32-bit single-precision data values stored in either of the
1404 ///    two 256-bit vectors of [8 x float], as specified by the 256-bit vector
1405 ///    operand.
1406 ///
1407 /// \headerfile <x86intrin.h>
1408 ///
1409 /// This intrinsic corresponds to the <c> VBLENDVPS </c> instruction.
1410 ///
1411 /// \param __a
1412 ///    A 256-bit vector of [8 x float].
1413 /// \param __b
1414 ///    A 256-bit vector of [8 x float].
1415 /// \param __c
1416 ///    A 256-bit vector operand, with mask bits 255, 223, 191, 159, 127, 95, 63,
1417 ///    and 31 specifying how the values are to be copied. The position of the
1418 ///    mask bit corresponds to the most significant bit of a copied value. When
1419 ///    a mask bit is 0, the corresponding 32-bit element in operand \a __a is
1420 ///    copied to the same position in the destination. When a mask bit is 1, the
1421 ///    corresponding 32-bit element in operand \a __b is copied to the same
1422 ///    position in the destination.
1423 /// \returns A 256-bit vector of [8 x float] containing the copied values.
1424 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_blendv_ps(__m256 __a,__m256 __b,__m256 __c)1425 _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c)
1426 {
1427   return (__m256)__builtin_ia32_blendvps256(
1428     (__v8sf)__a, (__v8sf)__b, (__v8sf)__c);
1429 }
1430 
1431 /* Vector Dot Product */
1432 /// Computes two dot products in parallel, using the lower and upper
1433 ///    halves of two [8 x float] vectors as input to the two computations, and
1434 ///    returning the two dot products in the lower and upper halves of the
1435 ///    [8 x float] result.
1436 ///
1437 ///    The immediate integer operand controls which input elements will
1438 ///    contribute to the dot product, and where the final results are returned.
1439 ///    In general, for each dot product, the four corresponding elements of the
1440 ///    input vectors are multiplied; the first two and second two products are
1441 ///    summed, then the two sums are added to form the final result.
1442 ///
1443 /// \headerfile <x86intrin.h>
1444 ///
1445 /// \code
1446 /// __m256 _mm256_dp_ps(__m256 V1, __m256 V2, const int M);
1447 /// \endcode
1448 ///
1449 /// This intrinsic corresponds to the <c> VDPPS </c> instruction.
1450 ///
1451 /// \param V1
1452 ///    A vector of [8 x float] values, treated as two [4 x float] vectors.
1453 /// \param V2
1454 ///    A vector of [8 x float] values, treated as two [4 x float] vectors.
1455 /// \param M
1456 ///    An immediate integer argument. Bits [7:4] determine which elements of
1457 ///    the input vectors are used, with bit [4] corresponding to the lowest
1458 ///    element and bit [7] corresponding to the highest element of each [4 x
1459 ///    float] subvector. If a bit is set, the corresponding elements from the
1460 ///    two input vectors are used as an input for dot product; otherwise that
1461 ///    input is treated as zero. Bits [3:0] determine which elements of the
1462 ///    result will receive a copy of the final dot product, with bit [0]
1463 ///    corresponding to the lowest element and bit [3] corresponding to the
1464 ///    highest element of each [4 x float] subvector. If a bit is set, the dot
1465 ///    product is returned in the corresponding element; otherwise that element
1466 ///    is set to zero. The bitmask is applied in the same way to each of the
1467 ///    two parallel dot product computations.
1468 /// \returns A 256-bit vector of [8 x float] containing the two dot products.
1469 #define _mm256_dp_ps(V1, V2, M) \
1470   ((__m256)__builtin_ia32_dpps256((__v8sf)(__m256)(V1), \
1471                                   (__v8sf)(__m256)(V2), (M)))
1472 
1473 /* Vector shuffle */
1474 /// Selects 8 float values from the 256-bit operands of [8 x float], as
1475 ///    specified by the immediate value operand.
1476 ///
1477 ///    The four selected elements in each operand are copied to the destination
1478 ///    according to the bits specified in the immediate operand. The selected
1479 ///    elements from the first 256-bit operand are copied to bits [63:0] and
1480 ///    bits [191:128] of the destination, and the selected elements from the
1481 ///    second 256-bit operand are copied to bits [127:64] and bits [255:192] of
1482 ///    the destination. For example, if bits [7:0] of the immediate operand
1483 ///    contain a value of 0xFF, the 256-bit destination vector would contain the
1484 ///    following values: b[7], b[7], a[7], a[7], b[3], b[3], a[3], a[3].
1485 ///
1486 /// \headerfile <x86intrin.h>
1487 ///
1488 /// \code
1489 /// __m256 _mm256_shuffle_ps(__m256 a, __m256 b, const int mask);
1490 /// \endcode
1491 ///
1492 /// This intrinsic corresponds to the <c> VSHUFPS </c> instruction.
1493 ///
1494 /// \param a
1495 ///    A 256-bit vector of [8 x float]. The four selected elements in this
1496 ///    operand are copied to bits [63:0] and bits [191:128] in the destination,
1497 ///    according to the bits specified in the immediate operand.
1498 /// \param b
1499 ///    A 256-bit vector of [8 x float]. The four selected elements in this
1500 ///    operand are copied to bits [127:64] and bits [255:192] in the
1501 ///    destination, according to the bits specified in the immediate operand.
1502 /// \param mask
1503 ///    An immediate value containing an 8-bit value specifying which elements to
1504 ///    copy from \a a and \a b \n.
1505 ///    Bits [3:0] specify the values copied from operand \a a. \n
1506 ///    Bits [7:4] specify the values copied from operand \a b. \n
1507 ///    The destinations within the 256-bit destination are assigned values as
1508 ///    follows, according to the bit value assignments described below: \n
1509 ///    Bits [1:0] are used to assign values to bits [31:0] and [159:128] in the
1510 ///    destination. \n
1511 ///    Bits [3:2] are used to assign values to bits [63:32] and [191:160] in the
1512 ///    destination. \n
1513 ///    Bits [5:4] are used to assign values to bits [95:64] and [223:192] in the
1514 ///    destination. \n
1515 ///    Bits [7:6] are used to assign values to bits [127:96] and [255:224] in
1516 ///    the destination. \n
1517 ///    Bit value assignments: \n
1518 ///    00: Bits [31:0] and [159:128] are copied from the selected operand. \n
1519 ///    01: Bits [63:32] and [191:160] are copied from the selected operand. \n
1520 ///    10: Bits [95:64] and [223:192] are copied from the selected operand. \n
1521 ///    11: Bits [127:96] and [255:224] are copied from the selected operand. \n
1522 ///    Note: To generate a mask, you can use the \c _MM_SHUFFLE macro.
1523 ///    <c>_MM_SHUFFLE(b6, b4, b2, b0)</c> can create an 8-bit mask of the form
1524 ///    <c>[b6, b4, b2, b0]</c>.
1525 /// \returns A 256-bit vector of [8 x float] containing the shuffled values.
1526 #define _mm256_shuffle_ps(a, b, mask) \
1527   ((__m256)__builtin_ia32_shufps256((__v8sf)(__m256)(a), \
1528                                     (__v8sf)(__m256)(b), (int)(mask)))
1529 
1530 /// Selects four double-precision values from the 256-bit operands of
1531 ///    [4 x double], as specified by the immediate value operand.
1532 ///
1533 ///    The selected elements from the first 256-bit operand are copied to bits
1534 ///    [63:0] and bits [191:128] in the destination, and the selected elements
1535 ///    from the second 256-bit operand are copied to bits [127:64] and bits
1536 ///    [255:192] in the destination. For example, if bits [3:0] of the immediate
1537 ///    operand contain a value of 0xF, the 256-bit destination vector would
1538 ///    contain the following values: b[3], a[3], b[1], a[1].
1539 ///
1540 /// \headerfile <x86intrin.h>
1541 ///
1542 /// \code
1543 /// __m256d _mm256_shuffle_pd(__m256d a, __m256d b, const int mask);
1544 /// \endcode
1545 ///
1546 /// This intrinsic corresponds to the <c> VSHUFPD </c> instruction.
1547 ///
1548 /// \param a
1549 ///    A 256-bit vector of [4 x double].
1550 /// \param b
1551 ///    A 256-bit vector of [4 x double].
1552 /// \param mask
1553 ///    An immediate value containing 8-bit values specifying which elements to
1554 ///    copy from \a a and \a b: \n
1555 ///    Bit [0]=0: Bits [63:0] are copied from \a a to bits [63:0] of the
1556 ///    destination. \n
1557 ///    Bit [0]=1: Bits [127:64] are copied from \a a to bits [63:0] of the
1558 ///    destination. \n
1559 ///    Bit [1]=0: Bits [63:0] are copied from \a b to bits [127:64] of the
1560 ///    destination. \n
1561 ///    Bit [1]=1: Bits [127:64] are copied from \a b to bits [127:64] of the
1562 ///    destination. \n
1563 ///    Bit [2]=0: Bits [191:128] are copied from \a a to bits [191:128] of the
1564 ///    destination. \n
1565 ///    Bit [2]=1: Bits [255:192] are copied from \a a to bits [191:128] of the
1566 ///    destination. \n
1567 ///    Bit [3]=0: Bits [191:128] are copied from \a b to bits [255:192] of the
1568 ///    destination. \n
1569 ///    Bit [3]=1: Bits [255:192] are copied from \a b to bits [255:192] of the
1570 ///    destination.
1571 /// \returns A 256-bit vector of [4 x double] containing the shuffled values.
1572 #define _mm256_shuffle_pd(a, b, mask) \
1573   ((__m256d)__builtin_ia32_shufpd256((__v4df)(__m256d)(a), \
1574                                      (__v4df)(__m256d)(b), (int)(mask)))
1575 
1576 /* Compare */
1577 #define _CMP_EQ_UQ    0x08 /* Equal (unordered, non-signaling)  */
1578 #define _CMP_NGE_US   0x09 /* Not-greater-than-or-equal (unordered, signaling)  */
1579 #define _CMP_NGT_US   0x0a /* Not-greater-than (unordered, signaling)  */
1580 #define _CMP_FALSE_OQ 0x0b /* False (ordered, non-signaling)  */
1581 #define _CMP_NEQ_OQ   0x0c /* Not-equal (ordered, non-signaling)  */
1582 #define _CMP_GE_OS    0x0d /* Greater-than-or-equal (ordered, signaling)  */
1583 #define _CMP_GT_OS    0x0e /* Greater-than (ordered, signaling)  */
1584 #define _CMP_TRUE_UQ  0x0f /* True (unordered, non-signaling)  */
1585 #define _CMP_EQ_OS    0x10 /* Equal (ordered, signaling)  */
1586 #define _CMP_LT_OQ    0x11 /* Less-than (ordered, non-signaling)  */
1587 #define _CMP_LE_OQ    0x12 /* Less-than-or-equal (ordered, non-signaling)  */
1588 #define _CMP_UNORD_S  0x13 /* Unordered (signaling)  */
1589 #define _CMP_NEQ_US   0x14 /* Not-equal (unordered, signaling)  */
1590 #define _CMP_NLT_UQ   0x15 /* Not-less-than (unordered, non-signaling)  */
1591 #define _CMP_NLE_UQ   0x16 /* Not-less-than-or-equal (unordered, non-signaling)  */
1592 #define _CMP_ORD_S    0x17 /* Ordered (signaling)  */
1593 #define _CMP_EQ_US    0x18 /* Equal (unordered, signaling)  */
1594 #define _CMP_NGE_UQ   0x19 /* Not-greater-than-or-equal (unordered, non-signaling)  */
1595 #define _CMP_NGT_UQ   0x1a /* Not-greater-than (unordered, non-signaling)  */
1596 #define _CMP_FALSE_OS 0x1b /* False (ordered, signaling)  */
1597 #define _CMP_NEQ_OS   0x1c /* Not-equal (ordered, signaling)  */
1598 #define _CMP_GE_OQ    0x1d /* Greater-than-or-equal (ordered, non-signaling)  */
1599 #define _CMP_GT_OQ    0x1e /* Greater-than (ordered, non-signaling)  */
1600 #define _CMP_TRUE_US  0x1f /* True (unordered, signaling)  */
1601 
1602 /* Below intrinsic defined in emmintrin.h can be used for AVX */
1603 /// Compares each of the corresponding double-precision values of two
1604 ///    128-bit vectors of [2 x double], using the operation specified by the
1605 ///    immediate integer operand.
1606 ///
1607 ///    Returns a [2 x double] vector consisting of two doubles corresponding to
1608 ///    the two comparison results: zero if the comparison is false, and all 1's
1609 ///    if the comparison is true.
1610 ///
1611 /// \headerfile <x86intrin.h>
1612 ///
1613 /// \code
1614 /// __m128d _mm_cmp_pd(__m128d a, __m128d b, const int c);
1615 /// \endcode
1616 ///
1617 /// This intrinsic corresponds to the <c> VCMPPD </c> instruction.
1618 ///
1619 /// \param a
1620 ///    A 128-bit vector of [2 x double].
1621 /// \param b
1622 ///    A 128-bit vector of [2 x double].
1623 /// \param c
1624 ///    An immediate integer operand, with bits [4:0] specifying which comparison
1625 ///    operation to use: \n
1626 ///    0x00: Equal (ordered, non-signaling) \n
1627 ///    0x01: Less-than (ordered, signaling) \n
1628 ///    0x02: Less-than-or-equal (ordered, signaling) \n
1629 ///    0x03: Unordered (non-signaling) \n
1630 ///    0x04: Not-equal (unordered, non-signaling) \n
1631 ///    0x05: Not-less-than (unordered, signaling) \n
1632 ///    0x06: Not-less-than-or-equal (unordered, signaling) \n
1633 ///    0x07: Ordered (non-signaling) \n
1634 ///    0x08: Equal (unordered, non-signaling) \n
1635 ///    0x09: Not-greater-than-or-equal (unordered, signaling) \n
1636 ///    0x0A: Not-greater-than (unordered, signaling) \n
1637 ///    0x0B: False (ordered, non-signaling) \n
1638 ///    0x0C: Not-equal (ordered, non-signaling) \n
1639 ///    0x0D: Greater-than-or-equal (ordered, signaling) \n
1640 ///    0x0E: Greater-than (ordered, signaling) \n
1641 ///    0x0F: True (unordered, non-signaling) \n
1642 ///    0x10: Equal (ordered, signaling) \n
1643 ///    0x11: Less-than (ordered, non-signaling) \n
1644 ///    0x12: Less-than-or-equal (ordered, non-signaling) \n
1645 ///    0x13: Unordered (signaling) \n
1646 ///    0x14: Not-equal (unordered, signaling) \n
1647 ///    0x15: Not-less-than (unordered, non-signaling) \n
1648 ///    0x16: Not-less-than-or-equal (unordered, non-signaling) \n
1649 ///    0x17: Ordered (signaling) \n
1650 ///    0x18: Equal (unordered, signaling) \n
1651 ///    0x19: Not-greater-than-or-equal (unordered, non-signaling) \n
1652 ///    0x1A: Not-greater-than (unordered, non-signaling) \n
1653 ///    0x1B: False (ordered, signaling) \n
1654 ///    0x1C: Not-equal (ordered, signaling) \n
1655 ///    0x1D: Greater-than-or-equal (ordered, non-signaling) \n
1656 ///    0x1E: Greater-than (ordered, non-signaling) \n
1657 ///    0x1F: True (unordered, signaling)
1658 /// \returns A 128-bit vector of [2 x double] containing the comparison results.
1659 /// \fn __m128d _mm_cmp_pd(__m128d a, __m128d b, const int c)
1660 
1661 /* Below intrinsic defined in xmmintrin.h can be used for AVX */
1662 /// Compares each of the corresponding values of two 128-bit vectors of
1663 ///    [4 x float], using the operation specified by the immediate integer
1664 ///    operand.
1665 ///
1666 ///    Returns a [4 x float] vector consisting of four floats corresponding to
1667 ///    the four comparison results: zero if the comparison is false, and all 1's
1668 ///    if the comparison is true.
1669 ///
1670 /// \headerfile <x86intrin.h>
1671 ///
1672 /// \code
1673 /// __m128 _mm_cmp_ps(__m128 a, __m128 b, const int c);
1674 /// \endcode
1675 ///
1676 /// This intrinsic corresponds to the <c> VCMPPS </c> instruction.
1677 ///
1678 /// \param a
1679 ///    A 128-bit vector of [4 x float].
1680 /// \param b
1681 ///    A 128-bit vector of [4 x float].
1682 /// \param c
1683 ///    An immediate integer operand, with bits [4:0] specifying which comparison
1684 ///    operation to use: \n
1685 ///    0x00: Equal (ordered, non-signaling) \n
1686 ///    0x01: Less-than (ordered, signaling) \n
1687 ///    0x02: Less-than-or-equal (ordered, signaling) \n
1688 ///    0x03: Unordered (non-signaling) \n
1689 ///    0x04: Not-equal (unordered, non-signaling) \n
1690 ///    0x05: Not-less-than (unordered, signaling) \n
1691 ///    0x06: Not-less-than-or-equal (unordered, signaling) \n
1692 ///    0x07: Ordered (non-signaling) \n
1693 ///    0x08: Equal (unordered, non-signaling) \n
1694 ///    0x09: Not-greater-than-or-equal (unordered, signaling) \n
1695 ///    0x0A: Not-greater-than (unordered, signaling) \n
1696 ///    0x0B: False (ordered, non-signaling) \n
1697 ///    0x0C: Not-equal (ordered, non-signaling) \n
1698 ///    0x0D: Greater-than-or-equal (ordered, signaling) \n
1699 ///    0x0E: Greater-than (ordered, signaling) \n
1700 ///    0x0F: True (unordered, non-signaling) \n
1701 ///    0x10: Equal (ordered, signaling) \n
1702 ///    0x11: Less-than (ordered, non-signaling) \n
1703 ///    0x12: Less-than-or-equal (ordered, non-signaling) \n
1704 ///    0x13: Unordered (signaling) \n
1705 ///    0x14: Not-equal (unordered, signaling) \n
1706 ///    0x15: Not-less-than (unordered, non-signaling) \n
1707 ///    0x16: Not-less-than-or-equal (unordered, non-signaling) \n
1708 ///    0x17: Ordered (signaling) \n
1709 ///    0x18: Equal (unordered, signaling) \n
1710 ///    0x19: Not-greater-than-or-equal (unordered, non-signaling) \n
1711 ///    0x1A: Not-greater-than (unordered, non-signaling) \n
1712 ///    0x1B: False (ordered, signaling) \n
1713 ///    0x1C: Not-equal (ordered, signaling) \n
1714 ///    0x1D: Greater-than-or-equal (ordered, non-signaling) \n
1715 ///    0x1E: Greater-than (ordered, non-signaling) \n
1716 ///    0x1F: True (unordered, signaling)
1717 /// \returns A 128-bit vector of [4 x float] containing the comparison results.
1718 /// \fn __m128 _mm_cmp_ps(__m128 a, __m128 b, const int c)
1719 
1720 /// Compares each of the corresponding double-precision values of two
1721 ///    256-bit vectors of [4 x double], using the operation specified by the
1722 ///    immediate integer operand.
1723 ///
1724 ///    Returns a [4 x double] vector consisting of four doubles corresponding to
1725 ///    the four comparison results: zero if the comparison is false, and all 1's
1726 ///    if the comparison is true.
1727 ///
1728 /// \headerfile <x86intrin.h>
1729 ///
1730 /// \code
1731 /// __m256d _mm256_cmp_pd(__m256d a, __m256d b, const int c);
1732 /// \endcode
1733 ///
1734 /// This intrinsic corresponds to the <c> VCMPPD </c> instruction.
1735 ///
1736 /// \param a
1737 ///    A 256-bit vector of [4 x double].
1738 /// \param b
1739 ///    A 256-bit vector of [4 x double].
1740 /// \param c
1741 ///    An immediate integer operand, with bits [4:0] specifying which comparison
1742 ///    operation to use: \n
1743 ///    0x00: Equal (ordered, non-signaling) \n
1744 ///    0x01: Less-than (ordered, signaling) \n
1745 ///    0x02: Less-than-or-equal (ordered, signaling) \n
1746 ///    0x03: Unordered (non-signaling) \n
1747 ///    0x04: Not-equal (unordered, non-signaling) \n
1748 ///    0x05: Not-less-than (unordered, signaling) \n
1749 ///    0x06: Not-less-than-or-equal (unordered, signaling) \n
1750 ///    0x07: Ordered (non-signaling) \n
1751 ///    0x08: Equal (unordered, non-signaling) \n
1752 ///    0x09: Not-greater-than-or-equal (unordered, signaling) \n
1753 ///    0x0A: Not-greater-than (unordered, signaling) \n
1754 ///    0x0B: False (ordered, non-signaling) \n
1755 ///    0x0C: Not-equal (ordered, non-signaling) \n
1756 ///    0x0D: Greater-than-or-equal (ordered, signaling) \n
1757 ///    0x0E: Greater-than (ordered, signaling) \n
1758 ///    0x0F: True (unordered, non-signaling) \n
1759 ///    0x10: Equal (ordered, signaling) \n
1760 ///    0x11: Less-than (ordered, non-signaling) \n
1761 ///    0x12: Less-than-or-equal (ordered, non-signaling) \n
1762 ///    0x13: Unordered (signaling) \n
1763 ///    0x14: Not-equal (unordered, signaling) \n
1764 ///    0x15: Not-less-than (unordered, non-signaling) \n
1765 ///    0x16: Not-less-than-or-equal (unordered, non-signaling) \n
1766 ///    0x17: Ordered (signaling) \n
1767 ///    0x18: Equal (unordered, signaling) \n
1768 ///    0x19: Not-greater-than-or-equal (unordered, non-signaling) \n
1769 ///    0x1A: Not-greater-than (unordered, non-signaling) \n
1770 ///    0x1B: False (ordered, signaling) \n
1771 ///    0x1C: Not-equal (ordered, signaling) \n
1772 ///    0x1D: Greater-than-or-equal (ordered, non-signaling) \n
1773 ///    0x1E: Greater-than (ordered, non-signaling) \n
1774 ///    0x1F: True (unordered, signaling)
1775 /// \returns A 256-bit vector of [4 x double] containing the comparison results.
1776 #define _mm256_cmp_pd(a, b, c) \
1777   ((__m256d)__builtin_ia32_cmppd256((__v4df)(__m256d)(a), \
1778                                     (__v4df)(__m256d)(b), (c)))
1779 
1780 /// Compares each of the corresponding values of two 256-bit vectors of
1781 ///    [8 x float], using the operation specified by the immediate integer
1782 ///    operand.
1783 ///
1784 ///    Returns a [8 x float] vector consisting of eight floats corresponding to
1785 ///    the eight comparison results: zero if the comparison is false, and all
1786 ///    1's if the comparison is true.
1787 ///
1788 /// \headerfile <x86intrin.h>
1789 ///
1790 /// \code
1791 /// __m256 _mm256_cmp_ps(__m256 a, __m256 b, const int c);
1792 /// \endcode
1793 ///
1794 /// This intrinsic corresponds to the <c> VCMPPS </c> instruction.
1795 ///
1796 /// \param a
1797 ///    A 256-bit vector of [8 x float].
1798 /// \param b
1799 ///    A 256-bit vector of [8 x float].
1800 /// \param c
1801 ///    An immediate integer operand, with bits [4:0] specifying which comparison
1802 ///    operation to use: \n
1803 ///    0x00: Equal (ordered, non-signaling) \n
1804 ///    0x01: Less-than (ordered, signaling) \n
1805 ///    0x02: Less-than-or-equal (ordered, signaling) \n
1806 ///    0x03: Unordered (non-signaling) \n
1807 ///    0x04: Not-equal (unordered, non-signaling) \n
1808 ///    0x05: Not-less-than (unordered, signaling) \n
1809 ///    0x06: Not-less-than-or-equal (unordered, signaling) \n
1810 ///    0x07: Ordered (non-signaling) \n
1811 ///    0x08: Equal (unordered, non-signaling) \n
1812 ///    0x09: Not-greater-than-or-equal (unordered, signaling) \n
1813 ///    0x0A: Not-greater-than (unordered, signaling) \n
1814 ///    0x0B: False (ordered, non-signaling) \n
1815 ///    0x0C: Not-equal (ordered, non-signaling) \n
1816 ///    0x0D: Greater-than-or-equal (ordered, signaling) \n
1817 ///    0x0E: Greater-than (ordered, signaling) \n
1818 ///    0x0F: True (unordered, non-signaling) \n
1819 ///    0x10: Equal (ordered, signaling) \n
1820 ///    0x11: Less-than (ordered, non-signaling) \n
1821 ///    0x12: Less-than-or-equal (ordered, non-signaling) \n
1822 ///    0x13: Unordered (signaling) \n
1823 ///    0x14: Not-equal (unordered, signaling) \n
1824 ///    0x15: Not-less-than (unordered, non-signaling) \n
1825 ///    0x16: Not-less-than-or-equal (unordered, non-signaling) \n
1826 ///    0x17: Ordered (signaling) \n
1827 ///    0x18: Equal (unordered, signaling) \n
1828 ///    0x19: Not-greater-than-or-equal (unordered, non-signaling) \n
1829 ///    0x1A: Not-greater-than (unordered, non-signaling) \n
1830 ///    0x1B: False (ordered, signaling) \n
1831 ///    0x1C: Not-equal (ordered, signaling) \n
1832 ///    0x1D: Greater-than-or-equal (ordered, non-signaling) \n
1833 ///    0x1E: Greater-than (ordered, non-signaling) \n
1834 ///    0x1F: True (unordered, signaling)
1835 /// \returns A 256-bit vector of [8 x float] containing the comparison results.
1836 #define _mm256_cmp_ps(a, b, c) \
1837   ((__m256)__builtin_ia32_cmpps256((__v8sf)(__m256)(a), \
1838                                    (__v8sf)(__m256)(b), (c)))
1839 
1840 /* Below intrinsic defined in emmintrin.h can be used for AVX */
1841 /// Compares each of the corresponding scalar double-precision values of
1842 ///    two 128-bit vectors of [2 x double], using the operation specified by the
1843 ///    immediate integer operand.
1844 ///
1845 ///    If the result is true, all 64 bits of the destination vector are set;
1846 ///    otherwise they are cleared.
1847 ///
1848 /// \headerfile <x86intrin.h>
1849 ///
1850 /// \code
1851 /// __m128d _mm_cmp_sd(__m128d a, __m128d b, const int c);
1852 /// \endcode
1853 ///
1854 /// This intrinsic corresponds to the <c> VCMPSD </c> instruction.
1855 ///
1856 /// \param a
1857 ///    A 128-bit vector of [2 x double].
1858 /// \param b
1859 ///    A 128-bit vector of [2 x double].
1860 /// \param c
1861 ///    An immediate integer operand, with bits [4:0] specifying which comparison
1862 ///    operation to use: \n
1863 ///    0x00: Equal (ordered, non-signaling) \n
1864 ///    0x01: Less-than (ordered, signaling) \n
1865 ///    0x02: Less-than-or-equal (ordered, signaling) \n
1866 ///    0x03: Unordered (non-signaling) \n
1867 ///    0x04: Not-equal (unordered, non-signaling) \n
1868 ///    0x05: Not-less-than (unordered, signaling) \n
1869 ///    0x06: Not-less-than-or-equal (unordered, signaling) \n
1870 ///    0x07: Ordered (non-signaling) \n
1871 ///    0x08: Equal (unordered, non-signaling) \n
1872 ///    0x09: Not-greater-than-or-equal (unordered, signaling) \n
1873 ///    0x0A: Not-greater-than (unordered, signaling) \n
1874 ///    0x0B: False (ordered, non-signaling) \n
1875 ///    0x0C: Not-equal (ordered, non-signaling) \n
1876 ///    0x0D: Greater-than-or-equal (ordered, signaling) \n
1877 ///    0x0E: Greater-than (ordered, signaling) \n
1878 ///    0x0F: True (unordered, non-signaling) \n
1879 ///    0x10: Equal (ordered, signaling) \n
1880 ///    0x11: Less-than (ordered, non-signaling) \n
1881 ///    0x12: Less-than-or-equal (ordered, non-signaling) \n
1882 ///    0x13: Unordered (signaling) \n
1883 ///    0x14: Not-equal (unordered, signaling) \n
1884 ///    0x15: Not-less-than (unordered, non-signaling) \n
1885 ///    0x16: Not-less-than-or-equal (unordered, non-signaling) \n
1886 ///    0x17: Ordered (signaling) \n
1887 ///    0x18: Equal (unordered, signaling) \n
1888 ///    0x19: Not-greater-than-or-equal (unordered, non-signaling) \n
1889 ///    0x1A: Not-greater-than (unordered, non-signaling) \n
1890 ///    0x1B: False (ordered, signaling) \n
1891 ///    0x1C: Not-equal (ordered, signaling) \n
1892 ///    0x1D: Greater-than-or-equal (ordered, non-signaling) \n
1893 ///    0x1E: Greater-than (ordered, non-signaling) \n
1894 ///    0x1F: True (unordered, signaling)
1895 /// \returns A 128-bit vector of [2 x double] containing the comparison results.
1896 /// \fn __m128d _mm_cmp_sd(__m128d a, __m128d b, const int c)
1897 
1898 /* Below intrinsic defined in xmmintrin.h can be used for AVX */
1899 /// Compares each of the corresponding scalar values of two 128-bit
1900 ///    vectors of [4 x float], using the operation specified by the immediate
1901 ///    integer operand.
1902 ///
1903 ///    If the result is true, all 32 bits of the destination vector are set;
1904 ///    otherwise they are cleared.
1905 ///
1906 /// \headerfile <x86intrin.h>
1907 ///
1908 /// \code
1909 /// __m128 _mm_cmp_ss(__m128 a, __m128 b, const int c);
1910 /// \endcode
1911 ///
1912 /// This intrinsic corresponds to the <c> VCMPSS </c> instruction.
1913 ///
1914 /// \param a
1915 ///    A 128-bit vector of [4 x float].
1916 /// \param b
1917 ///    A 128-bit vector of [4 x float].
1918 /// \param c
1919 ///    An immediate integer operand, with bits [4:0] specifying which comparison
1920 ///    operation to use: \n
1921 ///    0x00: Equal (ordered, non-signaling) \n
1922 ///    0x01: Less-than (ordered, signaling) \n
1923 ///    0x02: Less-than-or-equal (ordered, signaling) \n
1924 ///    0x03: Unordered (non-signaling) \n
1925 ///    0x04: Not-equal (unordered, non-signaling) \n
1926 ///    0x05: Not-less-than (unordered, signaling) \n
1927 ///    0x06: Not-less-than-or-equal (unordered, signaling) \n
1928 ///    0x07: Ordered (non-signaling) \n
1929 ///    0x08: Equal (unordered, non-signaling) \n
1930 ///    0x09: Not-greater-than-or-equal (unordered, signaling) \n
1931 ///    0x0A: Not-greater-than (unordered, signaling) \n
1932 ///    0x0B: False (ordered, non-signaling) \n
1933 ///    0x0C: Not-equal (ordered, non-signaling) \n
1934 ///    0x0D: Greater-than-or-equal (ordered, signaling) \n
1935 ///    0x0E: Greater-than (ordered, signaling) \n
1936 ///    0x0F: True (unordered, non-signaling) \n
1937 ///    0x10: Equal (ordered, signaling) \n
1938 ///    0x11: Less-than (ordered, non-signaling) \n
1939 ///    0x12: Less-than-or-equal (ordered, non-signaling) \n
1940 ///    0x13: Unordered (signaling) \n
1941 ///    0x14: Not-equal (unordered, signaling) \n
1942 ///    0x15: Not-less-than (unordered, non-signaling) \n
1943 ///    0x16: Not-less-than-or-equal (unordered, non-signaling) \n
1944 ///    0x17: Ordered (signaling) \n
1945 ///    0x18: Equal (unordered, signaling) \n
1946 ///    0x19: Not-greater-than-or-equal (unordered, non-signaling) \n
1947 ///    0x1A: Not-greater-than (unordered, non-signaling) \n
1948 ///    0x1B: False (ordered, signaling) \n
1949 ///    0x1C: Not-equal (ordered, signaling) \n
1950 ///    0x1D: Greater-than-or-equal (ordered, non-signaling) \n
1951 ///    0x1E: Greater-than (ordered, non-signaling) \n
1952 ///    0x1F: True (unordered, signaling)
1953 /// \returns A 128-bit vector of [4 x float] containing the comparison results.
1954 /// \fn __m128 _mm_cmp_ss(__m128 a, __m128 b, const int c)
1955 
1956 /// Takes a [8 x i32] vector and returns the vector element value
1957 ///    indexed by the immediate constant operand.
1958 ///
1959 /// \headerfile <x86intrin.h>
1960 ///
1961 /// \code
1962 /// int _mm256_extract_epi32(__m256i X, const int N);
1963 /// \endcode
1964 ///
1965 /// This intrinsic corresponds to the <c> VEXTRACTF128+COMPOSITE </c>
1966 ///   instruction.
1967 ///
1968 /// \param X
1969 ///    A 256-bit vector of [8 x i32].
1970 /// \param N
1971 ///    An immediate integer operand with bits [2:0] determining which vector
1972 ///    element is extracted and returned.
1973 /// \returns A 32-bit integer containing the extracted 32 bits of extended
1974 ///    packed data.
1975 #define _mm256_extract_epi32(X, N) \
1976   ((int)__builtin_ia32_vec_ext_v8si((__v8si)(__m256i)(X), (int)(N)))
1977 
1978 /// Takes a [16 x i16] vector and returns the vector element value
1979 ///    indexed by the immediate constant operand.
1980 ///
1981 /// \headerfile <x86intrin.h>
1982 ///
1983 /// \code
1984 /// int _mm256_extract_epi16(__m256i X, const int N);
1985 /// \endcode
1986 ///
1987 /// This intrinsic corresponds to the <c> VEXTRACTF128+COMPOSITE </c>
1988 ///   instruction.
1989 ///
1990 /// \param X
1991 ///    A 256-bit integer vector of [16 x i16].
1992 /// \param N
1993 ///    An immediate integer operand with bits [3:0] determining which vector
1994 ///    element is extracted and returned.
1995 /// \returns A 32-bit integer containing the extracted 16 bits of zero extended
1996 ///    packed data.
1997 #define _mm256_extract_epi16(X, N) \
1998   ((int)(unsigned short)__builtin_ia32_vec_ext_v16hi((__v16hi)(__m256i)(X), \
1999                                                      (int)(N)))
2000 
2001 /// Takes a [32 x i8] vector and returns the vector element value
2002 ///    indexed by the immediate constant operand.
2003 ///
2004 /// \headerfile <x86intrin.h>
2005 ///
2006 /// \code
2007 /// int _mm256_extract_epi8(__m256i X, const int N);
2008 /// \endcode
2009 ///
2010 /// This intrinsic corresponds to the <c> VEXTRACTF128+COMPOSITE </c>
2011 ///   instruction.
2012 ///
2013 /// \param X
2014 ///    A 256-bit integer vector of [32 x i8].
2015 /// \param N
2016 ///    An immediate integer operand with bits [4:0] determining which vector
2017 ///    element is extracted and returned.
2018 /// \returns A 32-bit integer containing the extracted 8 bits of zero extended
2019 ///    packed data.
2020 #define _mm256_extract_epi8(X, N) \
2021   ((int)(unsigned char)__builtin_ia32_vec_ext_v32qi((__v32qi)(__m256i)(X), \
2022                                                     (int)(N)))
2023 
2024 #ifdef __x86_64__
2025 /// Takes a [4 x i64] vector and returns the vector element value
2026 ///    indexed by the immediate constant operand.
2027 ///
2028 /// \headerfile <x86intrin.h>
2029 ///
2030 /// \code
2031 /// long long _mm256_extract_epi64(__m256i X, const int N);
2032 /// \endcode
2033 ///
2034 /// This intrinsic corresponds to the <c> VEXTRACTF128+COMPOSITE </c>
2035 ///   instruction.
2036 ///
2037 /// \param X
2038 ///    A 256-bit integer vector of [4 x i64].
2039 /// \param N
2040 ///    An immediate integer operand with bits [1:0] determining which vector
2041 ///    element is extracted and returned.
2042 /// \returns A 64-bit integer containing the extracted 64 bits of extended
2043 ///    packed data.
2044 #define _mm256_extract_epi64(X, N) \
2045   ((long long)__builtin_ia32_vec_ext_v4di((__v4di)(__m256i)(X), (int)(N)))
2046 #endif
2047 
2048 /// Takes a [8 x i32] vector and replaces the vector element value
2049 ///    indexed by the immediate constant operand by a new value. Returns the
2050 ///    modified vector.
2051 ///
2052 /// \headerfile <x86intrin.h>
2053 ///
2054 /// \code
2055 /// __m256i _mm256_insert_epi32(__m256i X, int I, const int N);
2056 /// \endcode
2057 ///
2058 /// This intrinsic corresponds to the <c> VINSERTF128+COMPOSITE </c>
2059 ///   instruction.
2060 ///
2061 /// \param X
2062 ///    A vector of [8 x i32] to be used by the insert operation.
2063 /// \param I
2064 ///    An integer value. The replacement value for the insert operation.
2065 /// \param N
2066 ///    An immediate integer specifying the index of the vector element to be
2067 ///    replaced.
2068 /// \returns A copy of vector \a X, after replacing its element indexed by
2069 ///    \a N with \a I.
2070 #define _mm256_insert_epi32(X, I, N) \
2071   ((__m256i)__builtin_ia32_vec_set_v8si((__v8si)(__m256i)(X), \
2072                                         (int)(I), (int)(N)))
2073 
2074 
2075 /// Takes a [16 x i16] vector and replaces the vector element value
2076 ///    indexed by the immediate constant operand with a new value. Returns the
2077 ///    modified vector.
2078 ///
2079 /// \headerfile <x86intrin.h>
2080 ///
2081 /// \code
2082 /// __m256i _mm256_insert_epi16(__m256i X, int I, const int N);
2083 /// \endcode
2084 ///
2085 /// This intrinsic corresponds to the <c> VINSERTF128+COMPOSITE </c>
2086 ///   instruction.
2087 ///
2088 /// \param X
2089 ///    A vector of [16 x i16] to be used by the insert operation.
2090 /// \param I
2091 ///    An i16 integer value. The replacement value for the insert operation.
2092 /// \param N
2093 ///    An immediate integer specifying the index of the vector element to be
2094 ///    replaced.
2095 /// \returns A copy of vector \a X, after replacing its element indexed by
2096 ///    \a N with \a I.
2097 #define _mm256_insert_epi16(X, I, N) \
2098   ((__m256i)__builtin_ia32_vec_set_v16hi((__v16hi)(__m256i)(X), \
2099                                          (int)(I), (int)(N)))
2100 
2101 /// Takes a [32 x i8] vector and replaces the vector element value
2102 ///    indexed by the immediate constant operand with a new value. Returns the
2103 ///    modified vector.
2104 ///
2105 /// \headerfile <x86intrin.h>
2106 ///
2107 /// \code
2108 /// __m256i _mm256_insert_epi8(__m256i X, int I, const int N);
2109 /// \endcode
2110 ///
2111 /// This intrinsic corresponds to the <c> VINSERTF128+COMPOSITE </c>
2112 ///   instruction.
2113 ///
2114 /// \param X
2115 ///    A vector of [32 x i8] to be used by the insert operation.
2116 /// \param I
2117 ///    An i8 integer value. The replacement value for the insert operation.
2118 /// \param N
2119 ///    An immediate integer specifying the index of the vector element to be
2120 ///    replaced.
2121 /// \returns A copy of vector \a X, after replacing its element indexed by
2122 ///    \a N with \a I.
2123 #define _mm256_insert_epi8(X, I, N) \
2124   ((__m256i)__builtin_ia32_vec_set_v32qi((__v32qi)(__m256i)(X), \
2125                                          (int)(I), (int)(N)))
2126 
2127 #ifdef __x86_64__
2128 /// Takes a [4 x i64] vector and replaces the vector element value
2129 ///    indexed by the immediate constant operand with a new value. Returns the
2130 ///    modified vector.
2131 ///
2132 /// \headerfile <x86intrin.h>
2133 ///
2134 /// \code
2135 /// __m256i _mm256_insert_epi64(__m256i X, int I, const int N);
2136 /// \endcode
2137 ///
2138 /// This intrinsic corresponds to the <c> VINSERTF128+COMPOSITE </c>
2139 ///   instruction.
2140 ///
2141 /// \param X
2142 ///    A vector of [4 x i64] to be used by the insert operation.
2143 /// \param I
2144 ///    A 64-bit integer value. The replacement value for the insert operation.
2145 /// \param N
2146 ///    An immediate integer specifying the index of the vector element to be
2147 ///    replaced.
2148 /// \returns A copy of vector \a X, after replacing its element indexed by
2149 ///     \a N with \a I.
2150 #define _mm256_insert_epi64(X, I, N) \
2151   ((__m256i)__builtin_ia32_vec_set_v4di((__v4di)(__m256i)(X), \
2152                                         (long long)(I), (int)(N)))
2153 #endif
2154 
2155 /* Conversion */
2156 /// Converts a vector of [4 x i32] into a vector of [4 x double].
2157 ///
2158 /// \headerfile <x86intrin.h>
2159 ///
2160 /// This intrinsic corresponds to the <c> VCVTDQ2PD </c> instruction.
2161 ///
2162 /// \param __a
2163 ///    A 128-bit integer vector of [4 x i32].
2164 /// \returns A 256-bit vector of [4 x double] containing the converted values.
2165 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_cvtepi32_pd(__m128i __a)2166 _mm256_cvtepi32_pd(__m128i __a)
2167 {
2168   return (__m256d)__builtin_convertvector((__v4si)__a, __v4df);
2169 }
2170 
2171 /// Converts a vector of [8 x i32] into a vector of [8 x float].
2172 ///
2173 /// \headerfile <x86intrin.h>
2174 ///
2175 /// This intrinsic corresponds to the <c> VCVTDQ2PS </c> instruction.
2176 ///
2177 /// \param __a
2178 ///    A 256-bit integer vector.
2179 /// \returns A 256-bit vector of [8 x float] containing the converted values.
2180 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_cvtepi32_ps(__m256i __a)2181 _mm256_cvtepi32_ps(__m256i __a)
2182 {
2183   return (__m256)__builtin_convertvector((__v8si)__a, __v8sf);
2184 }
2185 
2186 /// Converts a 256-bit vector of [4 x double] into a 128-bit vector of
2187 ///    [4 x float].
2188 ///
2189 /// \headerfile <x86intrin.h>
2190 ///
2191 /// This intrinsic corresponds to the <c> VCVTPD2PS </c> instruction.
2192 ///
2193 /// \param __a
2194 ///    A 256-bit vector of [4 x double].
2195 /// \returns A 128-bit vector of [4 x float] containing the converted values.
2196 static __inline __m128 __DEFAULT_FN_ATTRS
_mm256_cvtpd_ps(__m256d __a)2197 _mm256_cvtpd_ps(__m256d __a)
2198 {
2199   return (__m128)__builtin_ia32_cvtpd2ps256((__v4df) __a);
2200 }
2201 
2202 /// Converts a vector of [8 x float] into a vector of [8 x i32].
2203 ///
2204 /// \headerfile <x86intrin.h>
2205 ///
2206 /// This intrinsic corresponds to the <c> VCVTPS2DQ </c> instruction.
2207 ///
2208 /// \param __a
2209 ///    A 256-bit vector of [8 x float].
2210 /// \returns A 256-bit integer vector containing the converted values.
2211 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_cvtps_epi32(__m256 __a)2212 _mm256_cvtps_epi32(__m256 __a)
2213 {
2214   return (__m256i)__builtin_ia32_cvtps2dq256((__v8sf) __a);
2215 }
2216 
2217 /// Converts a 128-bit vector of [4 x float] into a 256-bit vector of [4
2218 ///    x double].
2219 ///
2220 /// \headerfile <x86intrin.h>
2221 ///
2222 /// This intrinsic corresponds to the <c> VCVTPS2PD </c> instruction.
2223 ///
2224 /// \param __a
2225 ///    A 128-bit vector of [4 x float].
2226 /// \returns A 256-bit vector of [4 x double] containing the converted values.
2227 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_cvtps_pd(__m128 __a)2228 _mm256_cvtps_pd(__m128 __a)
2229 {
2230   return (__m256d)__builtin_convertvector((__v4sf)__a, __v4df);
2231 }
2232 
2233 /// Converts a 256-bit vector of [4 x double] into a 128-bit vector of [4
2234 ///    x i32], truncating the result by rounding towards zero when it is
2235 ///    inexact.
2236 ///
2237 /// \headerfile <x86intrin.h>
2238 ///
2239 /// This intrinsic corresponds to the <c> VCVTTPD2DQ </c> instruction.
2240 ///
2241 /// \param __a
2242 ///    A 256-bit vector of [4 x double].
2243 /// \returns A 128-bit integer vector containing the converted values.
2244 static __inline __m128i __DEFAULT_FN_ATTRS
_mm256_cvttpd_epi32(__m256d __a)2245 _mm256_cvttpd_epi32(__m256d __a)
2246 {
2247   return (__m128i)__builtin_ia32_cvttpd2dq256((__v4df) __a);
2248 }
2249 
2250 /// Converts a 256-bit vector of [4 x double] into a 128-bit vector of [4
2251 ///    x i32]. When a conversion is inexact, the value returned is rounded
2252 ///    according to the rounding control bits in the MXCSR register.
2253 ///
2254 /// \headerfile <x86intrin.h>
2255 ///
2256 /// This intrinsic corresponds to the <c> VCVTPD2DQ </c> instruction.
2257 ///
2258 /// \param __a
2259 ///    A 256-bit vector of [4 x double].
2260 /// \returns A 128-bit integer vector containing the converted values.
2261 static __inline __m128i __DEFAULT_FN_ATTRS
_mm256_cvtpd_epi32(__m256d __a)2262 _mm256_cvtpd_epi32(__m256d __a)
2263 {
2264   return (__m128i)__builtin_ia32_cvtpd2dq256((__v4df) __a);
2265 }
2266 
2267 /// Converts a vector of [8 x float] into a vector of [8 x i32],
2268 ///    truncating the result by rounding towards zero when it is inexact.
2269 ///
2270 /// \headerfile <x86intrin.h>
2271 ///
2272 /// This intrinsic corresponds to the <c> VCVTTPS2DQ </c> instruction.
2273 ///
2274 /// \param __a
2275 ///    A 256-bit vector of [8 x float].
2276 /// \returns A 256-bit integer vector containing the converted values.
2277 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_cvttps_epi32(__m256 __a)2278 _mm256_cvttps_epi32(__m256 __a)
2279 {
2280   return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a);
2281 }
2282 
2283 /// Returns the first element of the input vector of [4 x double].
2284 ///
2285 /// \headerfile <x86intrin.h>
2286 ///
2287 /// This intrinsic is a utility function and does not correspond to a specific
2288 ///    instruction.
2289 ///
2290 /// \param __a
2291 ///    A 256-bit vector of [4 x double].
2292 /// \returns A 64 bit double containing the first element of the input vector.
2293 static __inline double __DEFAULT_FN_ATTRS
_mm256_cvtsd_f64(__m256d __a)2294 _mm256_cvtsd_f64(__m256d __a)
2295 {
2296  return __a[0];
2297 }
2298 
2299 /// Returns the first element of the input vector of [8 x i32].
2300 ///
2301 /// \headerfile <x86intrin.h>
2302 ///
2303 /// This intrinsic is a utility function and does not correspond to a specific
2304 ///    instruction.
2305 ///
2306 /// \param __a
2307 ///    A 256-bit vector of [8 x i32].
2308 /// \returns A 32 bit integer containing the first element of the input vector.
2309 static __inline int __DEFAULT_FN_ATTRS
_mm256_cvtsi256_si32(__m256i __a)2310 _mm256_cvtsi256_si32(__m256i __a)
2311 {
2312  __v8si __b = (__v8si)__a;
2313  return __b[0];
2314 }
2315 
2316 /// Returns the first element of the input vector of [8 x float].
2317 ///
2318 /// \headerfile <x86intrin.h>
2319 ///
2320 /// This intrinsic is a utility function and does not correspond to a specific
2321 ///    instruction.
2322 ///
2323 /// \param __a
2324 ///    A 256-bit vector of [8 x float].
2325 /// \returns A 32 bit float containing the first element of the input vector.
2326 static __inline float __DEFAULT_FN_ATTRS
_mm256_cvtss_f32(__m256 __a)2327 _mm256_cvtss_f32(__m256 __a)
2328 {
2329  return __a[0];
2330 }
2331 
2332 /* Vector replicate */
2333 /// Moves and duplicates odd-indexed values from a 256-bit vector of
2334 ///    [8 x float] to float values in a 256-bit vector of [8 x float].
2335 ///
2336 /// \headerfile <x86intrin.h>
2337 ///
2338 /// This intrinsic corresponds to the <c> VMOVSHDUP </c> instruction.
2339 ///
2340 /// \param __a
2341 ///    A 256-bit vector of [8 x float]. \n
2342 ///    Bits [255:224] of \a __a are written to bits [255:224] and [223:192] of
2343 ///    the return value. \n
2344 ///    Bits [191:160] of \a __a are written to bits [191:160] and [159:128] of
2345 ///    the return value. \n
2346 ///    Bits [127:96] of \a __a are written to bits [127:96] and [95:64] of the
2347 ///    return value. \n
2348 ///    Bits [63:32] of \a __a are written to bits [63:32] and [31:0] of the
2349 ///    return value.
2350 /// \returns A 256-bit vector of [8 x float] containing the moved and duplicated
2351 ///    values.
2352 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_movehdup_ps(__m256 __a)2353 _mm256_movehdup_ps(__m256 __a)
2354 {
2355   return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 1, 1, 3, 3, 5, 5, 7, 7);
2356 }
2357 
2358 /// Moves and duplicates even-indexed values from a 256-bit vector of
2359 ///    [8 x float] to float values in a 256-bit vector of [8 x float].
2360 ///
2361 /// \headerfile <x86intrin.h>
2362 ///
2363 /// This intrinsic corresponds to the <c> VMOVSLDUP </c> instruction.
2364 ///
2365 /// \param __a
2366 ///    A 256-bit vector of [8 x float]. \n
2367 ///    Bits [223:192] of \a __a are written to bits [255:224] and [223:192] of
2368 ///    the return value. \n
2369 ///    Bits [159:128] of \a __a are written to bits [191:160] and [159:128] of
2370 ///    the return value. \n
2371 ///    Bits [95:64] of \a __a are written to bits [127:96] and [95:64] of the
2372 ///    return value. \n
2373 ///    Bits [31:0] of \a __a are written to bits [63:32] and [31:0] of the
2374 ///    return value.
2375 /// \returns A 256-bit vector of [8 x float] containing the moved and duplicated
2376 ///    values.
2377 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_moveldup_ps(__m256 __a)2378 _mm256_moveldup_ps(__m256 __a)
2379 {
2380   return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 0, 0, 2, 2, 4, 4, 6, 6);
2381 }
2382 
2383 /// Moves and duplicates double-precision floating point values from a
2384 ///    256-bit vector of [4 x double] to double-precision values in a 256-bit
2385 ///    vector of [4 x double].
2386 ///
2387 /// \headerfile <x86intrin.h>
2388 ///
2389 /// This intrinsic corresponds to the <c> VMOVDDUP </c> instruction.
2390 ///
2391 /// \param __a
2392 ///    A 256-bit vector of [4 x double]. \n
2393 ///    Bits [63:0] of \a __a are written to bits [127:64] and [63:0] of the
2394 ///    return value. \n
2395 ///    Bits [191:128] of \a __a are written to bits [255:192] and [191:128] of
2396 ///    the return value.
2397 /// \returns A 256-bit vector of [4 x double] containing the moved and
2398 ///    duplicated values.
2399 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_movedup_pd(__m256d __a)2400 _mm256_movedup_pd(__m256d __a)
2401 {
2402   return __builtin_shufflevector((__v4df)__a, (__v4df)__a, 0, 0, 2, 2);
2403 }
2404 
2405 /* Unpack and Interleave */
2406 /// Unpacks the odd-indexed vector elements from two 256-bit vectors of
2407 ///    [4 x double] and interleaves them into a 256-bit vector of [4 x double].
2408 ///
2409 /// \headerfile <x86intrin.h>
2410 ///
2411 /// This intrinsic corresponds to the <c> VUNPCKHPD </c> instruction.
2412 ///
2413 /// \param __a
2414 ///    A 256-bit floating-point vector of [4 x double]. \n
2415 ///    Bits [127:64] are written to bits [63:0] of the return value. \n
2416 ///    Bits [255:192] are written to bits [191:128] of the return value. \n
2417 /// \param __b
2418 ///    A 256-bit floating-point vector of [4 x double]. \n
2419 ///    Bits [127:64] are written to bits [127:64] of the return value. \n
2420 ///    Bits [255:192] are written to bits [255:192] of the return value. \n
2421 /// \returns A 256-bit vector of [4 x double] containing the interleaved values.
2422 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_unpackhi_pd(__m256d __a,__m256d __b)2423 _mm256_unpackhi_pd(__m256d __a, __m256d __b)
2424 {
2425   return __builtin_shufflevector((__v4df)__a, (__v4df)__b, 1, 5, 1+2, 5+2);
2426 }
2427 
2428 /// Unpacks the even-indexed vector elements from two 256-bit vectors of
2429 ///    [4 x double] and interleaves them into a 256-bit vector of [4 x double].
2430 ///
2431 /// \headerfile <x86intrin.h>
2432 ///
2433 /// This intrinsic corresponds to the <c> VUNPCKLPD </c> instruction.
2434 ///
2435 /// \param __a
2436 ///    A 256-bit floating-point vector of [4 x double]. \n
2437 ///    Bits [63:0] are written to bits [63:0] of the return value. \n
2438 ///    Bits [191:128] are written to bits [191:128] of the return value.
2439 /// \param __b
2440 ///    A 256-bit floating-point vector of [4 x double]. \n
2441 ///    Bits [63:0] are written to bits [127:64] of the return value. \n
2442 ///    Bits [191:128] are written to bits [255:192] of the return value. \n
2443 /// \returns A 256-bit vector of [4 x double] containing the interleaved values.
2444 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_unpacklo_pd(__m256d __a,__m256d __b)2445 _mm256_unpacklo_pd(__m256d __a, __m256d __b)
2446 {
2447   return __builtin_shufflevector((__v4df)__a, (__v4df)__b, 0, 4, 0+2, 4+2);
2448 }
2449 
2450 /// Unpacks the 32-bit vector elements 2, 3, 6 and 7 from each of the
2451 ///    two 256-bit vectors of [8 x float] and interleaves them into a 256-bit
2452 ///    vector of [8 x float].
2453 ///
2454 /// \headerfile <x86intrin.h>
2455 ///
2456 /// This intrinsic corresponds to the <c> VUNPCKHPS </c> instruction.
2457 ///
2458 /// \param __a
2459 ///    A 256-bit vector of [8 x float]. \n
2460 ///    Bits [95:64] are written to bits [31:0] of the return value. \n
2461 ///    Bits [127:96] are written to bits [95:64] of the return value. \n
2462 ///    Bits [223:192] are written to bits [159:128] of the return value. \n
2463 ///    Bits [255:224] are written to bits [223:192] of the return value.
2464 /// \param __b
2465 ///    A 256-bit vector of [8 x float]. \n
2466 ///    Bits [95:64] are written to bits [63:32] of the return value. \n
2467 ///    Bits [127:96] are written to bits [127:96] of the return value. \n
2468 ///    Bits [223:192] are written to bits [191:160] of the return value. \n
2469 ///    Bits [255:224] are written to bits [255:224] of the return value.
2470 /// \returns A 256-bit vector of [8 x float] containing the interleaved values.
2471 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_unpackhi_ps(__m256 __a,__m256 __b)2472 _mm256_unpackhi_ps(__m256 __a, __m256 __b)
2473 {
2474   return __builtin_shufflevector((__v8sf)__a, (__v8sf)__b, 2, 10, 2+1, 10+1, 6, 14, 6+1, 14+1);
2475 }
2476 
2477 /// Unpacks the 32-bit vector elements 0, 1, 4 and 5 from each of the
2478 ///    two 256-bit vectors of [8 x float] and interleaves them into a 256-bit
2479 ///    vector of [8 x float].
2480 ///
2481 /// \headerfile <x86intrin.h>
2482 ///
2483 /// This intrinsic corresponds to the <c> VUNPCKLPS </c> instruction.
2484 ///
2485 /// \param __a
2486 ///    A 256-bit vector of [8 x float]. \n
2487 ///    Bits [31:0] are written to bits [31:0] of the return value. \n
2488 ///    Bits [63:32] are written to bits [95:64] of the return value. \n
2489 ///    Bits [159:128] are written to bits [159:128] of the return value. \n
2490 ///    Bits [191:160] are written to bits [223:192] of the return value.
2491 /// \param __b
2492 ///    A 256-bit vector of [8 x float]. \n
2493 ///    Bits [31:0] are written to bits [63:32] of the return value. \n
2494 ///    Bits [63:32] are written to bits [127:96] of the return value. \n
2495 ///    Bits [159:128] are written to bits [191:160] of the return value. \n
2496 ///    Bits [191:160] are written to bits [255:224] of the return value.
2497 /// \returns A 256-bit vector of [8 x float] containing the interleaved values.
2498 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_unpacklo_ps(__m256 __a,__m256 __b)2499 _mm256_unpacklo_ps(__m256 __a, __m256 __b)
2500 {
2501   return __builtin_shufflevector((__v8sf)__a, (__v8sf)__b, 0, 8, 0+1, 8+1, 4, 12, 4+1, 12+1);
2502 }
2503 
2504 /* Bit Test */
2505 /// Given two 128-bit floating-point vectors of [2 x double], perform an
2506 ///    element-by-element comparison of the double-precision element in the
2507 ///    first source vector and the corresponding element in the second source
2508 ///    vector.
2509 ///
2510 ///    The EFLAGS register is updated as follows: \n
2511 ///    If there is at least one pair of double-precision elements where the
2512 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2513 ///    ZF flag is set to 1. \n
2514 ///    If there is at least one pair of double-precision elements where the
2515 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2516 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2517 ///    This intrinsic returns the value of the ZF flag.
2518 ///
2519 /// \headerfile <x86intrin.h>
2520 ///
2521 /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
2522 ///
2523 /// \param __a
2524 ///    A 128-bit vector of [2 x double].
2525 /// \param __b
2526 ///    A 128-bit vector of [2 x double].
2527 /// \returns the ZF flag in the EFLAGS register.
2528 static __inline int __DEFAULT_FN_ATTRS128
_mm_testz_pd(__m128d __a,__m128d __b)2529 _mm_testz_pd(__m128d __a, __m128d __b)
2530 {
2531   return __builtin_ia32_vtestzpd((__v2df)__a, (__v2df)__b);
2532 }
2533 
2534 /// Given two 128-bit floating-point vectors of [2 x double], perform an
2535 ///    element-by-element comparison of the double-precision element in the
2536 ///    first source vector and the corresponding element in the second source
2537 ///    vector.
2538 ///
2539 ///    The EFLAGS register is updated as follows: \n
2540 ///    If there is at least one pair of double-precision elements where the
2541 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2542 ///    ZF flag is set to 1. \n
2543 ///    If there is at least one pair of double-precision elements where the
2544 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2545 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2546 ///    This intrinsic returns the value of the CF flag.
2547 ///
2548 /// \headerfile <x86intrin.h>
2549 ///
2550 /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
2551 ///
2552 /// \param __a
2553 ///    A 128-bit vector of [2 x double].
2554 /// \param __b
2555 ///    A 128-bit vector of [2 x double].
2556 /// \returns the CF flag in the EFLAGS register.
2557 static __inline int __DEFAULT_FN_ATTRS128
_mm_testc_pd(__m128d __a,__m128d __b)2558 _mm_testc_pd(__m128d __a, __m128d __b)
2559 {
2560   return __builtin_ia32_vtestcpd((__v2df)__a, (__v2df)__b);
2561 }
2562 
2563 /// Given two 128-bit floating-point vectors of [2 x double], perform an
2564 ///    element-by-element comparison of the double-precision element in the
2565 ///    first source vector and the corresponding element in the second source
2566 ///    vector.
2567 ///
2568 ///    The EFLAGS register is updated as follows: \n
2569 ///    If there is at least one pair of double-precision elements where the
2570 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2571 ///    ZF flag is set to 1. \n
2572 ///    If there is at least one pair of double-precision elements where the
2573 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2574 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2575 ///    This intrinsic returns 1 if both the ZF and CF flags are set to 0,
2576 ///    otherwise it returns 0.
2577 ///
2578 /// \headerfile <x86intrin.h>
2579 ///
2580 /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
2581 ///
2582 /// \param __a
2583 ///    A 128-bit vector of [2 x double].
2584 /// \param __b
2585 ///    A 128-bit vector of [2 x double].
2586 /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
2587 static __inline int __DEFAULT_FN_ATTRS128
_mm_testnzc_pd(__m128d __a,__m128d __b)2588 _mm_testnzc_pd(__m128d __a, __m128d __b)
2589 {
2590   return __builtin_ia32_vtestnzcpd((__v2df)__a, (__v2df)__b);
2591 }
2592 
2593 /// Given two 128-bit floating-point vectors of [4 x float], perform an
2594 ///    element-by-element comparison of the single-precision element in the
2595 ///    first source vector and the corresponding element in the second source
2596 ///    vector.
2597 ///
2598 ///    The EFLAGS register is updated as follows: \n
2599 ///    If there is at least one pair of single-precision elements where the
2600 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2601 ///    ZF flag is set to 1. \n
2602 ///    If there is at least one pair of single-precision elements where the
2603 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2604 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2605 ///    This intrinsic returns the value of the ZF flag.
2606 ///
2607 /// \headerfile <x86intrin.h>
2608 ///
2609 /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
2610 ///
2611 /// \param __a
2612 ///    A 128-bit vector of [4 x float].
2613 /// \param __b
2614 ///    A 128-bit vector of [4 x float].
2615 /// \returns the ZF flag.
2616 static __inline int __DEFAULT_FN_ATTRS128
_mm_testz_ps(__m128 __a,__m128 __b)2617 _mm_testz_ps(__m128 __a, __m128 __b)
2618 {
2619   return __builtin_ia32_vtestzps((__v4sf)__a, (__v4sf)__b);
2620 }
2621 
2622 /// Given two 128-bit floating-point vectors of [4 x float], perform an
2623 ///    element-by-element comparison of the single-precision element in the
2624 ///    first source vector and the corresponding element in the second source
2625 ///    vector.
2626 ///
2627 ///    The EFLAGS register is updated as follows: \n
2628 ///    If there is at least one pair of single-precision elements where the
2629 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2630 ///    ZF flag is set to 1. \n
2631 ///    If there is at least one pair of single-precision elements where the
2632 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2633 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2634 ///    This intrinsic returns the value of the CF flag.
2635 ///
2636 /// \headerfile <x86intrin.h>
2637 ///
2638 /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
2639 ///
2640 /// \param __a
2641 ///    A 128-bit vector of [4 x float].
2642 /// \param __b
2643 ///    A 128-bit vector of [4 x float].
2644 /// \returns the CF flag.
2645 static __inline int __DEFAULT_FN_ATTRS128
_mm_testc_ps(__m128 __a,__m128 __b)2646 _mm_testc_ps(__m128 __a, __m128 __b)
2647 {
2648   return __builtin_ia32_vtestcps((__v4sf)__a, (__v4sf)__b);
2649 }
2650 
2651 /// Given two 128-bit floating-point vectors of [4 x float], perform an
2652 ///    element-by-element comparison of the single-precision element in the
2653 ///    first source vector and the corresponding element in the second source
2654 ///    vector.
2655 ///
2656 ///    The EFLAGS register is updated as follows: \n
2657 ///    If there is at least one pair of single-precision elements where the
2658 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2659 ///    ZF flag is set to 1. \n
2660 ///    If there is at least one pair of single-precision elements where the
2661 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2662 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2663 ///    This intrinsic returns 1 if both the ZF and CF flags are set to 0,
2664 ///    otherwise it returns 0.
2665 ///
2666 /// \headerfile <x86intrin.h>
2667 ///
2668 /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
2669 ///
2670 /// \param __a
2671 ///    A 128-bit vector of [4 x float].
2672 /// \param __b
2673 ///    A 128-bit vector of [4 x float].
2674 /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
2675 static __inline int __DEFAULT_FN_ATTRS128
_mm_testnzc_ps(__m128 __a,__m128 __b)2676 _mm_testnzc_ps(__m128 __a, __m128 __b)
2677 {
2678   return __builtin_ia32_vtestnzcps((__v4sf)__a, (__v4sf)__b);
2679 }
2680 
2681 /// Given two 256-bit floating-point vectors of [4 x double], perform an
2682 ///    element-by-element comparison of the double-precision elements in the
2683 ///    first source vector and the corresponding elements in the second source
2684 ///    vector.
2685 ///
2686 ///    The EFLAGS register is updated as follows: \n
2687 ///    If there is at least one pair of double-precision elements where the
2688 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2689 ///    ZF flag is set to 1. \n
2690 ///    If there is at least one pair of double-precision elements where the
2691 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2692 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2693 ///    This intrinsic returns the value of the ZF flag.
2694 ///
2695 /// \headerfile <x86intrin.h>
2696 ///
2697 /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
2698 ///
2699 /// \param __a
2700 ///    A 256-bit vector of [4 x double].
2701 /// \param __b
2702 ///    A 256-bit vector of [4 x double].
2703 /// \returns the ZF flag.
2704 static __inline int __DEFAULT_FN_ATTRS
_mm256_testz_pd(__m256d __a,__m256d __b)2705 _mm256_testz_pd(__m256d __a, __m256d __b)
2706 {
2707   return __builtin_ia32_vtestzpd256((__v4df)__a, (__v4df)__b);
2708 }
2709 
2710 /// Given two 256-bit floating-point vectors of [4 x double], perform an
2711 ///    element-by-element comparison of the double-precision elements in the
2712 ///    first source vector and the corresponding elements in the second source
2713 ///    vector.
2714 ///
2715 ///    The EFLAGS register is updated as follows: \n
2716 ///    If there is at least one pair of double-precision elements where the
2717 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2718 ///    ZF flag is set to 1. \n
2719 ///    If there is at least one pair of double-precision elements where the
2720 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2721 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2722 ///    This intrinsic returns the value of the CF flag.
2723 ///
2724 /// \headerfile <x86intrin.h>
2725 ///
2726 /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
2727 ///
2728 /// \param __a
2729 ///    A 256-bit vector of [4 x double].
2730 /// \param __b
2731 ///    A 256-bit vector of [4 x double].
2732 /// \returns the CF flag.
2733 static __inline int __DEFAULT_FN_ATTRS
_mm256_testc_pd(__m256d __a,__m256d __b)2734 _mm256_testc_pd(__m256d __a, __m256d __b)
2735 {
2736   return __builtin_ia32_vtestcpd256((__v4df)__a, (__v4df)__b);
2737 }
2738 
2739 /// Given two 256-bit floating-point vectors of [4 x double], perform an
2740 ///    element-by-element comparison of the double-precision elements in the
2741 ///    first source vector and the corresponding elements in the second source
2742 ///    vector.
2743 ///
2744 ///    The EFLAGS register is updated as follows: \n
2745 ///    If there is at least one pair of double-precision elements where the
2746 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2747 ///    ZF flag is set to 1. \n
2748 ///    If there is at least one pair of double-precision elements where the
2749 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2750 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2751 ///    This intrinsic returns 1 if both the ZF and CF flags are set to 0,
2752 ///    otherwise it returns 0.
2753 ///
2754 /// \headerfile <x86intrin.h>
2755 ///
2756 /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
2757 ///
2758 /// \param __a
2759 ///    A 256-bit vector of [4 x double].
2760 /// \param __b
2761 ///    A 256-bit vector of [4 x double].
2762 /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
2763 static __inline int __DEFAULT_FN_ATTRS
_mm256_testnzc_pd(__m256d __a,__m256d __b)2764 _mm256_testnzc_pd(__m256d __a, __m256d __b)
2765 {
2766   return __builtin_ia32_vtestnzcpd256((__v4df)__a, (__v4df)__b);
2767 }
2768 
2769 /// Given two 256-bit floating-point vectors of [8 x float], perform an
2770 ///    element-by-element comparison of the single-precision element in the
2771 ///    first source vector and the corresponding element in the second source
2772 ///    vector.
2773 ///
2774 ///    The EFLAGS register is updated as follows: \n
2775 ///    If there is at least one pair of single-precision elements where the
2776 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2777 ///    ZF flag is set to 1. \n
2778 ///    If there is at least one pair of single-precision elements where the
2779 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2780 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2781 ///    This intrinsic returns the value of the ZF flag.
2782 ///
2783 /// \headerfile <x86intrin.h>
2784 ///
2785 /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
2786 ///
2787 /// \param __a
2788 ///    A 256-bit vector of [8 x float].
2789 /// \param __b
2790 ///    A 256-bit vector of [8 x float].
2791 /// \returns the ZF flag.
2792 static __inline int __DEFAULT_FN_ATTRS
_mm256_testz_ps(__m256 __a,__m256 __b)2793 _mm256_testz_ps(__m256 __a, __m256 __b)
2794 {
2795   return __builtin_ia32_vtestzps256((__v8sf)__a, (__v8sf)__b);
2796 }
2797 
2798 /// Given two 256-bit floating-point vectors of [8 x float], perform an
2799 ///    element-by-element comparison of the single-precision element in the
2800 ///    first source vector and the corresponding element in the second source
2801 ///    vector.
2802 ///
2803 ///    The EFLAGS register is updated as follows: \n
2804 ///    If there is at least one pair of single-precision elements where the
2805 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2806 ///    ZF flag is set to 1. \n
2807 ///    If there is at least one pair of single-precision elements where the
2808 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2809 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2810 ///    This intrinsic returns the value of the CF flag.
2811 ///
2812 /// \headerfile <x86intrin.h>
2813 ///
2814 /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
2815 ///
2816 /// \param __a
2817 ///    A 256-bit vector of [8 x float].
2818 /// \param __b
2819 ///    A 256-bit vector of [8 x float].
2820 /// \returns the CF flag.
2821 static __inline int __DEFAULT_FN_ATTRS
_mm256_testc_ps(__m256 __a,__m256 __b)2822 _mm256_testc_ps(__m256 __a, __m256 __b)
2823 {
2824   return __builtin_ia32_vtestcps256((__v8sf)__a, (__v8sf)__b);
2825 }
2826 
2827 /// Given two 256-bit floating-point vectors of [8 x float], perform an
2828 ///    element-by-element comparison of the single-precision elements in the
2829 ///    first source vector and the corresponding elements in the second source
2830 ///    vector.
2831 ///
2832 ///    The EFLAGS register is updated as follows: \n
2833 ///    If there is at least one pair of single-precision elements where the
2834 ///    sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
2835 ///    ZF flag is set to 1. \n
2836 ///    If there is at least one pair of single-precision elements where the
2837 ///    sign-bit of the first element is 0 and the sign-bit of the second element
2838 ///    is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
2839 ///    This intrinsic returns 1 if both the ZF and CF flags are set to 0,
2840 ///    otherwise it returns 0.
2841 ///
2842 /// \headerfile <x86intrin.h>
2843 ///
2844 /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
2845 ///
2846 /// \param __a
2847 ///    A 256-bit vector of [8 x float].
2848 /// \param __b
2849 ///    A 256-bit vector of [8 x float].
2850 /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
2851 static __inline int __DEFAULT_FN_ATTRS
_mm256_testnzc_ps(__m256 __a,__m256 __b)2852 _mm256_testnzc_ps(__m256 __a, __m256 __b)
2853 {
2854   return __builtin_ia32_vtestnzcps256((__v8sf)__a, (__v8sf)__b);
2855 }
2856 
2857 /// Given two 256-bit integer vectors, perform a bit-by-bit comparison
2858 ///    of the two source vectors.
2859 ///
2860 ///    The EFLAGS register is updated as follows: \n
2861 ///    If there is at least one pair of bits where both bits are 1, the ZF flag
2862 ///    is set to 0. Otherwise the ZF flag is set to 1. \n
2863 ///    If there is at least one pair of bits where the bit from the first source
2864 ///    vector is 0 and the bit from the second source vector is 1, the CF flag
2865 ///    is set to 0. Otherwise the CF flag is set to 1. \n
2866 ///    This intrinsic returns the value of the ZF flag.
2867 ///
2868 /// \headerfile <x86intrin.h>
2869 ///
2870 /// This intrinsic corresponds to the <c> VPTEST </c> instruction.
2871 ///
2872 /// \param __a
2873 ///    A 256-bit integer vector.
2874 /// \param __b
2875 ///    A 256-bit integer vector.
2876 /// \returns the ZF flag.
2877 static __inline int __DEFAULT_FN_ATTRS
_mm256_testz_si256(__m256i __a,__m256i __b)2878 _mm256_testz_si256(__m256i __a, __m256i __b)
2879 {
2880   return __builtin_ia32_ptestz256((__v4di)__a, (__v4di)__b);
2881 }
2882 
2883 /// Given two 256-bit integer vectors, perform a bit-by-bit comparison
2884 ///    of the two source vectors.
2885 ///
2886 ///    The EFLAGS register is updated as follows: \n
2887 ///    If there is at least one pair of bits where both bits are 1, the ZF flag
2888 ///    is set to 0. Otherwise the ZF flag is set to 1. \n
2889 ///    If there is at least one pair of bits where the bit from the first source
2890 ///    vector is 0 and the bit from the second source vector is 1, the CF flag
2891 ///    is set to 0. Otherwise the CF flag is set to 1. \n
2892 ///    This intrinsic returns the value of the CF flag.
2893 ///
2894 /// \headerfile <x86intrin.h>
2895 ///
2896 /// This intrinsic corresponds to the <c> VPTEST </c> instruction.
2897 ///
2898 /// \param __a
2899 ///    A 256-bit integer vector.
2900 /// \param __b
2901 ///    A 256-bit integer vector.
2902 /// \returns the CF flag.
2903 static __inline int __DEFAULT_FN_ATTRS
_mm256_testc_si256(__m256i __a,__m256i __b)2904 _mm256_testc_si256(__m256i __a, __m256i __b)
2905 {
2906   return __builtin_ia32_ptestc256((__v4di)__a, (__v4di)__b);
2907 }
2908 
2909 /// Given two 256-bit integer vectors, perform a bit-by-bit comparison
2910 ///    of the two source vectors.
2911 ///
2912 ///    The EFLAGS register is updated as follows: \n
2913 ///    If there is at least one pair of bits where both bits are 1, the ZF flag
2914 ///    is set to 0. Otherwise the ZF flag is set to 1. \n
2915 ///    If there is at least one pair of bits where the bit from the first source
2916 ///    vector is 0 and the bit from the second source vector is 1, the CF flag
2917 ///    is set to 0. Otherwise the CF flag is set to 1. \n
2918 ///    This intrinsic returns 1 if both the ZF and CF flags are set to 0,
2919 ///    otherwise it returns 0.
2920 ///
2921 /// \headerfile <x86intrin.h>
2922 ///
2923 /// This intrinsic corresponds to the <c> VPTEST </c> instruction.
2924 ///
2925 /// \param __a
2926 ///    A 256-bit integer vector.
2927 /// \param __b
2928 ///    A 256-bit integer vector.
2929 /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
2930 static __inline int __DEFAULT_FN_ATTRS
_mm256_testnzc_si256(__m256i __a,__m256i __b)2931 _mm256_testnzc_si256(__m256i __a, __m256i __b)
2932 {
2933   return __builtin_ia32_ptestnzc256((__v4di)__a, (__v4di)__b);
2934 }
2935 
2936 /* Vector extract sign mask */
2937 /// Extracts the sign bits of double-precision floating point elements
2938 ///    in a 256-bit vector of [4 x double] and writes them to the lower order
2939 ///    bits of the return value.
2940 ///
2941 /// \headerfile <x86intrin.h>
2942 ///
2943 /// This intrinsic corresponds to the <c> VMOVMSKPD </c> instruction.
2944 ///
2945 /// \param __a
2946 ///    A 256-bit vector of [4 x double] containing the double-precision
2947 ///    floating point values with sign bits to be extracted.
2948 /// \returns The sign bits from the operand, written to bits [3:0].
2949 static __inline int __DEFAULT_FN_ATTRS
_mm256_movemask_pd(__m256d __a)2950 _mm256_movemask_pd(__m256d __a)
2951 {
2952   return __builtin_ia32_movmskpd256((__v4df)__a);
2953 }
2954 
2955 /// Extracts the sign bits of single-precision floating point elements
2956 ///    in a 256-bit vector of [8 x float] and writes them to the lower order
2957 ///    bits of the return value.
2958 ///
2959 /// \headerfile <x86intrin.h>
2960 ///
2961 /// This intrinsic corresponds to the <c> VMOVMSKPS </c> instruction.
2962 ///
2963 /// \param __a
2964 ///    A 256-bit vector of [8 x float] containing the single-precision floating
2965 ///    point values with sign bits to be extracted.
2966 /// \returns The sign bits from the operand, written to bits [7:0].
2967 static __inline int __DEFAULT_FN_ATTRS
_mm256_movemask_ps(__m256 __a)2968 _mm256_movemask_ps(__m256 __a)
2969 {
2970   return __builtin_ia32_movmskps256((__v8sf)__a);
2971 }
2972 
2973 /* Vector __zero */
2974 /// Zeroes the contents of all XMM or YMM registers.
2975 ///
2976 /// \headerfile <x86intrin.h>
2977 ///
2978 /// This intrinsic corresponds to the <c> VZEROALL </c> instruction.
2979 static __inline void __attribute__((__always_inline__, __nodebug__, __target__("avx")))
_mm256_zeroall(void)2980 _mm256_zeroall(void)
2981 {
2982   __builtin_ia32_vzeroall();
2983 }
2984 
2985 /// Zeroes the upper 128 bits (bits 255:128) of all YMM registers.
2986 ///
2987 /// \headerfile <x86intrin.h>
2988 ///
2989 /// This intrinsic corresponds to the <c> VZEROUPPER </c> instruction.
2990 static __inline void __attribute__((__always_inline__, __nodebug__, __target__("avx")))
_mm256_zeroupper(void)2991 _mm256_zeroupper(void)
2992 {
2993   __builtin_ia32_vzeroupper();
2994 }
2995 
2996 /* Vector load with broadcast */
2997 /// Loads a scalar single-precision floating point value from the
2998 ///    specified address pointed to by \a __a and broadcasts it to the elements
2999 ///    of a [4 x float] vector.
3000 ///
3001 /// \headerfile <x86intrin.h>
3002 ///
3003 /// This intrinsic corresponds to the <c> VBROADCASTSS </c> instruction.
3004 ///
3005 /// \param __a
3006 ///    The single-precision floating point value to be broadcast.
3007 /// \returns A 128-bit vector of [4 x float] whose 32-bit elements are set
3008 ///    equal to the broadcast value.
3009 static __inline __m128 __DEFAULT_FN_ATTRS128
_mm_broadcast_ss(float const * __a)3010 _mm_broadcast_ss(float const *__a)
3011 {
3012   struct __mm_broadcast_ss_struct {
3013     float __f;
3014   } __attribute__((__packed__, __may_alias__));
3015   float __f = ((const struct __mm_broadcast_ss_struct*)__a)->__f;
3016   return __extension__ (__m128){ __f, __f, __f, __f };
3017 }
3018 
3019 /// Loads a scalar double-precision floating point value from the
3020 ///    specified address pointed to by \a __a and broadcasts it to the elements
3021 ///    of a [4 x double] vector.
3022 ///
3023 /// \headerfile <x86intrin.h>
3024 ///
3025 /// This intrinsic corresponds to the <c> VBROADCASTSD </c> instruction.
3026 ///
3027 /// \param __a
3028 ///    The double-precision floating point value to be broadcast.
3029 /// \returns A 256-bit vector of [4 x double] whose 64-bit elements are set
3030 ///    equal to the broadcast value.
3031 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_broadcast_sd(double const * __a)3032 _mm256_broadcast_sd(double const *__a)
3033 {
3034   struct __mm256_broadcast_sd_struct {
3035     double __d;
3036   } __attribute__((__packed__, __may_alias__));
3037   double __d = ((const struct __mm256_broadcast_sd_struct*)__a)->__d;
3038   return __extension__ (__m256d)(__v4df){ __d, __d, __d, __d };
3039 }
3040 
3041 /// Loads a scalar single-precision floating point value from the
3042 ///    specified address pointed to by \a __a and broadcasts it to the elements
3043 ///    of a [8 x float] vector.
3044 ///
3045 /// \headerfile <x86intrin.h>
3046 ///
3047 /// This intrinsic corresponds to the <c> VBROADCASTSS </c> instruction.
3048 ///
3049 /// \param __a
3050 ///    The single-precision floating point value to be broadcast.
3051 /// \returns A 256-bit vector of [8 x float] whose 32-bit elements are set
3052 ///    equal to the broadcast value.
3053 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_broadcast_ss(float const * __a)3054 _mm256_broadcast_ss(float const *__a)
3055 {
3056   struct __mm256_broadcast_ss_struct {
3057     float __f;
3058   } __attribute__((__packed__, __may_alias__));
3059   float __f = ((const struct __mm256_broadcast_ss_struct*)__a)->__f;
3060   return __extension__ (__m256)(__v8sf){ __f, __f, __f, __f, __f, __f, __f, __f };
3061 }
3062 
3063 /// Loads the data from a 128-bit vector of [2 x double] from the
3064 ///    specified address pointed to by \a __a and broadcasts it to 128-bit
3065 ///    elements in a 256-bit vector of [4 x double].
3066 ///
3067 /// \headerfile <x86intrin.h>
3068 ///
3069 /// This intrinsic corresponds to the <c> VBROADCASTF128 </c> instruction.
3070 ///
3071 /// \param __a
3072 ///    The 128-bit vector of [2 x double] to be broadcast.
3073 /// \returns A 256-bit vector of [4 x double] whose 128-bit elements are set
3074 ///    equal to the broadcast value.
3075 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_broadcast_pd(__m128d const * __a)3076 _mm256_broadcast_pd(__m128d const *__a)
3077 {
3078   __m128d __b = _mm_loadu_pd((const double *)__a);
3079   return (__m256d)__builtin_shufflevector((__v2df)__b, (__v2df)__b,
3080                                           0, 1, 0, 1);
3081 }
3082 
3083 /// Loads the data from a 128-bit vector of [4 x float] from the
3084 ///    specified address pointed to by \a __a and broadcasts it to 128-bit
3085 ///    elements in a 256-bit vector of [8 x float].
3086 ///
3087 /// \headerfile <x86intrin.h>
3088 ///
3089 /// This intrinsic corresponds to the <c> VBROADCASTF128 </c> instruction.
3090 ///
3091 /// \param __a
3092 ///    The 128-bit vector of [4 x float] to be broadcast.
3093 /// \returns A 256-bit vector of [8 x float] whose 128-bit elements are set
3094 ///    equal to the broadcast value.
3095 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_broadcast_ps(__m128 const * __a)3096 _mm256_broadcast_ps(__m128 const *__a)
3097 {
3098   __m128 __b = _mm_loadu_ps((const float *)__a);
3099   return (__m256)__builtin_shufflevector((__v4sf)__b, (__v4sf)__b,
3100                                          0, 1, 2, 3, 0, 1, 2, 3);
3101 }
3102 
3103 /* SIMD load ops */
3104 /// Loads 4 double-precision floating point values from a 32-byte aligned
3105 ///    memory location pointed to by \a __p into a vector of [4 x double].
3106 ///
3107 /// \headerfile <x86intrin.h>
3108 ///
3109 /// This intrinsic corresponds to the <c> VMOVAPD </c> instruction.
3110 ///
3111 /// \param __p
3112 ///    A 32-byte aligned pointer to a memory location containing
3113 ///    double-precision floating point values.
3114 /// \returns A 256-bit vector of [4 x double] containing the moved values.
3115 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_load_pd(double const * __p)3116 _mm256_load_pd(double const *__p)
3117 {
3118   return *(const __m256d *)__p;
3119 }
3120 
3121 /// Loads 8 single-precision floating point values from a 32-byte aligned
3122 ///    memory location pointed to by \a __p into a vector of [8 x float].
3123 ///
3124 /// \headerfile <x86intrin.h>
3125 ///
3126 /// This intrinsic corresponds to the <c> VMOVAPS </c> instruction.
3127 ///
3128 /// \param __p
3129 ///    A 32-byte aligned pointer to a memory location containing float values.
3130 /// \returns A 256-bit vector of [8 x float] containing the moved values.
3131 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_load_ps(float const * __p)3132 _mm256_load_ps(float const *__p)
3133 {
3134   return *(const __m256 *)__p;
3135 }
3136 
3137 /// Loads 4 double-precision floating point values from an unaligned
3138 ///    memory location pointed to by \a __p into a vector of [4 x double].
3139 ///
3140 /// \headerfile <x86intrin.h>
3141 ///
3142 /// This intrinsic corresponds to the <c> VMOVUPD </c> instruction.
3143 ///
3144 /// \param __p
3145 ///    A pointer to a memory location containing double-precision floating
3146 ///    point values.
3147 /// \returns A 256-bit vector of [4 x double] containing the moved values.
3148 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_loadu_pd(double const * __p)3149 _mm256_loadu_pd(double const *__p)
3150 {
3151   struct __loadu_pd {
3152     __m256d_u __v;
3153   } __attribute__((__packed__, __may_alias__));
3154   return ((const struct __loadu_pd*)__p)->__v;
3155 }
3156 
3157 /// Loads 8 single-precision floating point values from an unaligned
3158 ///    memory location pointed to by \a __p into a vector of [8 x float].
3159 ///
3160 /// \headerfile <x86intrin.h>
3161 ///
3162 /// This intrinsic corresponds to the <c> VMOVUPS </c> instruction.
3163 ///
3164 /// \param __p
3165 ///    A pointer to a memory location containing single-precision floating
3166 ///    point values.
3167 /// \returns A 256-bit vector of [8 x float] containing the moved values.
3168 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_loadu_ps(float const * __p)3169 _mm256_loadu_ps(float const *__p)
3170 {
3171   struct __loadu_ps {
3172     __m256_u __v;
3173   } __attribute__((__packed__, __may_alias__));
3174   return ((const struct __loadu_ps*)__p)->__v;
3175 }
3176 
3177 /// Loads 256 bits of integer data from a 32-byte aligned memory
3178 ///    location pointed to by \a __p into elements of a 256-bit integer vector.
3179 ///
3180 /// \headerfile <x86intrin.h>
3181 ///
3182 /// This intrinsic corresponds to the <c> VMOVDQA </c> instruction.
3183 ///
3184 /// \param __p
3185 ///    A 32-byte aligned pointer to a 256-bit integer vector containing integer
3186 ///    values.
3187 /// \returns A 256-bit integer vector containing the moved values.
3188 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_load_si256(__m256i const * __p)3189 _mm256_load_si256(__m256i const *__p)
3190 {
3191   return *__p;
3192 }
3193 
3194 /// Loads 256 bits of integer data from an unaligned memory location
3195 ///    pointed to by \a __p into a 256-bit integer vector.
3196 ///
3197 /// \headerfile <x86intrin.h>
3198 ///
3199 /// This intrinsic corresponds to the <c> VMOVDQU </c> instruction.
3200 ///
3201 /// \param __p
3202 ///    A pointer to a 256-bit integer vector containing integer values.
3203 /// \returns A 256-bit integer vector containing the moved values.
3204 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_loadu_si256(__m256i_u const * __p)3205 _mm256_loadu_si256(__m256i_u const *__p)
3206 {
3207   struct __loadu_si256 {
3208     __m256i_u __v;
3209   } __attribute__((__packed__, __may_alias__));
3210   return ((const struct __loadu_si256*)__p)->__v;
3211 }
3212 
3213 /// Loads 256 bits of integer data from an unaligned memory location
3214 ///    pointed to by \a __p into a 256-bit integer vector. This intrinsic may
3215 ///    perform better than \c _mm256_loadu_si256 when the data crosses a cache
3216 ///    line boundary.
3217 ///
3218 /// \headerfile <x86intrin.h>
3219 ///
3220 /// This intrinsic corresponds to the <c> VLDDQU </c> instruction.
3221 ///
3222 /// \param __p
3223 ///    A pointer to a 256-bit integer vector containing integer values.
3224 /// \returns A 256-bit integer vector containing the moved values.
3225 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_lddqu_si256(__m256i_u const * __p)3226 _mm256_lddqu_si256(__m256i_u const *__p)
3227 {
3228   return (__m256i)__builtin_ia32_lddqu256((char const *)__p);
3229 }
3230 
3231 /* SIMD store ops */
3232 /// Stores double-precision floating point values from a 256-bit vector
3233 ///    of [4 x double] to a 32-byte aligned memory location pointed to by
3234 ///    \a __p.
3235 ///
3236 /// \headerfile <x86intrin.h>
3237 ///
3238 /// This intrinsic corresponds to the <c> VMOVAPD </c> instruction.
3239 ///
3240 /// \param __p
3241 ///    A 32-byte aligned pointer to a memory location that will receive the
3242 ///    double-precision floaing point values.
3243 /// \param __a
3244 ///    A 256-bit vector of [4 x double] containing the values to be moved.
3245 static __inline void __DEFAULT_FN_ATTRS
_mm256_store_pd(double * __p,__m256d __a)3246 _mm256_store_pd(double *__p, __m256d __a)
3247 {
3248   *(__m256d *)__p = __a;
3249 }
3250 
3251 /// Stores single-precision floating point values from a 256-bit vector
3252 ///    of [8 x float] to a 32-byte aligned memory location pointed to by \a __p.
3253 ///
3254 /// \headerfile <x86intrin.h>
3255 ///
3256 /// This intrinsic corresponds to the <c> VMOVAPS </c> instruction.
3257 ///
3258 /// \param __p
3259 ///    A 32-byte aligned pointer to a memory location that will receive the
3260 ///    float values.
3261 /// \param __a
3262 ///    A 256-bit vector of [8 x float] containing the values to be moved.
3263 static __inline void __DEFAULT_FN_ATTRS
_mm256_store_ps(float * __p,__m256 __a)3264 _mm256_store_ps(float *__p, __m256 __a)
3265 {
3266   *(__m256 *)__p = __a;
3267 }
3268 
3269 /// Stores double-precision floating point values from a 256-bit vector
3270 ///    of [4 x double] to an unaligned memory location pointed to by \a __p.
3271 ///
3272 /// \headerfile <x86intrin.h>
3273 ///
3274 /// This intrinsic corresponds to the <c> VMOVUPD </c> instruction.
3275 ///
3276 /// \param __p
3277 ///    A pointer to a memory location that will receive the double-precision
3278 ///    floating point values.
3279 /// \param __a
3280 ///    A 256-bit vector of [4 x double] containing the values to be moved.
3281 static __inline void __DEFAULT_FN_ATTRS
_mm256_storeu_pd(double * __p,__m256d __a)3282 _mm256_storeu_pd(double *__p, __m256d __a)
3283 {
3284   struct __storeu_pd {
3285     __m256d_u __v;
3286   } __attribute__((__packed__, __may_alias__));
3287   ((struct __storeu_pd*)__p)->__v = __a;
3288 }
3289 
3290 /// Stores single-precision floating point values from a 256-bit vector
3291 ///    of [8 x float] to an unaligned memory location pointed to by \a __p.
3292 ///
3293 /// \headerfile <x86intrin.h>
3294 ///
3295 /// This intrinsic corresponds to the <c> VMOVUPS </c> instruction.
3296 ///
3297 /// \param __p
3298 ///    A pointer to a memory location that will receive the float values.
3299 /// \param __a
3300 ///    A 256-bit vector of [8 x float] containing the values to be moved.
3301 static __inline void __DEFAULT_FN_ATTRS
_mm256_storeu_ps(float * __p,__m256 __a)3302 _mm256_storeu_ps(float *__p, __m256 __a)
3303 {
3304   struct __storeu_ps {
3305     __m256_u __v;
3306   } __attribute__((__packed__, __may_alias__));
3307   ((struct __storeu_ps*)__p)->__v = __a;
3308 }
3309 
3310 /// Stores integer values from a 256-bit integer vector to a 32-byte
3311 ///    aligned memory location pointed to by \a __p.
3312 ///
3313 /// \headerfile <x86intrin.h>
3314 ///
3315 /// This intrinsic corresponds to the <c> VMOVDQA </c> instruction.
3316 ///
3317 /// \param __p
3318 ///    A 32-byte aligned pointer to a memory location that will receive the
3319 ///    integer values.
3320 /// \param __a
3321 ///    A 256-bit integer vector containing the values to be moved.
3322 static __inline void __DEFAULT_FN_ATTRS
_mm256_store_si256(__m256i * __p,__m256i __a)3323 _mm256_store_si256(__m256i *__p, __m256i __a)
3324 {
3325   *__p = __a;
3326 }
3327 
3328 /// Stores integer values from a 256-bit integer vector to an unaligned
3329 ///    memory location pointed to by \a __p.
3330 ///
3331 /// \headerfile <x86intrin.h>
3332 ///
3333 /// This intrinsic corresponds to the <c> VMOVDQU </c> instruction.
3334 ///
3335 /// \param __p
3336 ///    A pointer to a memory location that will receive the integer values.
3337 /// \param __a
3338 ///    A 256-bit integer vector containing the values to be moved.
3339 static __inline void __DEFAULT_FN_ATTRS
_mm256_storeu_si256(__m256i_u * __p,__m256i __a)3340 _mm256_storeu_si256(__m256i_u *__p, __m256i __a)
3341 {
3342   struct __storeu_si256 {
3343     __m256i_u __v;
3344   } __attribute__((__packed__, __may_alias__));
3345   ((struct __storeu_si256*)__p)->__v = __a;
3346 }
3347 
3348 /* Conditional load ops */
3349 /// Conditionally loads double-precision floating point elements from a
3350 ///    memory location pointed to by \a __p into a 128-bit vector of
3351 ///    [2 x double], depending on the mask bits associated with each data
3352 ///    element.
3353 ///
3354 /// \headerfile <x86intrin.h>
3355 ///
3356 /// This intrinsic corresponds to the <c> VMASKMOVPD </c> instruction.
3357 ///
3358 /// \param __p
3359 ///    A pointer to a memory location that contains the double-precision
3360 ///    floating point values.
3361 /// \param __m
3362 ///    A 128-bit integer vector containing the mask. The most significant bit of
3363 ///    each data element represents the mask bits. If a mask bit is zero, the
3364 ///    corresponding value in the memory location is not loaded and the
3365 ///    corresponding field in the return value is set to zero.
3366 /// \returns A 128-bit vector of [2 x double] containing the loaded values.
3367 static __inline __m128d __DEFAULT_FN_ATTRS128
_mm_maskload_pd(double const * __p,__m128i __m)3368 _mm_maskload_pd(double const *__p, __m128i __m)
3369 {
3370   return (__m128d)__builtin_ia32_maskloadpd((const __v2df *)__p, (__v2di)__m);
3371 }
3372 
3373 /// Conditionally loads double-precision floating point elements from a
3374 ///    memory location pointed to by \a __p into a 256-bit vector of
3375 ///    [4 x double], depending on the mask bits associated with each data
3376 ///    element.
3377 ///
3378 /// \headerfile <x86intrin.h>
3379 ///
3380 /// This intrinsic corresponds to the <c> VMASKMOVPD </c> instruction.
3381 ///
3382 /// \param __p
3383 ///    A pointer to a memory location that contains the double-precision
3384 ///    floating point values.
3385 /// \param __m
3386 ///    A 256-bit integer vector of [4 x quadword] containing the mask. The most
3387 ///    significant bit of each quadword element represents the mask bits. If a
3388 ///    mask bit is zero, the corresponding value in the memory location is not
3389 ///    loaded and the corresponding field in the return value is set to zero.
3390 /// \returns A 256-bit vector of [4 x double] containing the loaded values.
3391 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_maskload_pd(double const * __p,__m256i __m)3392 _mm256_maskload_pd(double const *__p, __m256i __m)
3393 {
3394   return (__m256d)__builtin_ia32_maskloadpd256((const __v4df *)__p,
3395                                                (__v4di)__m);
3396 }
3397 
3398 /// Conditionally loads single-precision floating point elements from a
3399 ///    memory location pointed to by \a __p into a 128-bit vector of
3400 ///    [4 x float], depending on the mask bits associated with each data
3401 ///    element.
3402 ///
3403 /// \headerfile <x86intrin.h>
3404 ///
3405 /// This intrinsic corresponds to the <c> VMASKMOVPS </c> instruction.
3406 ///
3407 /// \param __p
3408 ///    A pointer to a memory location that contains the single-precision
3409 ///    floating point values.
3410 /// \param __m
3411 ///    A 128-bit integer vector containing the mask. The most significant bit of
3412 ///    each data element represents the mask bits. If a mask bit is zero, the
3413 ///    corresponding value in the memory location is not loaded and the
3414 ///    corresponding field in the return value is set to zero.
3415 /// \returns A 128-bit vector of [4 x float] containing the loaded values.
3416 static __inline __m128 __DEFAULT_FN_ATTRS128
_mm_maskload_ps(float const * __p,__m128i __m)3417 _mm_maskload_ps(float const *__p, __m128i __m)
3418 {
3419   return (__m128)__builtin_ia32_maskloadps((const __v4sf *)__p, (__v4si)__m);
3420 }
3421 
3422 /// Conditionally loads single-precision floating point elements from a
3423 ///    memory location pointed to by \a __p into a 256-bit vector of
3424 ///    [8 x float], depending on the mask bits associated with each data
3425 ///    element.
3426 ///
3427 /// \headerfile <x86intrin.h>
3428 ///
3429 /// This intrinsic corresponds to the <c> VMASKMOVPS </c> instruction.
3430 ///
3431 /// \param __p
3432 ///    A pointer to a memory location that contains the single-precision
3433 ///    floating point values.
3434 /// \param __m
3435 ///    A 256-bit integer vector of [8 x dword] containing the mask. The most
3436 ///    significant bit of each dword element represents the mask bits. If a mask
3437 ///    bit is zero, the corresponding value in the memory location is not loaded
3438 ///    and the corresponding field in the return value is set to zero.
3439 /// \returns A 256-bit vector of [8 x float] containing the loaded values.
3440 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_maskload_ps(float const * __p,__m256i __m)3441 _mm256_maskload_ps(float const *__p, __m256i __m)
3442 {
3443   return (__m256)__builtin_ia32_maskloadps256((const __v8sf *)__p, (__v8si)__m);
3444 }
3445 
3446 /* Conditional store ops */
3447 /// Moves single-precision floating point values from a 256-bit vector
3448 ///    of [8 x float] to a memory location pointed to by \a __p, according to
3449 ///    the specified mask.
3450 ///
3451 /// \headerfile <x86intrin.h>
3452 ///
3453 /// This intrinsic corresponds to the <c> VMASKMOVPS </c> instruction.
3454 ///
3455 /// \param __p
3456 ///    A pointer to a memory location that will receive the float values.
3457 /// \param __m
3458 ///    A 256-bit integer vector of [8 x dword] containing the mask. The most
3459 ///    significant bit of each dword element in the mask vector represents the
3460 ///    mask bits. If a mask bit is zero, the corresponding value from vector
3461 ///    \a __a is not stored and the corresponding field in the memory location
3462 ///    pointed to by \a __p is not changed.
3463 /// \param __a
3464 ///    A 256-bit vector of [8 x float] containing the values to be stored.
3465 static __inline void __DEFAULT_FN_ATTRS
_mm256_maskstore_ps(float * __p,__m256i __m,__m256 __a)3466 _mm256_maskstore_ps(float *__p, __m256i __m, __m256 __a)
3467 {
3468   __builtin_ia32_maskstoreps256((__v8sf *)__p, (__v8si)__m, (__v8sf)__a);
3469 }
3470 
3471 /// Moves double-precision values from a 128-bit vector of [2 x double]
3472 ///    to a memory location pointed to by \a __p, according to the specified
3473 ///    mask.
3474 ///
3475 /// \headerfile <x86intrin.h>
3476 ///
3477 /// This intrinsic corresponds to the <c> VMASKMOVPD </c> instruction.
3478 ///
3479 /// \param __p
3480 ///    A pointer to a memory location that will receive the float values.
3481 /// \param __m
3482 ///    A 128-bit integer vector containing the mask. The most significant bit of
3483 ///    each field in the mask vector represents the mask bits. If a mask bit is
3484 ///    zero, the corresponding value from vector \a __a is not stored and the
3485 ///    corresponding field in the memory location pointed to by \a __p is not
3486 ///    changed.
3487 /// \param __a
3488 ///    A 128-bit vector of [2 x double] containing the values to be stored.
3489 static __inline void __DEFAULT_FN_ATTRS128
_mm_maskstore_pd(double * __p,__m128i __m,__m128d __a)3490 _mm_maskstore_pd(double *__p, __m128i __m, __m128d __a)
3491 {
3492   __builtin_ia32_maskstorepd((__v2df *)__p, (__v2di)__m, (__v2df)__a);
3493 }
3494 
3495 /// Moves double-precision values from a 256-bit vector of [4 x double]
3496 ///    to a memory location pointed to by \a __p, according to the specified
3497 ///    mask.
3498 ///
3499 /// \headerfile <x86intrin.h>
3500 ///
3501 /// This intrinsic corresponds to the <c> VMASKMOVPD </c> instruction.
3502 ///
3503 /// \param __p
3504 ///    A pointer to a memory location that will receive the float values.
3505 /// \param __m
3506 ///    A 256-bit integer vector of [4 x quadword] containing the mask. The most
3507 ///    significant bit of each quadword element in the mask vector represents
3508 ///    the mask bits. If a mask bit is zero, the corresponding value from vector
3509 ///    __a is not stored and the corresponding field in the memory location
3510 ///    pointed to by \a __p is not changed.
3511 /// \param __a
3512 ///    A 256-bit vector of [4 x double] containing the values to be stored.
3513 static __inline void __DEFAULT_FN_ATTRS
_mm256_maskstore_pd(double * __p,__m256i __m,__m256d __a)3514 _mm256_maskstore_pd(double *__p, __m256i __m, __m256d __a)
3515 {
3516   __builtin_ia32_maskstorepd256((__v4df *)__p, (__v4di)__m, (__v4df)__a);
3517 }
3518 
3519 /// Moves single-precision floating point values from a 128-bit vector
3520 ///    of [4 x float] to a memory location pointed to by \a __p, according to
3521 ///    the specified mask.
3522 ///
3523 /// \headerfile <x86intrin.h>
3524 ///
3525 /// This intrinsic corresponds to the <c> VMASKMOVPS </c> instruction.
3526 ///
3527 /// \param __p
3528 ///    A pointer to a memory location that will receive the float values.
3529 /// \param __m
3530 ///    A 128-bit integer vector containing the mask. The most significant bit of
3531 ///    each field in the mask vector represents the mask bits. If a mask bit is
3532 ///    zero, the corresponding value from vector __a is not stored and the
3533 ///    corresponding field in the memory location pointed to by \a __p is not
3534 ///    changed.
3535 /// \param __a
3536 ///    A 128-bit vector of [4 x float] containing the values to be stored.
3537 static __inline void __DEFAULT_FN_ATTRS128
_mm_maskstore_ps(float * __p,__m128i __m,__m128 __a)3538 _mm_maskstore_ps(float *__p, __m128i __m, __m128 __a)
3539 {
3540   __builtin_ia32_maskstoreps((__v4sf *)__p, (__v4si)__m, (__v4sf)__a);
3541 }
3542 
3543 /* Cacheability support ops */
3544 /// Moves integer data from a 256-bit integer vector to a 32-byte
3545 ///    aligned memory location. To minimize caching, the data is flagged as
3546 ///    non-temporal (unlikely to be used again soon).
3547 ///
3548 /// \headerfile <x86intrin.h>
3549 ///
3550 /// This intrinsic corresponds to the <c> VMOVNTDQ </c> instruction.
3551 ///
3552 /// \param __a
3553 ///    A pointer to a 32-byte aligned memory location that will receive the
3554 ///    integer values.
3555 /// \param __b
3556 ///    A 256-bit integer vector containing the values to be moved.
3557 static __inline void __DEFAULT_FN_ATTRS
_mm256_stream_si256(void * __a,__m256i __b)3558 _mm256_stream_si256(void *__a, __m256i __b)
3559 {
3560   typedef __v4di __v4di_aligned __attribute__((aligned(32)));
3561   __builtin_nontemporal_store((__v4di_aligned)__b, (__v4di_aligned*)__a);
3562 }
3563 
3564 /// Moves double-precision values from a 256-bit vector of [4 x double]
3565 ///    to a 32-byte aligned memory location. To minimize caching, the data is
3566 ///    flagged as non-temporal (unlikely to be used again soon).
3567 ///
3568 /// \headerfile <x86intrin.h>
3569 ///
3570 /// This intrinsic corresponds to the <c> VMOVNTPD </c> instruction.
3571 ///
3572 /// \param __a
3573 ///    A pointer to a 32-byte aligned memory location that will receive the
3574 ///    double-precision floating-point values.
3575 /// \param __b
3576 ///    A 256-bit vector of [4 x double] containing the values to be moved.
3577 static __inline void __DEFAULT_FN_ATTRS
_mm256_stream_pd(void * __a,__m256d __b)3578 _mm256_stream_pd(void *__a, __m256d __b)
3579 {
3580   typedef __v4df __v4df_aligned __attribute__((aligned(32)));
3581   __builtin_nontemporal_store((__v4df_aligned)__b, (__v4df_aligned*)__a);
3582 }
3583 
3584 /// Moves single-precision floating point values from a 256-bit vector
3585 ///    of [8 x float] to a 32-byte aligned memory location. To minimize
3586 ///    caching, the data is flagged as non-temporal (unlikely to be used again
3587 ///    soon).
3588 ///
3589 /// \headerfile <x86intrin.h>
3590 ///
3591 /// This intrinsic corresponds to the <c> VMOVNTPS </c> instruction.
3592 ///
3593 /// \param __p
3594 ///    A pointer to a 32-byte aligned memory location that will receive the
3595 ///    single-precision floating point values.
3596 /// \param __a
3597 ///    A 256-bit vector of [8 x float] containing the values to be moved.
3598 static __inline void __DEFAULT_FN_ATTRS
_mm256_stream_ps(void * __p,__m256 __a)3599 _mm256_stream_ps(void *__p, __m256 __a)
3600 {
3601   typedef __v8sf __v8sf_aligned __attribute__((aligned(32)));
3602   __builtin_nontemporal_store((__v8sf_aligned)__a, (__v8sf_aligned*)__p);
3603 }
3604 
3605 /* Create vectors */
3606 /// Create a 256-bit vector of [4 x double] with undefined values.
3607 ///
3608 /// \headerfile <x86intrin.h>
3609 ///
3610 /// This intrinsic has no corresponding instruction.
3611 ///
3612 /// \returns A 256-bit vector of [4 x double] containing undefined values.
3613 static __inline__ __m256d __DEFAULT_FN_ATTRS
_mm256_undefined_pd(void)3614 _mm256_undefined_pd(void)
3615 {
3616   return (__m256d)__builtin_ia32_undef256();
3617 }
3618 
3619 /// Create a 256-bit vector of [8 x float] with undefined values.
3620 ///
3621 /// \headerfile <x86intrin.h>
3622 ///
3623 /// This intrinsic has no corresponding instruction.
3624 ///
3625 /// \returns A 256-bit vector of [8 x float] containing undefined values.
3626 static __inline__ __m256 __DEFAULT_FN_ATTRS
_mm256_undefined_ps(void)3627 _mm256_undefined_ps(void)
3628 {
3629   return (__m256)__builtin_ia32_undef256();
3630 }
3631 
3632 /// Create a 256-bit integer vector with undefined values.
3633 ///
3634 /// \headerfile <x86intrin.h>
3635 ///
3636 /// This intrinsic has no corresponding instruction.
3637 ///
3638 /// \returns A 256-bit integer vector containing undefined values.
3639 static __inline__ __m256i __DEFAULT_FN_ATTRS
_mm256_undefined_si256(void)3640 _mm256_undefined_si256(void)
3641 {
3642   return (__m256i)__builtin_ia32_undef256();
3643 }
3644 
3645 /// Constructs a 256-bit floating-point vector of [4 x double]
3646 ///    initialized with the specified double-precision floating-point values.
3647 ///
3648 /// \headerfile <x86intrin.h>
3649 ///
3650 /// This intrinsic corresponds to the <c> VUNPCKLPD+VINSERTF128 </c>
3651 ///   instruction.
3652 ///
3653 /// \param __a
3654 ///    A double-precision floating-point value used to initialize bits [255:192]
3655 ///    of the result.
3656 /// \param __b
3657 ///    A double-precision floating-point value used to initialize bits [191:128]
3658 ///    of the result.
3659 /// \param __c
3660 ///    A double-precision floating-point value used to initialize bits [127:64]
3661 ///    of the result.
3662 /// \param __d
3663 ///    A double-precision floating-point value used to initialize bits [63:0]
3664 ///    of the result.
3665 /// \returns An initialized 256-bit floating-point vector of [4 x double].
3666 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_set_pd(double __a,double __b,double __c,double __d)3667 _mm256_set_pd(double __a, double __b, double __c, double __d)
3668 {
3669   return __extension__ (__m256d){ __d, __c, __b, __a };
3670 }
3671 
3672 /// Constructs a 256-bit floating-point vector of [8 x float] initialized
3673 ///    with the specified single-precision floating-point values.
3674 ///
3675 /// \headerfile <x86intrin.h>
3676 ///
3677 /// This intrinsic is a utility function and does not correspond to a specific
3678 ///   instruction.
3679 ///
3680 /// \param __a
3681 ///    A single-precision floating-point value used to initialize bits [255:224]
3682 ///    of the result.
3683 /// \param __b
3684 ///    A single-precision floating-point value used to initialize bits [223:192]
3685 ///    of the result.
3686 /// \param __c
3687 ///    A single-precision floating-point value used to initialize bits [191:160]
3688 ///    of the result.
3689 /// \param __d
3690 ///    A single-precision floating-point value used to initialize bits [159:128]
3691 ///    of the result.
3692 /// \param __e
3693 ///    A single-precision floating-point value used to initialize bits [127:96]
3694 ///    of the result.
3695 /// \param __f
3696 ///    A single-precision floating-point value used to initialize bits [95:64]
3697 ///    of the result.
3698 /// \param __g
3699 ///    A single-precision floating-point value used to initialize bits [63:32]
3700 ///    of the result.
3701 /// \param __h
3702 ///    A single-precision floating-point value used to initialize bits [31:0]
3703 ///    of the result.
3704 /// \returns An initialized 256-bit floating-point vector of [8 x float].
3705 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_set_ps(float __a,float __b,float __c,float __d,float __e,float __f,float __g,float __h)3706 _mm256_set_ps(float __a, float __b, float __c, float __d,
3707               float __e, float __f, float __g, float __h)
3708 {
3709   return __extension__ (__m256){ __h, __g, __f, __e, __d, __c, __b, __a };
3710 }
3711 
3712 /// Constructs a 256-bit integer vector initialized with the specified
3713 ///    32-bit integral values.
3714 ///
3715 /// \headerfile <x86intrin.h>
3716 ///
3717 /// This intrinsic is a utility function and does not correspond to a specific
3718 ///   instruction.
3719 ///
3720 /// \param __i0
3721 ///    A 32-bit integral value used to initialize bits [255:224] of the result.
3722 /// \param __i1
3723 ///    A 32-bit integral value used to initialize bits [223:192] of the result.
3724 /// \param __i2
3725 ///    A 32-bit integral value used to initialize bits [191:160] of the result.
3726 /// \param __i3
3727 ///    A 32-bit integral value used to initialize bits [159:128] of the result.
3728 /// \param __i4
3729 ///    A 32-bit integral value used to initialize bits [127:96] of the result.
3730 /// \param __i5
3731 ///    A 32-bit integral value used to initialize bits [95:64] of the result.
3732 /// \param __i6
3733 ///    A 32-bit integral value used to initialize bits [63:32] of the result.
3734 /// \param __i7
3735 ///    A 32-bit integral value used to initialize bits [31:0] of the result.
3736 /// \returns An initialized 256-bit integer vector.
3737 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set_epi32(int __i0,int __i1,int __i2,int __i3,int __i4,int __i5,int __i6,int __i7)3738 _mm256_set_epi32(int __i0, int __i1, int __i2, int __i3,
3739                  int __i4, int __i5, int __i6, int __i7)
3740 {
3741   return __extension__ (__m256i)(__v8si){ __i7, __i6, __i5, __i4, __i3, __i2, __i1, __i0 };
3742 }
3743 
3744 /// Constructs a 256-bit integer vector initialized with the specified
3745 ///    16-bit integral values.
3746 ///
3747 /// \headerfile <x86intrin.h>
3748 ///
3749 /// This intrinsic is a utility function and does not correspond to a specific
3750 ///   instruction.
3751 ///
3752 /// \param __w15
3753 ///    A 16-bit integral value used to initialize bits [255:240] of the result.
3754 /// \param __w14
3755 ///    A 16-bit integral value used to initialize bits [239:224] of the result.
3756 /// \param __w13
3757 ///    A 16-bit integral value used to initialize bits [223:208] of the result.
3758 /// \param __w12
3759 ///    A 16-bit integral value used to initialize bits [207:192] of the result.
3760 /// \param __w11
3761 ///    A 16-bit integral value used to initialize bits [191:176] of the result.
3762 /// \param __w10
3763 ///    A 16-bit integral value used to initialize bits [175:160] of the result.
3764 /// \param __w09
3765 ///    A 16-bit integral value used to initialize bits [159:144] of the result.
3766 /// \param __w08
3767 ///    A 16-bit integral value used to initialize bits [143:128] of the result.
3768 /// \param __w07
3769 ///    A 16-bit integral value used to initialize bits [127:112] of the result.
3770 /// \param __w06
3771 ///    A 16-bit integral value used to initialize bits [111:96] of the result.
3772 /// \param __w05
3773 ///    A 16-bit integral value used to initialize bits [95:80] of the result.
3774 /// \param __w04
3775 ///    A 16-bit integral value used to initialize bits [79:64] of the result.
3776 /// \param __w03
3777 ///    A 16-bit integral value used to initialize bits [63:48] of the result.
3778 /// \param __w02
3779 ///    A 16-bit integral value used to initialize bits [47:32] of the result.
3780 /// \param __w01
3781 ///    A 16-bit integral value used to initialize bits [31:16] of the result.
3782 /// \param __w00
3783 ///    A 16-bit integral value used to initialize bits [15:0] of the result.
3784 /// \returns An initialized 256-bit integer vector.
3785 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set_epi16(short __w15,short __w14,short __w13,short __w12,short __w11,short __w10,short __w09,short __w08,short __w07,short __w06,short __w05,short __w04,short __w03,short __w02,short __w01,short __w00)3786 _mm256_set_epi16(short __w15, short __w14, short __w13, short __w12,
3787                  short __w11, short __w10, short __w09, short __w08,
3788                  short __w07, short __w06, short __w05, short __w04,
3789                  short __w03, short __w02, short __w01, short __w00)
3790 {
3791   return __extension__ (__m256i)(__v16hi){ __w00, __w01, __w02, __w03, __w04, __w05, __w06,
3792     __w07, __w08, __w09, __w10, __w11, __w12, __w13, __w14, __w15 };
3793 }
3794 
3795 /// Constructs a 256-bit integer vector initialized with the specified
3796 ///    8-bit integral values.
3797 ///
3798 /// \headerfile <x86intrin.h>
3799 ///
3800 /// This intrinsic is a utility function and does not correspond to a specific
3801 ///   instruction.
3802 ///
3803 /// \param __b31
3804 ///    An 8-bit integral value used to initialize bits [255:248] of the result.
3805 /// \param __b30
3806 ///    An 8-bit integral value used to initialize bits [247:240] of the result.
3807 /// \param __b29
3808 ///    An 8-bit integral value used to initialize bits [239:232] of the result.
3809 /// \param __b28
3810 ///    An 8-bit integral value used to initialize bits [231:224] of the result.
3811 /// \param __b27
3812 ///    An 8-bit integral value used to initialize bits [223:216] of the result.
3813 /// \param __b26
3814 ///    An 8-bit integral value used to initialize bits [215:208] of the result.
3815 /// \param __b25
3816 ///    An 8-bit integral value used to initialize bits [207:200] of the result.
3817 /// \param __b24
3818 ///    An 8-bit integral value used to initialize bits [199:192] of the result.
3819 /// \param __b23
3820 ///    An 8-bit integral value used to initialize bits [191:184] of the result.
3821 /// \param __b22
3822 ///    An 8-bit integral value used to initialize bits [183:176] of the result.
3823 /// \param __b21
3824 ///    An 8-bit integral value used to initialize bits [175:168] of the result.
3825 /// \param __b20
3826 ///    An 8-bit integral value used to initialize bits [167:160] of the result.
3827 /// \param __b19
3828 ///    An 8-bit integral value used to initialize bits [159:152] of the result.
3829 /// \param __b18
3830 ///    An 8-bit integral value used to initialize bits [151:144] of the result.
3831 /// \param __b17
3832 ///    An 8-bit integral value used to initialize bits [143:136] of the result.
3833 /// \param __b16
3834 ///    An 8-bit integral value used to initialize bits [135:128] of the result.
3835 /// \param __b15
3836 ///    An 8-bit integral value used to initialize bits [127:120] of the result.
3837 /// \param __b14
3838 ///    An 8-bit integral value used to initialize bits [119:112] of the result.
3839 /// \param __b13
3840 ///    An 8-bit integral value used to initialize bits [111:104] of the result.
3841 /// \param __b12
3842 ///    An 8-bit integral value used to initialize bits [103:96] of the result.
3843 /// \param __b11
3844 ///    An 8-bit integral value used to initialize bits [95:88] of the result.
3845 /// \param __b10
3846 ///    An 8-bit integral value used to initialize bits [87:80] of the result.
3847 /// \param __b09
3848 ///    An 8-bit integral value used to initialize bits [79:72] of the result.
3849 /// \param __b08
3850 ///    An 8-bit integral value used to initialize bits [71:64] of the result.
3851 /// \param __b07
3852 ///    An 8-bit integral value used to initialize bits [63:56] of the result.
3853 /// \param __b06
3854 ///    An 8-bit integral value used to initialize bits [55:48] of the result.
3855 /// \param __b05
3856 ///    An 8-bit integral value used to initialize bits [47:40] of the result.
3857 /// \param __b04
3858 ///    An 8-bit integral value used to initialize bits [39:32] of the result.
3859 /// \param __b03
3860 ///    An 8-bit integral value used to initialize bits [31:24] of the result.
3861 /// \param __b02
3862 ///    An 8-bit integral value used to initialize bits [23:16] of the result.
3863 /// \param __b01
3864 ///    An 8-bit integral value used to initialize bits [15:8] of the result.
3865 /// \param __b00
3866 ///    An 8-bit integral value used to initialize bits [7:0] of the result.
3867 /// \returns An initialized 256-bit integer vector.
3868 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set_epi8(char __b31,char __b30,char __b29,char __b28,char __b27,char __b26,char __b25,char __b24,char __b23,char __b22,char __b21,char __b20,char __b19,char __b18,char __b17,char __b16,char __b15,char __b14,char __b13,char __b12,char __b11,char __b10,char __b09,char __b08,char __b07,char __b06,char __b05,char __b04,char __b03,char __b02,char __b01,char __b00)3869 _mm256_set_epi8(char __b31, char __b30, char __b29, char __b28,
3870                 char __b27, char __b26, char __b25, char __b24,
3871                 char __b23, char __b22, char __b21, char __b20,
3872                 char __b19, char __b18, char __b17, char __b16,
3873                 char __b15, char __b14, char __b13, char __b12,
3874                 char __b11, char __b10, char __b09, char __b08,
3875                 char __b07, char __b06, char __b05, char __b04,
3876                 char __b03, char __b02, char __b01, char __b00)
3877 {
3878   return __extension__ (__m256i)(__v32qi){
3879     __b00, __b01, __b02, __b03, __b04, __b05, __b06, __b07,
3880     __b08, __b09, __b10, __b11, __b12, __b13, __b14, __b15,
3881     __b16, __b17, __b18, __b19, __b20, __b21, __b22, __b23,
3882     __b24, __b25, __b26, __b27, __b28, __b29, __b30, __b31
3883   };
3884 }
3885 
3886 /// Constructs a 256-bit integer vector initialized with the specified
3887 ///    64-bit integral values.
3888 ///
3889 /// \headerfile <x86intrin.h>
3890 ///
3891 /// This intrinsic corresponds to the <c> VPUNPCKLQDQ+VINSERTF128 </c>
3892 ///   instruction.
3893 ///
3894 /// \param __a
3895 ///    A 64-bit integral value used to initialize bits [255:192] of the result.
3896 /// \param __b
3897 ///    A 64-bit integral value used to initialize bits [191:128] of the result.
3898 /// \param __c
3899 ///    A 64-bit integral value used to initialize bits [127:64] of the result.
3900 /// \param __d
3901 ///    A 64-bit integral value used to initialize bits [63:0] of the result.
3902 /// \returns An initialized 256-bit integer vector.
3903 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set_epi64x(long long __a,long long __b,long long __c,long long __d)3904 _mm256_set_epi64x(long long __a, long long __b, long long __c, long long __d)
3905 {
3906   return __extension__ (__m256i)(__v4di){ __d, __c, __b, __a };
3907 }
3908 
3909 /* Create vectors with elements in reverse order */
3910 /// Constructs a 256-bit floating-point vector of [4 x double],
3911 ///    initialized in reverse order with the specified double-precision
3912 ///    floating-point values.
3913 ///
3914 /// \headerfile <x86intrin.h>
3915 ///
3916 /// This intrinsic corresponds to the <c> VUNPCKLPD+VINSERTF128 </c>
3917 ///   instruction.
3918 ///
3919 /// \param __a
3920 ///    A double-precision floating-point value used to initialize bits [63:0]
3921 ///    of the result.
3922 /// \param __b
3923 ///    A double-precision floating-point value used to initialize bits [127:64]
3924 ///    of the result.
3925 /// \param __c
3926 ///    A double-precision floating-point value used to initialize bits [191:128]
3927 ///    of the result.
3928 /// \param __d
3929 ///    A double-precision floating-point value used to initialize bits [255:192]
3930 ///    of the result.
3931 /// \returns An initialized 256-bit floating-point vector of [4 x double].
3932 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_setr_pd(double __a,double __b,double __c,double __d)3933 _mm256_setr_pd(double __a, double __b, double __c, double __d)
3934 {
3935   return _mm256_set_pd(__d, __c, __b, __a);
3936 }
3937 
3938 /// Constructs a 256-bit floating-point vector of [8 x float],
3939 ///    initialized in reverse order with the specified single-precision
3940 ///    float-point values.
3941 ///
3942 /// \headerfile <x86intrin.h>
3943 ///
3944 /// This intrinsic is a utility function and does not correspond to a specific
3945 ///   instruction.
3946 ///
3947 /// \param __a
3948 ///    A single-precision floating-point value used to initialize bits [31:0]
3949 ///    of the result.
3950 /// \param __b
3951 ///    A single-precision floating-point value used to initialize bits [63:32]
3952 ///    of the result.
3953 /// \param __c
3954 ///    A single-precision floating-point value used to initialize bits [95:64]
3955 ///    of the result.
3956 /// \param __d
3957 ///    A single-precision floating-point value used to initialize bits [127:96]
3958 ///    of the result.
3959 /// \param __e
3960 ///    A single-precision floating-point value used to initialize bits [159:128]
3961 ///    of the result.
3962 /// \param __f
3963 ///    A single-precision floating-point value used to initialize bits [191:160]
3964 ///    of the result.
3965 /// \param __g
3966 ///    A single-precision floating-point value used to initialize bits [223:192]
3967 ///    of the result.
3968 /// \param __h
3969 ///    A single-precision floating-point value used to initialize bits [255:224]
3970 ///    of the result.
3971 /// \returns An initialized 256-bit floating-point vector of [8 x float].
3972 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_setr_ps(float __a,float __b,float __c,float __d,float __e,float __f,float __g,float __h)3973 _mm256_setr_ps(float __a, float __b, float __c, float __d,
3974                float __e, float __f, float __g, float __h)
3975 {
3976   return _mm256_set_ps(__h, __g, __f, __e, __d, __c, __b, __a);
3977 }
3978 
3979 /// Constructs a 256-bit integer vector, initialized in reverse order
3980 ///    with the specified 32-bit integral values.
3981 ///
3982 /// \headerfile <x86intrin.h>
3983 ///
3984 /// This intrinsic is a utility function and does not correspond to a specific
3985 ///   instruction.
3986 ///
3987 /// \param __i0
3988 ///    A 32-bit integral value used to initialize bits [31:0] of the result.
3989 /// \param __i1
3990 ///    A 32-bit integral value used to initialize bits [63:32] of the result.
3991 /// \param __i2
3992 ///    A 32-bit integral value used to initialize bits [95:64] of the result.
3993 /// \param __i3
3994 ///    A 32-bit integral value used to initialize bits [127:96] of the result.
3995 /// \param __i4
3996 ///    A 32-bit integral value used to initialize bits [159:128] of the result.
3997 /// \param __i5
3998 ///    A 32-bit integral value used to initialize bits [191:160] of the result.
3999 /// \param __i6
4000 ///    A 32-bit integral value used to initialize bits [223:192] of the result.
4001 /// \param __i7
4002 ///    A 32-bit integral value used to initialize bits [255:224] of the result.
4003 /// \returns An initialized 256-bit integer vector.
4004 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_setr_epi32(int __i0,int __i1,int __i2,int __i3,int __i4,int __i5,int __i6,int __i7)4005 _mm256_setr_epi32(int __i0, int __i1, int __i2, int __i3,
4006                   int __i4, int __i5, int __i6, int __i7)
4007 {
4008   return _mm256_set_epi32(__i7, __i6, __i5, __i4, __i3, __i2, __i1, __i0);
4009 }
4010 
4011 /// Constructs a 256-bit integer vector, initialized in reverse order
4012 ///    with the specified 16-bit integral values.
4013 ///
4014 /// \headerfile <x86intrin.h>
4015 ///
4016 /// This intrinsic is a utility function and does not correspond to a specific
4017 ///   instruction.
4018 ///
4019 /// \param __w15
4020 ///    A 16-bit integral value used to initialize bits [15:0] of the result.
4021 /// \param __w14
4022 ///    A 16-bit integral value used to initialize bits [31:16] of the result.
4023 /// \param __w13
4024 ///    A 16-bit integral value used to initialize bits [47:32] of the result.
4025 /// \param __w12
4026 ///    A 16-bit integral value used to initialize bits [63:48] of the result.
4027 /// \param __w11
4028 ///    A 16-bit integral value used to initialize bits [79:64] of the result.
4029 /// \param __w10
4030 ///    A 16-bit integral value used to initialize bits [95:80] of the result.
4031 /// \param __w09
4032 ///    A 16-bit integral value used to initialize bits [111:96] of the result.
4033 /// \param __w08
4034 ///    A 16-bit integral value used to initialize bits [127:112] of the result.
4035 /// \param __w07
4036 ///    A 16-bit integral value used to initialize bits [143:128] of the result.
4037 /// \param __w06
4038 ///    A 16-bit integral value used to initialize bits [159:144] of the result.
4039 /// \param __w05
4040 ///    A 16-bit integral value used to initialize bits [175:160] of the result.
4041 /// \param __w04
4042 ///    A 16-bit integral value used to initialize bits [191:176] of the result.
4043 /// \param __w03
4044 ///    A 16-bit integral value used to initialize bits [207:192] of the result.
4045 /// \param __w02
4046 ///    A 16-bit integral value used to initialize bits [223:208] of the result.
4047 /// \param __w01
4048 ///    A 16-bit integral value used to initialize bits [239:224] of the result.
4049 /// \param __w00
4050 ///    A 16-bit integral value used to initialize bits [255:240] of the result.
4051 /// \returns An initialized 256-bit integer vector.
4052 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_setr_epi16(short __w15,short __w14,short __w13,short __w12,short __w11,short __w10,short __w09,short __w08,short __w07,short __w06,short __w05,short __w04,short __w03,short __w02,short __w01,short __w00)4053 _mm256_setr_epi16(short __w15, short __w14, short __w13, short __w12,
4054        short __w11, short __w10, short __w09, short __w08,
4055        short __w07, short __w06, short __w05, short __w04,
4056        short __w03, short __w02, short __w01, short __w00)
4057 {
4058   return _mm256_set_epi16(__w00, __w01, __w02, __w03,
4059                           __w04, __w05, __w06, __w07,
4060                           __w08, __w09, __w10, __w11,
4061                           __w12, __w13, __w14, __w15);
4062 }
4063 
4064 /// Constructs a 256-bit integer vector, initialized in reverse order
4065 ///    with the specified 8-bit integral values.
4066 ///
4067 /// \headerfile <x86intrin.h>
4068 ///
4069 /// This intrinsic is a utility function and does not correspond to a specific
4070 ///   instruction.
4071 ///
4072 /// \param __b31
4073 ///    An 8-bit integral value used to initialize bits [7:0] of the result.
4074 /// \param __b30
4075 ///    An 8-bit integral value used to initialize bits [15:8] of the result.
4076 /// \param __b29
4077 ///    An 8-bit integral value used to initialize bits [23:16] of the result.
4078 /// \param __b28
4079 ///    An 8-bit integral value used to initialize bits [31:24] of the result.
4080 /// \param __b27
4081 ///    An 8-bit integral value used to initialize bits [39:32] of the result.
4082 /// \param __b26
4083 ///    An 8-bit integral value used to initialize bits [47:40] of the result.
4084 /// \param __b25
4085 ///    An 8-bit integral value used to initialize bits [55:48] of the result.
4086 /// \param __b24
4087 ///    An 8-bit integral value used to initialize bits [63:56] of the result.
4088 /// \param __b23
4089 ///    An 8-bit integral value used to initialize bits [71:64] of the result.
4090 /// \param __b22
4091 ///    An 8-bit integral value used to initialize bits [79:72] of the result.
4092 /// \param __b21
4093 ///    An 8-bit integral value used to initialize bits [87:80] of the result.
4094 /// \param __b20
4095 ///    An 8-bit integral value used to initialize bits [95:88] of the result.
4096 /// \param __b19
4097 ///    An 8-bit integral value used to initialize bits [103:96] of the result.
4098 /// \param __b18
4099 ///    An 8-bit integral value used to initialize bits [111:104] of the result.
4100 /// \param __b17
4101 ///    An 8-bit integral value used to initialize bits [119:112] of the result.
4102 /// \param __b16
4103 ///    An 8-bit integral value used to initialize bits [127:120] of the result.
4104 /// \param __b15
4105 ///    An 8-bit integral value used to initialize bits [135:128] of the result.
4106 /// \param __b14
4107 ///    An 8-bit integral value used to initialize bits [143:136] of the result.
4108 /// \param __b13
4109 ///    An 8-bit integral value used to initialize bits [151:144] of the result.
4110 /// \param __b12
4111 ///    An 8-bit integral value used to initialize bits [159:152] of the result.
4112 /// \param __b11
4113 ///    An 8-bit integral value used to initialize bits [167:160] of the result.
4114 /// \param __b10
4115 ///    An 8-bit integral value used to initialize bits [175:168] of the result.
4116 /// \param __b09
4117 ///    An 8-bit integral value used to initialize bits [183:176] of the result.
4118 /// \param __b08
4119 ///    An 8-bit integral value used to initialize bits [191:184] of the result.
4120 /// \param __b07
4121 ///    An 8-bit integral value used to initialize bits [199:192] of the result.
4122 /// \param __b06
4123 ///    An 8-bit integral value used to initialize bits [207:200] of the result.
4124 /// \param __b05
4125 ///    An 8-bit integral value used to initialize bits [215:208] of the result.
4126 /// \param __b04
4127 ///    An 8-bit integral value used to initialize bits [223:216] of the result.
4128 /// \param __b03
4129 ///    An 8-bit integral value used to initialize bits [231:224] of the result.
4130 /// \param __b02
4131 ///    An 8-bit integral value used to initialize bits [239:232] of the result.
4132 /// \param __b01
4133 ///    An 8-bit integral value used to initialize bits [247:240] of the result.
4134 /// \param __b00
4135 ///    An 8-bit integral value used to initialize bits [255:248] of the result.
4136 /// \returns An initialized 256-bit integer vector.
4137 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_setr_epi8(char __b31,char __b30,char __b29,char __b28,char __b27,char __b26,char __b25,char __b24,char __b23,char __b22,char __b21,char __b20,char __b19,char __b18,char __b17,char __b16,char __b15,char __b14,char __b13,char __b12,char __b11,char __b10,char __b09,char __b08,char __b07,char __b06,char __b05,char __b04,char __b03,char __b02,char __b01,char __b00)4138 _mm256_setr_epi8(char __b31, char __b30, char __b29, char __b28,
4139                  char __b27, char __b26, char __b25, char __b24,
4140                  char __b23, char __b22, char __b21, char __b20,
4141                  char __b19, char __b18, char __b17, char __b16,
4142                  char __b15, char __b14, char __b13, char __b12,
4143                  char __b11, char __b10, char __b09, char __b08,
4144                  char __b07, char __b06, char __b05, char __b04,
4145                  char __b03, char __b02, char __b01, char __b00)
4146 {
4147   return _mm256_set_epi8(__b00, __b01, __b02, __b03, __b04, __b05, __b06, __b07,
4148                          __b08, __b09, __b10, __b11, __b12, __b13, __b14, __b15,
4149                          __b16, __b17, __b18, __b19, __b20, __b21, __b22, __b23,
4150                          __b24, __b25, __b26, __b27, __b28, __b29, __b30, __b31);
4151 }
4152 
4153 /// Constructs a 256-bit integer vector, initialized in reverse order
4154 ///    with the specified 64-bit integral values.
4155 ///
4156 /// \headerfile <x86intrin.h>
4157 ///
4158 /// This intrinsic corresponds to the <c> VPUNPCKLQDQ+VINSERTF128 </c>
4159 ///   instruction.
4160 ///
4161 /// \param __a
4162 ///    A 64-bit integral value used to initialize bits [63:0] of the result.
4163 /// \param __b
4164 ///    A 64-bit integral value used to initialize bits [127:64] of the result.
4165 /// \param __c
4166 ///    A 64-bit integral value used to initialize bits [191:128] of the result.
4167 /// \param __d
4168 ///    A 64-bit integral value used to initialize bits [255:192] of the result.
4169 /// \returns An initialized 256-bit integer vector.
4170 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_setr_epi64x(long long __a,long long __b,long long __c,long long __d)4171 _mm256_setr_epi64x(long long __a, long long __b, long long __c, long long __d)
4172 {
4173   return _mm256_set_epi64x(__d, __c, __b, __a);
4174 }
4175 
4176 /* Create vectors with repeated elements */
4177 /// Constructs a 256-bit floating-point vector of [4 x double], with each
4178 ///    of the four double-precision floating-point vector elements set to the
4179 ///    specified double-precision floating-point value.
4180 ///
4181 /// \headerfile <x86intrin.h>
4182 ///
4183 /// This intrinsic corresponds to the <c> VMOVDDUP+VINSERTF128 </c> instruction.
4184 ///
4185 /// \param __w
4186 ///    A double-precision floating-point value used to initialize each vector
4187 ///    element of the result.
4188 /// \returns An initialized 256-bit floating-point vector of [4 x double].
4189 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_set1_pd(double __w)4190 _mm256_set1_pd(double __w)
4191 {
4192   return _mm256_set_pd(__w, __w, __w, __w);
4193 }
4194 
4195 /// Constructs a 256-bit floating-point vector of [8 x float], with each
4196 ///    of the eight single-precision floating-point vector elements set to the
4197 ///    specified single-precision floating-point value.
4198 ///
4199 /// \headerfile <x86intrin.h>
4200 ///
4201 /// This intrinsic corresponds to the <c> VPERMILPS+VINSERTF128 </c>
4202 ///   instruction.
4203 ///
4204 /// \param __w
4205 ///    A single-precision floating-point value used to initialize each vector
4206 ///    element of the result.
4207 /// \returns An initialized 256-bit floating-point vector of [8 x float].
4208 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_set1_ps(float __w)4209 _mm256_set1_ps(float __w)
4210 {
4211   return _mm256_set_ps(__w, __w, __w, __w, __w, __w, __w, __w);
4212 }
4213 
4214 /// Constructs a 256-bit integer vector of [8 x i32], with each of the
4215 ///    32-bit integral vector elements set to the specified 32-bit integral
4216 ///    value.
4217 ///
4218 /// \headerfile <x86intrin.h>
4219 ///
4220 /// This intrinsic corresponds to the <c> VPERMILPS+VINSERTF128 </c>
4221 ///   instruction.
4222 ///
4223 /// \param __i
4224 ///    A 32-bit integral value used to initialize each vector element of the
4225 ///    result.
4226 /// \returns An initialized 256-bit integer vector of [8 x i32].
4227 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set1_epi32(int __i)4228 _mm256_set1_epi32(int __i)
4229 {
4230   return _mm256_set_epi32(__i, __i, __i, __i, __i, __i, __i, __i);
4231 }
4232 
4233 /// Constructs a 256-bit integer vector of [16 x i16], with each of the
4234 ///    16-bit integral vector elements set to the specified 16-bit integral
4235 ///    value.
4236 ///
4237 /// \headerfile <x86intrin.h>
4238 ///
4239 /// This intrinsic corresponds to the <c> VPSHUFB+VINSERTF128 </c> instruction.
4240 ///
4241 /// \param __w
4242 ///    A 16-bit integral value used to initialize each vector element of the
4243 ///    result.
4244 /// \returns An initialized 256-bit integer vector of [16 x i16].
4245 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set1_epi16(short __w)4246 _mm256_set1_epi16(short __w)
4247 {
4248   return _mm256_set_epi16(__w, __w, __w, __w, __w, __w, __w, __w,
4249                           __w, __w, __w, __w, __w, __w, __w, __w);
4250 }
4251 
4252 /// Constructs a 256-bit integer vector of [32 x i8], with each of the
4253 ///    8-bit integral vector elements set to the specified 8-bit integral value.
4254 ///
4255 /// \headerfile <x86intrin.h>
4256 ///
4257 /// This intrinsic corresponds to the <c> VPSHUFB+VINSERTF128 </c> instruction.
4258 ///
4259 /// \param __b
4260 ///    An 8-bit integral value used to initialize each vector element of the
4261 ///    result.
4262 /// \returns An initialized 256-bit integer vector of [32 x i8].
4263 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set1_epi8(char __b)4264 _mm256_set1_epi8(char __b)
4265 {
4266   return _mm256_set_epi8(__b, __b, __b, __b, __b, __b, __b, __b,
4267                          __b, __b, __b, __b, __b, __b, __b, __b,
4268                          __b, __b, __b, __b, __b, __b, __b, __b,
4269                          __b, __b, __b, __b, __b, __b, __b, __b);
4270 }
4271 
4272 /// Constructs a 256-bit integer vector of [4 x i64], with each of the
4273 ///    64-bit integral vector elements set to the specified 64-bit integral
4274 ///    value.
4275 ///
4276 /// \headerfile <x86intrin.h>
4277 ///
4278 /// This intrinsic corresponds to the <c> VMOVDDUP+VINSERTF128 </c> instruction.
4279 ///
4280 /// \param __q
4281 ///    A 64-bit integral value used to initialize each vector element of the
4282 ///    result.
4283 /// \returns An initialized 256-bit integer vector of [4 x i64].
4284 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set1_epi64x(long long __q)4285 _mm256_set1_epi64x(long long __q)
4286 {
4287   return _mm256_set_epi64x(__q, __q, __q, __q);
4288 }
4289 
4290 /* Create __zeroed vectors */
4291 /// Constructs a 256-bit floating-point vector of [4 x double] with all
4292 ///    vector elements initialized to zero.
4293 ///
4294 /// \headerfile <x86intrin.h>
4295 ///
4296 /// This intrinsic corresponds to the <c> VXORPS </c> instruction.
4297 ///
4298 /// \returns A 256-bit vector of [4 x double] with all elements set to zero.
4299 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_setzero_pd(void)4300 _mm256_setzero_pd(void)
4301 {
4302   return __extension__ (__m256d){ 0.0, 0.0, 0.0, 0.0 };
4303 }
4304 
4305 /// Constructs a 256-bit floating-point vector of [8 x float] with all
4306 ///    vector elements initialized to zero.
4307 ///
4308 /// \headerfile <x86intrin.h>
4309 ///
4310 /// This intrinsic corresponds to the <c> VXORPS </c> instruction.
4311 ///
4312 /// \returns A 256-bit vector of [8 x float] with all elements set to zero.
4313 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_setzero_ps(void)4314 _mm256_setzero_ps(void)
4315 {
4316   return __extension__ (__m256){ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
4317 }
4318 
4319 /// Constructs a 256-bit integer vector initialized to zero.
4320 ///
4321 /// \headerfile <x86intrin.h>
4322 ///
4323 /// This intrinsic corresponds to the <c> VXORPS </c> instruction.
4324 ///
4325 /// \returns A 256-bit integer vector initialized to zero.
4326 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_setzero_si256(void)4327 _mm256_setzero_si256(void)
4328 {
4329   return __extension__ (__m256i)(__v4di){ 0, 0, 0, 0 };
4330 }
4331 
4332 /* Cast between vector types */
4333 /// Casts a 256-bit floating-point vector of [4 x double] into a 256-bit
4334 ///    floating-point vector of [8 x float].
4335 ///
4336 /// \headerfile <x86intrin.h>
4337 ///
4338 /// This intrinsic has no corresponding instruction.
4339 ///
4340 /// \param __a
4341 ///    A 256-bit floating-point vector of [4 x double].
4342 /// \returns A 256-bit floating-point vector of [8 x float] containing the same
4343 ///    bitwise pattern as the parameter.
4344 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_castpd_ps(__m256d __a)4345 _mm256_castpd_ps(__m256d __a)
4346 {
4347   return (__m256)__a;
4348 }
4349 
4350 /// Casts a 256-bit floating-point vector of [4 x double] into a 256-bit
4351 ///    integer vector.
4352 ///
4353 /// \headerfile <x86intrin.h>
4354 ///
4355 /// This intrinsic has no corresponding instruction.
4356 ///
4357 /// \param __a
4358 ///    A 256-bit floating-point vector of [4 x double].
4359 /// \returns A 256-bit integer vector containing the same bitwise pattern as the
4360 ///    parameter.
4361 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_castpd_si256(__m256d __a)4362 _mm256_castpd_si256(__m256d __a)
4363 {
4364   return (__m256i)__a;
4365 }
4366 
4367 /// Casts a 256-bit floating-point vector of [8 x float] into a 256-bit
4368 ///    floating-point vector of [4 x double].
4369 ///
4370 /// \headerfile <x86intrin.h>
4371 ///
4372 /// This intrinsic has no corresponding instruction.
4373 ///
4374 /// \param __a
4375 ///    A 256-bit floating-point vector of [8 x float].
4376 /// \returns A 256-bit floating-point vector of [4 x double] containing the same
4377 ///    bitwise pattern as the parameter.
4378 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_castps_pd(__m256 __a)4379 _mm256_castps_pd(__m256 __a)
4380 {
4381   return (__m256d)__a;
4382 }
4383 
4384 /// Casts a 256-bit floating-point vector of [8 x float] into a 256-bit
4385 ///    integer vector.
4386 ///
4387 /// \headerfile <x86intrin.h>
4388 ///
4389 /// This intrinsic has no corresponding instruction.
4390 ///
4391 /// \param __a
4392 ///    A 256-bit floating-point vector of [8 x float].
4393 /// \returns A 256-bit integer vector containing the same bitwise pattern as the
4394 ///    parameter.
4395 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_castps_si256(__m256 __a)4396 _mm256_castps_si256(__m256 __a)
4397 {
4398   return (__m256i)__a;
4399 }
4400 
4401 /// Casts a 256-bit integer vector into a 256-bit floating-point vector
4402 ///    of [8 x float].
4403 ///
4404 /// \headerfile <x86intrin.h>
4405 ///
4406 /// This intrinsic has no corresponding instruction.
4407 ///
4408 /// \param __a
4409 ///    A 256-bit integer vector.
4410 /// \returns A 256-bit floating-point vector of [8 x float] containing the same
4411 ///    bitwise pattern as the parameter.
4412 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_castsi256_ps(__m256i __a)4413 _mm256_castsi256_ps(__m256i __a)
4414 {
4415   return (__m256)__a;
4416 }
4417 
4418 /// Casts a 256-bit integer vector into a 256-bit floating-point vector
4419 ///    of [4 x double].
4420 ///
4421 /// \headerfile <x86intrin.h>
4422 ///
4423 /// This intrinsic has no corresponding instruction.
4424 ///
4425 /// \param __a
4426 ///    A 256-bit integer vector.
4427 /// \returns A 256-bit floating-point vector of [4 x double] containing the same
4428 ///    bitwise pattern as the parameter.
4429 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_castsi256_pd(__m256i __a)4430 _mm256_castsi256_pd(__m256i __a)
4431 {
4432   return (__m256d)__a;
4433 }
4434 
4435 /// Returns the lower 128 bits of a 256-bit floating-point vector of
4436 ///    [4 x double] as a 128-bit floating-point vector of [2 x double].
4437 ///
4438 /// \headerfile <x86intrin.h>
4439 ///
4440 /// This intrinsic has no corresponding instruction.
4441 ///
4442 /// \param __a
4443 ///    A 256-bit floating-point vector of [4 x double].
4444 /// \returns A 128-bit floating-point vector of [2 x double] containing the
4445 ///    lower 128 bits of the parameter.
4446 static __inline __m128d __DEFAULT_FN_ATTRS
_mm256_castpd256_pd128(__m256d __a)4447 _mm256_castpd256_pd128(__m256d __a)
4448 {
4449   return __builtin_shufflevector((__v4df)__a, (__v4df)__a, 0, 1);
4450 }
4451 
4452 /// Returns the lower 128 bits of a 256-bit floating-point vector of
4453 ///    [8 x float] as a 128-bit floating-point vector of [4 x float].
4454 ///
4455 /// \headerfile <x86intrin.h>
4456 ///
4457 /// This intrinsic has no corresponding instruction.
4458 ///
4459 /// \param __a
4460 ///    A 256-bit floating-point vector of [8 x float].
4461 /// \returns A 128-bit floating-point vector of [4 x float] containing the
4462 ///    lower 128 bits of the parameter.
4463 static __inline __m128 __DEFAULT_FN_ATTRS
_mm256_castps256_ps128(__m256 __a)4464 _mm256_castps256_ps128(__m256 __a)
4465 {
4466   return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 0, 1, 2, 3);
4467 }
4468 
4469 /// Truncates a 256-bit integer vector into a 128-bit integer vector.
4470 ///
4471 /// \headerfile <x86intrin.h>
4472 ///
4473 /// This intrinsic has no corresponding instruction.
4474 ///
4475 /// \param __a
4476 ///    A 256-bit integer vector.
4477 /// \returns A 128-bit integer vector containing the lower 128 bits of the
4478 ///    parameter.
4479 static __inline __m128i __DEFAULT_FN_ATTRS
_mm256_castsi256_si128(__m256i __a)4480 _mm256_castsi256_si128(__m256i __a)
4481 {
4482   return __builtin_shufflevector((__v4di)__a, (__v4di)__a, 0, 1);
4483 }
4484 
4485 /// Constructs a 256-bit floating-point vector of [4 x double] from a
4486 ///    128-bit floating-point vector of [2 x double].
4487 ///
4488 ///    The lower 128 bits contain the value of the source vector. The contents
4489 ///    of the upper 128 bits are undefined.
4490 ///
4491 /// \headerfile <x86intrin.h>
4492 ///
4493 /// This intrinsic has no corresponding instruction.
4494 ///
4495 /// \param __a
4496 ///    A 128-bit vector of [2 x double].
4497 /// \returns A 256-bit floating-point vector of [4 x double]. The lower 128 bits
4498 ///    contain the value of the parameter. The contents of the upper 128 bits
4499 ///    are undefined.
4500 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_castpd128_pd256(__m128d __a)4501 _mm256_castpd128_pd256(__m128d __a)
4502 {
4503   return __builtin_shufflevector(
4504       (__v2df)__a, (__v2df)__builtin_nondeterministic_value(__a), 0, 1, 2, 3);
4505 }
4506 
4507 /// Constructs a 256-bit floating-point vector of [8 x float] from a
4508 ///    128-bit floating-point vector of [4 x float].
4509 ///
4510 ///    The lower 128 bits contain the value of the source vector. The contents
4511 ///    of the upper 128 bits are undefined.
4512 ///
4513 /// \headerfile <x86intrin.h>
4514 ///
4515 /// This intrinsic has no corresponding instruction.
4516 ///
4517 /// \param __a
4518 ///    A 128-bit vector of [4 x float].
4519 /// \returns A 256-bit floating-point vector of [8 x float]. The lower 128 bits
4520 ///    contain the value of the parameter. The contents of the upper 128 bits
4521 ///    are undefined.
4522 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_castps128_ps256(__m128 __a)4523 _mm256_castps128_ps256(__m128 __a)
4524 {
4525   return __builtin_shufflevector((__v4sf)__a,
4526                                  (__v4sf)__builtin_nondeterministic_value(__a),
4527                                  0, 1, 2, 3, 4, 5, 6, 7);
4528 }
4529 
4530 /// Constructs a 256-bit integer vector from a 128-bit integer vector.
4531 ///
4532 ///    The lower 128 bits contain the value of the source vector. The contents
4533 ///    of the upper 128 bits are undefined.
4534 ///
4535 /// \headerfile <x86intrin.h>
4536 ///
4537 /// This intrinsic has no corresponding instruction.
4538 ///
4539 /// \param __a
4540 ///    A 128-bit integer vector.
4541 /// \returns A 256-bit integer vector. The lower 128 bits contain the value of
4542 ///    the parameter. The contents of the upper 128 bits are undefined.
4543 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_castsi128_si256(__m128i __a)4544 _mm256_castsi128_si256(__m128i __a)
4545 {
4546   return __builtin_shufflevector(
4547       (__v2di)__a, (__v2di)__builtin_nondeterministic_value(__a), 0, 1, 2, 3);
4548 }
4549 
4550 /// Constructs a 256-bit floating-point vector of [4 x double] from a
4551 ///    128-bit floating-point vector of [2 x double]. The lower 128 bits
4552 ///    contain the value of the source vector. The upper 128 bits are set
4553 ///    to zero.
4554 ///
4555 /// \headerfile <x86intrin.h>
4556 ///
4557 /// This intrinsic has no corresponding instruction.
4558 ///
4559 /// \param __a
4560 ///    A 128-bit vector of [2 x double].
4561 /// \returns A 256-bit floating-point vector of [4 x double]. The lower 128 bits
4562 ///    contain the value of the parameter. The upper 128 bits are set to zero.
4563 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_zextpd128_pd256(__m128d __a)4564 _mm256_zextpd128_pd256(__m128d __a)
4565 {
4566   return __builtin_shufflevector((__v2df)__a, (__v2df)_mm_setzero_pd(), 0, 1, 2, 3);
4567 }
4568 
4569 /// Constructs a 256-bit floating-point vector of [8 x float] from a
4570 ///    128-bit floating-point vector of [4 x float]. The lower 128 bits contain
4571 ///    the value of the source vector. The upper 128 bits are set to zero.
4572 ///
4573 /// \headerfile <x86intrin.h>
4574 ///
4575 /// This intrinsic has no corresponding instruction.
4576 ///
4577 /// \param __a
4578 ///    A 128-bit vector of [4 x float].
4579 /// \returns A 256-bit floating-point vector of [8 x float]. The lower 128 bits
4580 ///    contain the value of the parameter. The upper 128 bits are set to zero.
4581 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_zextps128_ps256(__m128 __a)4582 _mm256_zextps128_ps256(__m128 __a)
4583 {
4584   return __builtin_shufflevector((__v4sf)__a, (__v4sf)_mm_setzero_ps(), 0, 1, 2, 3, 4, 5, 6, 7);
4585 }
4586 
4587 /// Constructs a 256-bit integer vector from a 128-bit integer vector.
4588 ///    The lower 128 bits contain the value of the source vector. The upper
4589 ///    128 bits are set to zero.
4590 ///
4591 /// \headerfile <x86intrin.h>
4592 ///
4593 /// This intrinsic has no corresponding instruction.
4594 ///
4595 /// \param __a
4596 ///    A 128-bit integer vector.
4597 /// \returns A 256-bit integer vector. The lower 128 bits contain the value of
4598 ///    the parameter. The upper 128 bits are set to zero.
4599 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_zextsi128_si256(__m128i __a)4600 _mm256_zextsi128_si256(__m128i __a)
4601 {
4602   return __builtin_shufflevector((__v2di)__a, (__v2di)_mm_setzero_si128(), 0, 1, 2, 3);
4603 }
4604 
4605 /*
4606    Vector insert.
4607    We use macros rather than inlines because we only want to accept
4608    invocations where the immediate M is a constant expression.
4609 */
4610 /// Constructs a new 256-bit vector of [8 x float] by first duplicating
4611 ///    a 256-bit vector of [8 x float] given in the first parameter, and then
4612 ///    replacing either the upper or the lower 128 bits with the contents of a
4613 ///    128-bit vector of [4 x float] in the second parameter.
4614 ///
4615 ///    The immediate integer parameter determines between the upper or the lower
4616 ///    128 bits.
4617 ///
4618 /// \headerfile <x86intrin.h>
4619 ///
4620 /// \code
4621 /// __m256 _mm256_insertf128_ps(__m256 V1, __m128 V2, const int M);
4622 /// \endcode
4623 ///
4624 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4625 ///
4626 /// \param V1
4627 ///    A 256-bit vector of [8 x float]. This vector is copied to the result
4628 ///    first, and then either the upper or the lower 128 bits of the result will
4629 ///    be replaced by the contents of \a V2.
4630 /// \param V2
4631 ///    A 128-bit vector of [4 x float]. The contents of this parameter are
4632 ///    written to either the upper or the lower 128 bits of the result depending
4633 ///    on the value of parameter \a M.
4634 /// \param M
4635 ///    An immediate integer. The least significant bit determines how the values
4636 ///    from the two parameters are interleaved: \n
4637 ///    If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result,
4638 ///    and bits [255:128] of \a V1 are copied to bits [255:128] of the
4639 ///    result. \n
4640 ///    If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the
4641 ///    result, and bits [127:0] of \a V1 are copied to bits [127:0] of the
4642 ///    result.
4643 /// \returns A 256-bit vector of [8 x float] containing the interleaved values.
4644 #define _mm256_insertf128_ps(V1, V2, M) \
4645   ((__m256)__builtin_ia32_vinsertf128_ps256((__v8sf)(__m256)(V1), \
4646                                             (__v4sf)(__m128)(V2), (int)(M)))
4647 
4648 /// Constructs a new 256-bit vector of [4 x double] by first duplicating
4649 ///    a 256-bit vector of [4 x double] given in the first parameter, and then
4650 ///    replacing either the upper or the lower 128 bits with the contents of a
4651 ///    128-bit vector of [2 x double] in the second parameter.
4652 ///
4653 ///    The immediate integer parameter determines between the upper or the lower
4654 ///    128 bits.
4655 ///
4656 /// \headerfile <x86intrin.h>
4657 ///
4658 /// \code
4659 /// __m256d _mm256_insertf128_pd(__m256d V1, __m128d V2, const int M);
4660 /// \endcode
4661 ///
4662 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4663 ///
4664 /// \param V1
4665 ///    A 256-bit vector of [4 x double]. This vector is copied to the result
4666 ///    first, and then either the upper or the lower 128 bits of the result will
4667 ///    be replaced by the contents of \a V2.
4668 /// \param V2
4669 ///    A 128-bit vector of [2 x double]. The contents of this parameter are
4670 ///    written to either the upper or the lower 128 bits of the result depending
4671 ///    on the value of parameter \a M.
4672 /// \param M
4673 ///    An immediate integer. The least significant bit determines how the values
4674 ///    from the two parameters are interleaved: \n
4675 ///    If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result,
4676 ///    and bits [255:128] of \a V1 are copied to bits [255:128] of the
4677 ///    result. \n
4678 ///    If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the
4679 ///    result, and bits [127:0] of \a V1 are copied to bits [127:0] of the
4680 ///    result.
4681 /// \returns A 256-bit vector of [4 x double] containing the interleaved values.
4682 #define _mm256_insertf128_pd(V1, V2, M) \
4683   ((__m256d)__builtin_ia32_vinsertf128_pd256((__v4df)(__m256d)(V1), \
4684                                              (__v2df)(__m128d)(V2), (int)(M)))
4685 
4686 /// Constructs a new 256-bit integer vector by first duplicating a
4687 ///    256-bit integer vector given in the first parameter, and then replacing
4688 ///    either the upper or the lower 128 bits with the contents of a 128-bit
4689 ///    integer vector in the second parameter.
4690 ///
4691 ///    The immediate integer parameter determines between the upper or the lower
4692 ///    128 bits.
4693 ///
4694 /// \headerfile <x86intrin.h>
4695 ///
4696 /// \code
4697 /// __m256i _mm256_insertf128_si256(__m256i V1, __m128i V2, const int M);
4698 /// \endcode
4699 ///
4700 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4701 ///
4702 /// \param V1
4703 ///    A 256-bit integer vector. This vector is copied to the result first, and
4704 ///    then either the upper or the lower 128 bits of the result will be
4705 ///    replaced by the contents of \a V2.
4706 /// \param V2
4707 ///    A 128-bit integer vector. The contents of this parameter are written to
4708 ///    either the upper or the lower 128 bits of the result depending on the
4709 ///     value of parameter \a M.
4710 /// \param M
4711 ///    An immediate integer. The least significant bit determines how the values
4712 ///    from the two parameters are interleaved: \n
4713 ///    If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result,
4714 ///    and bits [255:128] of \a V1 are copied to bits [255:128] of the
4715 ///    result. \n
4716 ///    If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the
4717 ///    result, and bits [127:0] of \a V1 are copied to bits [127:0] of the
4718 ///    result.
4719 /// \returns A 256-bit integer vector containing the interleaved values.
4720 #define _mm256_insertf128_si256(V1, V2, M) \
4721   ((__m256i)__builtin_ia32_vinsertf128_si256((__v8si)(__m256i)(V1), \
4722                                              (__v4si)(__m128i)(V2), (int)(M)))
4723 
4724 /*
4725    Vector extract.
4726    We use macros rather than inlines because we only want to accept
4727    invocations where the immediate M is a constant expression.
4728 */
4729 /// Extracts either the upper or the lower 128 bits from a 256-bit vector
4730 ///    of [8 x float], as determined by the immediate integer parameter, and
4731 ///    returns the extracted bits as a 128-bit vector of [4 x float].
4732 ///
4733 /// \headerfile <x86intrin.h>
4734 ///
4735 /// \code
4736 /// __m128 _mm256_extractf128_ps(__m256 V, const int M);
4737 /// \endcode
4738 ///
4739 /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction.
4740 ///
4741 /// \param V
4742 ///    A 256-bit vector of [8 x float].
4743 /// \param M
4744 ///    An immediate integer. The least significant bit determines which bits are
4745 ///    extracted from the first parameter: \n
4746 ///    If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the
4747 ///    result. \n
4748 ///    If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result.
4749 /// \returns A 128-bit vector of [4 x float] containing the extracted bits.
4750 #define _mm256_extractf128_ps(V, M) \
4751   ((__m128)__builtin_ia32_vextractf128_ps256((__v8sf)(__m256)(V), (int)(M)))
4752 
4753 /// Extracts either the upper or the lower 128 bits from a 256-bit vector
4754 ///    of [4 x double], as determined by the immediate integer parameter, and
4755 ///    returns the extracted bits as a 128-bit vector of [2 x double].
4756 ///
4757 /// \headerfile <x86intrin.h>
4758 ///
4759 /// \code
4760 /// __m128d _mm256_extractf128_pd(__m256d V, const int M);
4761 /// \endcode
4762 ///
4763 /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction.
4764 ///
4765 /// \param V
4766 ///    A 256-bit vector of [4 x double].
4767 /// \param M
4768 ///    An immediate integer. The least significant bit determines which bits are
4769 ///    extracted from the first parameter: \n
4770 ///    If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the
4771 ///    result. \n
4772 ///    If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result.
4773 /// \returns A 128-bit vector of [2 x double] containing the extracted bits.
4774 #define _mm256_extractf128_pd(V, M) \
4775   ((__m128d)__builtin_ia32_vextractf128_pd256((__v4df)(__m256d)(V), (int)(M)))
4776 
4777 /// Extracts either the upper or the lower 128 bits from a 256-bit
4778 ///    integer vector, as determined by the immediate integer parameter, and
4779 ///    returns the extracted bits as a 128-bit integer vector.
4780 ///
4781 /// \headerfile <x86intrin.h>
4782 ///
4783 /// \code
4784 /// __m128i _mm256_extractf128_si256(__m256i V, const int M);
4785 /// \endcode
4786 ///
4787 /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction.
4788 ///
4789 /// \param V
4790 ///    A 256-bit integer vector.
4791 /// \param M
4792 ///    An immediate integer. The least significant bit determines which bits are
4793 ///    extracted from the first parameter:  \n
4794 ///    If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the
4795 ///    result. \n
4796 ///    If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result.
4797 /// \returns A 128-bit integer vector containing the extracted bits.
4798 #define _mm256_extractf128_si256(V, M) \
4799   ((__m128i)__builtin_ia32_vextractf128_si256((__v8si)(__m256i)(V), (int)(M)))
4800 
4801 /// Constructs a 256-bit floating-point vector of [8 x float] by
4802 ///    concatenating two 128-bit floating-point vectors of [4 x float].
4803 ///
4804 /// \headerfile <x86intrin.h>
4805 ///
4806 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4807 ///
4808 /// \param __hi
4809 ///    A 128-bit floating-point vector of [4 x float] to be copied to the upper
4810 ///    128 bits of the result.
4811 /// \param __lo
4812 ///    A 128-bit floating-point vector of [4 x float] to be copied to the lower
4813 ///    128 bits of the result.
4814 /// \returns A 256-bit floating-point vector of [8 x float] containing the
4815 ///    concatenated result.
4816 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_set_m128(__m128 __hi,__m128 __lo)4817 _mm256_set_m128 (__m128 __hi, __m128 __lo)
4818 {
4819   return (__m256) __builtin_shufflevector((__v4sf)__lo, (__v4sf)__hi, 0, 1, 2, 3, 4, 5, 6, 7);
4820 }
4821 
4822 /// Constructs a 256-bit floating-point vector of [4 x double] by
4823 ///    concatenating two 128-bit floating-point vectors of [2 x double].
4824 ///
4825 /// \headerfile <x86intrin.h>
4826 ///
4827 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4828 ///
4829 /// \param __hi
4830 ///    A 128-bit floating-point vector of [2 x double] to be copied to the upper
4831 ///    128 bits of the result.
4832 /// \param __lo
4833 ///    A 128-bit floating-point vector of [2 x double] to be copied to the lower
4834 ///    128 bits of the result.
4835 /// \returns A 256-bit floating-point vector of [4 x double] containing the
4836 ///    concatenated result.
4837 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_set_m128d(__m128d __hi,__m128d __lo)4838 _mm256_set_m128d (__m128d __hi, __m128d __lo)
4839 {
4840   return (__m256d) __builtin_shufflevector((__v2df)__lo, (__v2df)__hi, 0, 1, 2, 3);
4841 }
4842 
4843 /// Constructs a 256-bit integer vector by concatenating two 128-bit
4844 ///    integer vectors.
4845 ///
4846 /// \headerfile <x86intrin.h>
4847 ///
4848 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4849 ///
4850 /// \param __hi
4851 ///    A 128-bit integer vector to be copied to the upper 128 bits of the
4852 ///    result.
4853 /// \param __lo
4854 ///    A 128-bit integer vector to be copied to the lower 128 bits of the
4855 ///    result.
4856 /// \returns A 256-bit integer vector containing the concatenated result.
4857 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_set_m128i(__m128i __hi,__m128i __lo)4858 _mm256_set_m128i (__m128i __hi, __m128i __lo)
4859 {
4860   return (__m256i) __builtin_shufflevector((__v2di)__lo, (__v2di)__hi, 0, 1, 2, 3);
4861 }
4862 
4863 /// Constructs a 256-bit floating-point vector of [8 x float] by
4864 ///    concatenating two 128-bit floating-point vectors of [4 x float]. This is
4865 ///    similar to _mm256_set_m128, but the order of the input parameters is
4866 ///    swapped.
4867 ///
4868 /// \headerfile <x86intrin.h>
4869 ///
4870 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4871 ///
4872 /// \param __lo
4873 ///    A 128-bit floating-point vector of [4 x float] to be copied to the lower
4874 ///    128 bits of the result.
4875 /// \param __hi
4876 ///    A 128-bit floating-point vector of [4 x float] to be copied to the upper
4877 ///    128 bits of the result.
4878 /// \returns A 256-bit floating-point vector of [8 x float] containing the
4879 ///    concatenated result.
4880 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_setr_m128(__m128 __lo,__m128 __hi)4881 _mm256_setr_m128 (__m128 __lo, __m128 __hi)
4882 {
4883   return _mm256_set_m128(__hi, __lo);
4884 }
4885 
4886 /// Constructs a 256-bit floating-point vector of [4 x double] by
4887 ///    concatenating two 128-bit floating-point vectors of [2 x double]. This is
4888 ///    similar to _mm256_set_m128d, but the order of the input parameters is
4889 ///    swapped.
4890 ///
4891 /// \headerfile <x86intrin.h>
4892 ///
4893 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4894 ///
4895 /// \param __lo
4896 ///    A 128-bit floating-point vector of [2 x double] to be copied to the lower
4897 ///    128 bits of the result.
4898 /// \param __hi
4899 ///    A 128-bit floating-point vector of [2 x double] to be copied to the upper
4900 ///    128 bits of the result.
4901 /// \returns A 256-bit floating-point vector of [4 x double] containing the
4902 ///    concatenated result.
4903 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_setr_m128d(__m128d __lo,__m128d __hi)4904 _mm256_setr_m128d (__m128d __lo, __m128d __hi)
4905 {
4906   return (__m256d)_mm256_set_m128d(__hi, __lo);
4907 }
4908 
4909 /// Constructs a 256-bit integer vector by concatenating two 128-bit
4910 ///    integer vectors. This is similar to _mm256_set_m128i, but the order of
4911 ///    the input parameters is swapped.
4912 ///
4913 /// \headerfile <x86intrin.h>
4914 ///
4915 /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
4916 ///
4917 /// \param __lo
4918 ///    A 128-bit integer vector to be copied to the lower 128 bits of the
4919 ///    result.
4920 /// \param __hi
4921 ///    A 128-bit integer vector to be copied to the upper 128 bits of the
4922 ///    result.
4923 /// \returns A 256-bit integer vector containing the concatenated result.
4924 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_setr_m128i(__m128i __lo,__m128i __hi)4925 _mm256_setr_m128i (__m128i __lo, __m128i __hi)
4926 {
4927   return (__m256i)_mm256_set_m128i(__hi, __lo);
4928 }
4929 
4930 /* SIMD load ops (unaligned) */
4931 /// Loads two 128-bit floating-point vectors of [4 x float] from
4932 ///    unaligned memory locations and constructs a 256-bit floating-point vector
4933 ///    of [8 x float] by concatenating the two 128-bit vectors.
4934 ///
4935 /// \headerfile <x86intrin.h>
4936 ///
4937 /// This intrinsic corresponds to load instructions followed by the
4938 ///   <c> VINSERTF128 </c> instruction.
4939 ///
4940 /// \param __addr_hi
4941 ///    A pointer to a 128-bit memory location containing 4 consecutive
4942 ///    single-precision floating-point values. These values are to be copied to
4943 ///    bits[255:128] of the result. The address of the memory location does not
4944 ///    have to be aligned.
4945 /// \param __addr_lo
4946 ///    A pointer to a 128-bit memory location containing 4 consecutive
4947 ///    single-precision floating-point values. These values are to be copied to
4948 ///    bits[127:0] of the result. The address of the memory location does not
4949 ///    have to be aligned.
4950 /// \returns A 256-bit floating-point vector of [8 x float] containing the
4951 ///    concatenated result.
4952 static __inline __m256 __DEFAULT_FN_ATTRS
_mm256_loadu2_m128(float const * __addr_hi,float const * __addr_lo)4953 _mm256_loadu2_m128(float const *__addr_hi, float const *__addr_lo)
4954 {
4955   return _mm256_set_m128(_mm_loadu_ps(__addr_hi), _mm_loadu_ps(__addr_lo));
4956 }
4957 
4958 /// Loads two 128-bit floating-point vectors of [2 x double] from
4959 ///    unaligned memory locations and constructs a 256-bit floating-point vector
4960 ///    of [4 x double] by concatenating the two 128-bit vectors.
4961 ///
4962 /// \headerfile <x86intrin.h>
4963 ///
4964 /// This intrinsic corresponds to load instructions followed by the
4965 ///   <c> VINSERTF128 </c> instruction.
4966 ///
4967 /// \param __addr_hi
4968 ///    A pointer to a 128-bit memory location containing two consecutive
4969 ///    double-precision floating-point values. These values are to be copied to
4970 ///    bits[255:128] of the result. The address of the memory location does not
4971 ///    have to be aligned.
4972 /// \param __addr_lo
4973 ///    A pointer to a 128-bit memory location containing two consecutive
4974 ///    double-precision floating-point values. These values are to be copied to
4975 ///    bits[127:0] of the result. The address of the memory location does not
4976 ///    have to be aligned.
4977 /// \returns A 256-bit floating-point vector of [4 x double] containing the
4978 ///    concatenated result.
4979 static __inline __m256d __DEFAULT_FN_ATTRS
_mm256_loadu2_m128d(double const * __addr_hi,double const * __addr_lo)4980 _mm256_loadu2_m128d(double const *__addr_hi, double const *__addr_lo)
4981 {
4982   return _mm256_set_m128d(_mm_loadu_pd(__addr_hi), _mm_loadu_pd(__addr_lo));
4983 }
4984 
4985 /// Loads two 128-bit integer vectors from unaligned memory locations and
4986 ///    constructs a 256-bit integer vector by concatenating the two 128-bit
4987 ///    vectors.
4988 ///
4989 /// \headerfile <x86intrin.h>
4990 ///
4991 /// This intrinsic corresponds to load instructions followed by the
4992 ///   <c> VINSERTF128 </c> instruction.
4993 ///
4994 /// \param __addr_hi
4995 ///    A pointer to a 128-bit memory location containing a 128-bit integer
4996 ///    vector. This vector is to be copied to bits[255:128] of the result. The
4997 ///    address of the memory location does not have to be aligned.
4998 /// \param __addr_lo
4999 ///    A pointer to a 128-bit memory location containing a 128-bit integer
5000 ///    vector. This vector is to be copied to bits[127:0] of the result. The
5001 ///    address of the memory location does not have to be aligned.
5002 /// \returns A 256-bit integer vector containing the concatenated result.
5003 static __inline __m256i __DEFAULT_FN_ATTRS
_mm256_loadu2_m128i(__m128i_u const * __addr_hi,__m128i_u const * __addr_lo)5004 _mm256_loadu2_m128i(__m128i_u const *__addr_hi, __m128i_u const *__addr_lo)
5005 {
5006    return _mm256_set_m128i(_mm_loadu_si128(__addr_hi), _mm_loadu_si128(__addr_lo));
5007 }
5008 
5009 /* SIMD store ops (unaligned) */
5010 /// Stores the upper and lower 128 bits of a 256-bit floating-point
5011 ///    vector of [8 x float] into two different unaligned memory locations.
5012 ///
5013 /// \headerfile <x86intrin.h>
5014 ///
5015 /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction and the
5016 ///   store instructions.
5017 ///
5018 /// \param __addr_hi
5019 ///    A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be
5020 ///    copied to this memory location. The address of this memory location does
5021 ///    not have to be aligned.
5022 /// \param __addr_lo
5023 ///    A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be
5024 ///    copied to this memory location. The address of this memory location does
5025 ///    not have to be aligned.
5026 /// \param __a
5027 ///    A 256-bit floating-point vector of [8 x float].
5028 static __inline void __DEFAULT_FN_ATTRS
_mm256_storeu2_m128(float * __addr_hi,float * __addr_lo,__m256 __a)5029 _mm256_storeu2_m128(float *__addr_hi, float *__addr_lo, __m256 __a)
5030 {
5031   __m128 __v128;
5032 
5033   __v128 = _mm256_castps256_ps128(__a);
5034   _mm_storeu_ps(__addr_lo, __v128);
5035   __v128 = _mm256_extractf128_ps(__a, 1);
5036   _mm_storeu_ps(__addr_hi, __v128);
5037 }
5038 
5039 /// Stores the upper and lower 128 bits of a 256-bit floating-point
5040 ///    vector of [4 x double] into two different unaligned memory locations.
5041 ///
5042 /// \headerfile <x86intrin.h>
5043 ///
5044 /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction and the
5045 ///   store instructions.
5046 ///
5047 /// \param __addr_hi
5048 ///    A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be
5049 ///    copied to this memory location. The address of this memory location does
5050 ///    not have to be aligned.
5051 /// \param __addr_lo
5052 ///    A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be
5053 ///    copied to this memory location. The address of this memory location does
5054 ///    not have to be aligned.
5055 /// \param __a
5056 ///    A 256-bit floating-point vector of [4 x double].
5057 static __inline void __DEFAULT_FN_ATTRS
_mm256_storeu2_m128d(double * __addr_hi,double * __addr_lo,__m256d __a)5058 _mm256_storeu2_m128d(double *__addr_hi, double *__addr_lo, __m256d __a)
5059 {
5060   __m128d __v128;
5061 
5062   __v128 = _mm256_castpd256_pd128(__a);
5063   _mm_storeu_pd(__addr_lo, __v128);
5064   __v128 = _mm256_extractf128_pd(__a, 1);
5065   _mm_storeu_pd(__addr_hi, __v128);
5066 }
5067 
5068 /// Stores the upper and lower 128 bits of a 256-bit integer vector into
5069 ///    two different unaligned memory locations.
5070 ///
5071 /// \headerfile <x86intrin.h>
5072 ///
5073 /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction and the
5074 ///   store instructions.
5075 ///
5076 /// \param __addr_hi
5077 ///    A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be
5078 ///    copied to this memory location. The address of this memory location does
5079 ///    not have to be aligned.
5080 /// \param __addr_lo
5081 ///    A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be
5082 ///    copied to this memory location. The address of this memory location does
5083 ///    not have to be aligned.
5084 /// \param __a
5085 ///    A 256-bit integer vector.
5086 static __inline void __DEFAULT_FN_ATTRS
_mm256_storeu2_m128i(__m128i_u * __addr_hi,__m128i_u * __addr_lo,__m256i __a)5087 _mm256_storeu2_m128i(__m128i_u *__addr_hi, __m128i_u *__addr_lo, __m256i __a)
5088 {
5089   __m128i __v128;
5090 
5091   __v128 = _mm256_castsi256_si128(__a);
5092   _mm_storeu_si128(__addr_lo, __v128);
5093   __v128 = _mm256_extractf128_si256(__a, 1);
5094   _mm_storeu_si128(__addr_hi, __v128);
5095 }
5096 
5097 #undef __DEFAULT_FN_ATTRS
5098 #undef __DEFAULT_FN_ATTRS128
5099 
5100 #endif /* __AVXINTRIN_H */
5101