clang 24.0.0git
avx2intrin.h
Go to the documentation of this file.
1/*===---- avx2intrin.h - AVX2 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 <avx2intrin.h> directly; include <immintrin.h> instead."
12#endif
13
14#ifndef __AVX2INTRIN_H
15#define __AVX2INTRIN_H
16
17/* Define the default attributes for the functions in this file. */
18#define __DEFAULT_FN_ATTRS256 \
19 __attribute__((__always_inline__, __nodebug__, __target__("avx2"), \
20 __min_vector_width__(256)))
21#define __DEFAULT_FN_ATTRS128 \
22 __attribute__((__always_inline__, __nodebug__, __target__("avx2"), \
23 __min_vector_width__(128)))
24
25#if defined(__cplusplus) && (__cplusplus >= 201103L)
26#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256 constexpr
27#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 constexpr
28#else
29#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256
30#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128
31#endif
32
33/* SSE4 Multiple Packed Sums of Absolute Difference. */
34/// Computes sixteen sum of absolute difference (SAD) operations on sets of
35/// four unsigned 8-bit integers from the 256-bit integer vectors \a X and
36/// \a Y.
37///
38/// Eight SAD results are computed using the lower half of the input
39/// vectors, and another eight using the upper half. These 16-bit values
40/// are returned in the lower and upper halves of the 256-bit result,
41/// respectively.
42///
43/// A single SAD operation selects four bytes from \a X and four bytes from
44/// \a Y as input. It computes the differences between each \a X byte and
45/// the corresponding \a Y byte, takes the absolute value of each
46/// difference, and sums these four values to form one 16-bit result. The
47/// intrinsic computes 16 of these results with different sets of input
48/// bytes.
49///
50/// For each set of eight results, the SAD operations use the same four
51/// bytes from \a Y; the starting bit position for these four bytes is
52/// specified by \a M[1:0] times 32. The eight operations use successive
53/// sets of four bytes from \a X; the starting bit position for the first
54/// set of four bytes is specified by \a M[2] times 32. These bit positions
55/// are all relative to the 128-bit lane for each set of eight operations.
56///
57/// \code{.operation}
58/// r := 0
59/// FOR i := 0 TO 1
60/// j := i*3
61/// Ybase := M[j+1:j]*32 + i*128
62/// Xbase := M[j+2]*32 + i*128
63/// FOR k := 0 TO 3
64/// temp0 := ABS(X[Xbase+7:Xbase] - Y[Ybase+7:Ybase])
65/// temp1 := ABS(X[Xbase+15:Xbase+8] - Y[Ybase+15:Ybase+8])
66/// temp2 := ABS(X[Xbase+23:Xbase+16] - Y[Ybase+23:Ybase+16])
67/// temp3 := ABS(X[Xbase+31:Xbase+24] - Y[Ybase+31:Ybase+24])
68/// result[r+15:r] := temp0 + temp1 + temp2 + temp3
69/// Xbase := Xbase + 8
70/// r := r + 16
71/// ENDFOR
72/// ENDFOR
73/// \endcode
74///
75/// \headerfile <immintrin.h>
76///
77/// \code
78/// __m256i _mm256_mpsadbw_epu8(__m256i X, __m256i Y, const int M);
79/// \endcode
80///
81/// This intrinsic corresponds to the \c VMPSADBW instruction.
82///
83/// \param X
84/// A 256-bit integer vector containing one of the inputs.
85/// \param Y
86/// A 256-bit integer vector containing one of the inputs.
87/// \param M
88/// An unsigned immediate value specifying the starting positions of the
89/// bytes to operate on.
90/// \returns A 256-bit vector of [16 x i16] containing the result.
91#define _mm256_mpsadbw_epu8(X, Y, M) \
92 ((__m256i)__builtin_ia32_mpsadbw256((__v32qi)(__m256i)(X), \
93 (__v32qi)(__m256i)(Y), (int)(M)))
94
95/// Computes the absolute value of each signed byte in the 256-bit integer
96/// vector \a __a and returns each value in the corresponding byte of
97/// the result.
98///
99/// \headerfile <immintrin.h>
100///
101/// This intrinsic corresponds to the \c VPABSB instruction.
102///
103/// \param __a
104/// A 256-bit integer vector.
105/// \returns A 256-bit integer vector containing the result.
106static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
108 return (__m256i)__builtin_elementwise_abs((__v32qs)__a);
109}
110
111/// Computes the absolute value of each signed 16-bit element in the 256-bit
112/// vector of [16 x i16] in \a __a and returns each value in the
113/// corresponding element of the result.
114///
115/// \headerfile <immintrin.h>
116///
117/// This intrinsic corresponds to the \c VPABSW instruction.
118///
119/// \param __a
120/// A 256-bit vector of [16 x i16].
121/// \returns A 256-bit vector of [16 x i16] containing the result.
122static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
124 return (__m256i)__builtin_elementwise_abs((__v16hi)__a);
125}
126
127/// Computes the absolute value of each signed 32-bit element in the 256-bit
128/// vector of [8 x i32] in \a __a and returns each value in the
129/// corresponding element of the result.
130///
131/// \headerfile <immintrin.h>
132///
133/// This intrinsic corresponds to the \c VPABSD instruction.
134///
135/// \param __a
136/// A 256-bit vector of [8 x i32].
137/// \returns A 256-bit vector of [8 x i32] containing the result.
138static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
140 return (__m256i)__builtin_elementwise_abs((__v8si)__a);
141}
142
143/// Converts the elements of two 256-bit vectors of [16 x i16] to 8-bit
144/// integers using signed saturation, and returns the 256-bit result.
145///
146/// \code{.operation}
147/// FOR i := 0 TO 7
148/// j := i*16
149/// k := i*8
150/// result[7+k:k] := SATURATE8(__a[15+j:j])
151/// result[71+k:64+k] := SATURATE8(__b[15+j:j])
152/// result[135+k:128+k] := SATURATE8(__a[143+j:128+j])
153/// result[199+k:192+k] := SATURATE8(__b[143+j:128+j])
154/// ENDFOR
155/// \endcode
156///
157/// \headerfile <immintrin.h>
158///
159/// This intrinsic corresponds to the \c VPACKSSWB instruction.
160///
161/// \param __a
162/// A 256-bit vector of [16 x i16] used to generate result[63:0] and
163/// result[191:128].
164/// \param __b
165/// A 256-bit vector of [16 x i16] used to generate result[127:64] and
166/// result[255:192].
167/// \returns A 256-bit integer vector containing the result.
168static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
169_mm256_packs_epi16(__m256i __a, __m256i __b) {
170 return (__m256i)__builtin_ia32_packsswb256((__v16hi)__a, (__v16hi)__b);
171}
172
173/// Converts the elements of two 256-bit vectors of [8 x i32] to 16-bit
174/// integers using signed saturation, and returns the resulting 256-bit
175/// vector of [16 x i16].
176///
177/// \code{.operation}
178/// FOR i := 0 TO 3
179/// j := i*32
180/// k := i*16
181/// result[15+k:k] := SATURATE16(__a[31+j:j])
182/// result[79+k:64+k] := SATURATE16(__b[31+j:j])
183/// result[143+k:128+k] := SATURATE16(__a[159+j:128+j])
184/// result[207+k:192+k] := SATURATE16(__b[159+j:128+j])
185/// ENDFOR
186/// \endcode
187///
188/// \headerfile <immintrin.h>
189///
190/// This intrinsic corresponds to the \c VPACKSSDW instruction.
191///
192/// \param __a
193/// A 256-bit vector of [8 x i32] used to generate result[63:0] and
194/// result[191:128].
195/// \param __b
196/// A 256-bit vector of [8 x i32] used to generate result[127:64] and
197/// result[255:192].
198/// \returns A 256-bit vector of [16 x i16] containing the result.
199static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
200_mm256_packs_epi32(__m256i __a, __m256i __b) {
201 return (__m256i)__builtin_ia32_packssdw256((__v8si)__a, (__v8si)__b);
202}
203
204/// Converts elements from two 256-bit vectors of [16 x i16] to 8-bit integers
205/// using unsigned saturation, and returns the 256-bit result.
206///
207/// \code{.operation}
208/// FOR i := 0 TO 7
209/// j := i*16
210/// k := i*8
211/// result[7+k:k] := SATURATE8U(__a[15+j:j])
212/// result[71+k:64+k] := SATURATE8U(__b[15+j:j])
213/// result[135+k:128+k] := SATURATE8U(__a[143+j:128+j])
214/// result[199+k:192+k] := SATURATE8U(__b[143+j:128+j])
215/// ENDFOR
216/// \endcode
217///
218/// \headerfile <immintrin.h>
219///
220/// This intrinsic corresponds to the \c VPACKUSWB instruction.
221///
222/// \param __a
223/// A 256-bit vector of [16 x i16] used to generate result[63:0] and
224/// result[191:128].
225/// \param __b
226/// A 256-bit vector of [16 x i16] used to generate result[127:64] and
227/// result[255:192].
228/// \returns A 256-bit integer vector containing the result.
229static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
230_mm256_packus_epi16(__m256i __a, __m256i __b) {
231 return (__m256i)__builtin_ia32_packuswb256((__v16hi)__a, (__v16hi)__b);
232}
233
234/// Converts elements from two 256-bit vectors of [8 x i32] to 16-bit integers
235/// using unsigned saturation, and returns the resulting 256-bit vector of
236/// [16 x i16].
237///
238/// \code{.operation}
239/// FOR i := 0 TO 3
240/// j := i*32
241/// k := i*16
242/// result[15+k:k] := SATURATE16U(__V1[31+j:j])
243/// result[79+k:64+k] := SATURATE16U(__V2[31+j:j])
244/// result[143+k:128+k] := SATURATE16U(__V1[159+j:128+j])
245/// result[207+k:192+k] := SATURATE16U(__V2[159+j:128+j])
246/// ENDFOR
247/// \endcode
248///
249/// \headerfile <immintrin.h>
250///
251/// This intrinsic corresponds to the \c VPACKUSDW instruction.
252///
253/// \param __V1
254/// A 256-bit vector of [8 x i32] used to generate result[63:0] and
255/// result[191:128].
256/// \param __V2
257/// A 256-bit vector of [8 x i32] used to generate result[127:64] and
258/// result[255:192].
259/// \returns A 256-bit vector of [16 x i16] containing the result.
260static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
261_mm256_packus_epi32(__m256i __V1, __m256i __V2) {
262 return (__m256i) __builtin_ia32_packusdw256((__v8si)__V1, (__v8si)__V2);
263}
264
265/// Adds 8-bit integers from corresponding bytes of two 256-bit integer
266/// vectors and returns the lower 8 bits of each sum in the corresponding
267/// byte of the 256-bit integer vector result (overflow is ignored).
268///
269/// \headerfile <immintrin.h>
270///
271/// This intrinsic corresponds to the \c VPADDB instruction.
272///
273/// \param __a
274/// A 256-bit integer vector containing one of the source operands.
275/// \param __b
276/// A 256-bit integer vector containing one of the source operands.
277/// \returns A 256-bit integer vector containing the sums.
278static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
279_mm256_add_epi8(__m256i __a, __m256i __b) {
280 return (__m256i)((__v32qu)__a + (__v32qu)__b);
281}
282
283/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of
284/// [16 x i16] and returns the lower 16 bits of each sum in the
285/// corresponding element of the [16 x i16] result (overflow is ignored).
286///
287/// \headerfile <immintrin.h>
288///
289/// This intrinsic corresponds to the \c VPADDW instruction.
290///
291/// \param __a
292/// A 256-bit vector of [16 x i16] containing one of the source operands.
293/// \param __b
294/// A 256-bit vector of [16 x i16] containing one of the source operands.
295/// \returns A 256-bit vector of [16 x i16] containing the sums.
296static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
297_mm256_add_epi16(__m256i __a, __m256i __b) {
298 return (__m256i)((__v16hu)__a + (__v16hu)__b);
299}
300
301/// Adds 32-bit integers from corresponding elements of two 256-bit vectors of
302/// [8 x i32] and returns the lower 32 bits of each sum in the corresponding
303/// element of the [8 x i32] result (overflow is ignored).
304///
305/// \headerfile <immintrin.h>
306///
307/// This intrinsic corresponds to the \c VPADDD instruction.
308///
309/// \param __a
310/// A 256-bit vector of [8 x i32] containing one of the source operands.
311/// \param __b
312/// A 256-bit vector of [8 x i32] containing one of the source operands.
313/// \returns A 256-bit vector of [8 x i32] containing the sums.
314static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
315_mm256_add_epi32(__m256i __a, __m256i __b) {
316 return (__m256i)((__v8su)__a + (__v8su)__b);
317}
318
319/// Adds 64-bit integers from corresponding elements of two 256-bit vectors of
320/// [4 x i64] and returns the lower 64 bits of each sum in the corresponding
321/// element of the [4 x i64] result (overflow is ignored).
322///
323/// \headerfile <immintrin.h>
324///
325/// This intrinsic corresponds to the \c VPADDQ instruction.
326///
327/// \param __a
328/// A 256-bit vector of [4 x i64] containing one of the source operands.
329/// \param __b
330/// A 256-bit vector of [4 x i64] containing one of the source operands.
331/// \returns A 256-bit vector of [4 x i64] containing the sums.
332static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
333_mm256_add_epi64(__m256i __a, __m256i __b) {
334 return (__m256i)((__v4du)__a + (__v4du)__b);
335}
336
337/// Adds 8-bit integers from corresponding bytes of two 256-bit integer
338/// vectors using signed saturation, and returns each sum in the
339/// corresponding byte of the 256-bit integer vector result.
340///
341/// \headerfile <immintrin.h>
342///
343/// This intrinsic corresponds to the \c VPADDSB instruction.
344///
345/// \param __a
346/// A 256-bit integer vector containing one of the source operands.
347/// \param __b
348/// A 256-bit integer vector containing one of the source operands.
349/// \returns A 256-bit integer vector containing the sums.
350static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
351_mm256_adds_epi8(__m256i __a, __m256i __b) {
352 return (__m256i)__builtin_elementwise_add_sat((__v32qs)__a, (__v32qs)__b);
353}
354
355/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of
356/// [16 x i16] using signed saturation, and returns the [16 x i16] result.
357///
358/// \headerfile <immintrin.h>
359///
360/// This intrinsic corresponds to the \c VPADDSW instruction.
361///
362/// \param __a
363/// A 256-bit vector of [16 x i16] containing one of the source operands.
364/// \param __b
365/// A 256-bit vector of [16 x i16] containing one of the source operands.
366/// \returns A 256-bit vector of [16 x i16] containing the sums.
367static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
368_mm256_adds_epi16(__m256i __a, __m256i __b) {
369 return (__m256i)__builtin_elementwise_add_sat((__v16hi)__a, (__v16hi)__b);
370}
371
372/// Adds 8-bit integers from corresponding bytes of two 256-bit integer
373/// vectors using unsigned saturation, and returns each sum in the
374/// corresponding byte of the 256-bit integer vector result.
375///
376/// \headerfile <immintrin.h>
377///
378/// This intrinsic corresponds to the \c VPADDUSB instruction.
379///
380/// \param __a
381/// A 256-bit integer vector containing one of the source operands.
382/// \param __b
383/// A 256-bit integer vector containing one of the source operands.
384/// \returns A 256-bit integer vector containing the sums.
385static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
386_mm256_adds_epu8(__m256i __a, __m256i __b) {
387 return (__m256i)__builtin_elementwise_add_sat((__v32qu)__a, (__v32qu)__b);
388}
389
390/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of
391/// [16 x i16] using unsigned saturation, and returns the [16 x i16] result.
392///
393/// \headerfile <immintrin.h>
394///
395/// This intrinsic corresponds to the \c VPADDUSW instruction.
396///
397/// \param __a
398/// A 256-bit vector of [16 x i16] containing one of the source operands.
399/// \param __b
400/// A 256-bit vector of [16 x i16] containing one of the source operands.
401/// \returns A 256-bit vector of [16 x i16] containing the sums.
402static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
403_mm256_adds_epu16(__m256i __a, __m256i __b) {
404 return (__m256i)__builtin_elementwise_add_sat((__v16hu)__a, (__v16hu)__b);
405}
406
407/// Uses the lower half of the 256-bit vector \a a as the upper half of a
408/// temporary 256-bit value, and the lower half of the 256-bit vector \a b
409/// as the lower half of the temporary value. Right-shifts the temporary
410/// value by \a n bytes, and uses the lower 16 bytes of the shifted value
411/// as the lower 16 bytes of the result. Uses the upper halves of \a a and
412/// \a b to make another temporary value, right shifts by \a n, and uses
413/// the lower 16 bytes of the shifted value as the upper 16 bytes of the
414/// result.
415///
416/// \headerfile <immintrin.h>
417///
418/// \code
419/// __m256i _mm256_alignr_epi8(__m256i a, __m256i b, const int n);
420/// \endcode
421///
422/// This intrinsic corresponds to the \c VPALIGNR instruction.
423///
424/// \param a
425/// A 256-bit integer vector containing source values.
426/// \param b
427/// A 256-bit integer vector containing source values.
428/// \param n
429/// An immediate value specifying the number of bytes to shift.
430/// \returns A 256-bit integer vector containing the result.
431#define _mm256_alignr_epi8(a, b, n) \
432 ((__m256i)__builtin_ia32_palignr256((__v32qi)(__m256i)(a), \
433 (__v32qi)(__m256i)(b), (n)))
434
435/// Computes the bitwise AND of the 256-bit integer vectors in \a __a and
436/// \a __b.
437///
438/// \headerfile <immintrin.h>
439///
440/// This intrinsic corresponds to the \c VPAND instruction.
441///
442/// \param __a
443/// A 256-bit integer vector.
444/// \param __b
445/// A 256-bit integer vector.
446/// \returns A 256-bit integer vector containing the result.
447static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
448_mm256_and_si256(__m256i __a, __m256i __b)
449{
450 return (__m256i)((__v4du)__a & (__v4du)__b);
451}
452
453/// Computes the bitwise AND of the 256-bit integer vector in \a __b with
454/// the bitwise NOT of the 256-bit integer vector in \a __a.
455///
456/// \headerfile <immintrin.h>
457///
458/// This intrinsic corresponds to the \c VPANDN instruction.
459///
460/// \param __a
461/// A 256-bit integer vector.
462/// \param __b
463/// A 256-bit integer vector.
464/// \returns A 256-bit integer vector containing the result.
465static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
466_mm256_andnot_si256(__m256i __a, __m256i __b)
467{
468 return (__m256i)(~(__v4du)__a & (__v4du)__b);
469}
470
471/// Computes the averages of the corresponding unsigned bytes in the two
472/// 256-bit integer vectors in \a __a and \a __b and returns each
473/// average in the corresponding byte of the 256-bit result.
474///
475/// \code{.operation}
476/// FOR i := 0 TO 31
477/// j := i*8
478/// result[j+7:j] := (__a[j+7:j] + __b[j+7:j] + 1) >> 1
479/// ENDFOR
480/// \endcode
481///
482/// \headerfile <immintrin.h>
483///
484/// This intrinsic corresponds to the \c VPAVGB instruction.
485///
486/// \param __a
487/// A 256-bit integer vector.
488/// \param __b
489/// A 256-bit integer vector.
490/// \returns A 256-bit integer vector containing the result.
491static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
492_mm256_avg_epu8(__m256i __a, __m256i __b) {
493 return (__m256i)__builtin_ia32_pavgb256((__v32qu)__a, (__v32qu)__b);
494}
495
496/// Computes the averages of the corresponding unsigned 16-bit integers in
497/// the two 256-bit vectors of [16 x i16] in \a __a and \a __b and returns
498/// each average in the corresponding element of the 256-bit result.
499///
500/// \code{.operation}
501/// FOR i := 0 TO 15
502/// j := i*16
503/// result[j+15:j] := (__a[j+15:j] + __b[j+15:j] + 1) >> 1
504/// ENDFOR
505/// \endcode
506///
507/// \headerfile <immintrin.h>
508///
509/// This intrinsic corresponds to the \c VPAVGW instruction.
510///
511/// \param __a
512/// A 256-bit vector of [16 x i16].
513/// \param __b
514/// A 256-bit vector of [16 x i16].
515/// \returns A 256-bit vector of [16 x i16] containing the result.
516static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
517_mm256_avg_epu16(__m256i __a, __m256i __b) {
518 return (__m256i)__builtin_ia32_pavgw256((__v16hu)__a, (__v16hu)__b);
519}
520
521/// Merges 8-bit integer values from either of the two 256-bit vectors
522/// \a __V1 or \a __V2, as specified by the 256-bit mask \a __M and returns
523/// the resulting 256-bit integer vector.
524///
525/// \code{.operation}
526/// FOR i := 0 TO 31
527/// j := i*8
528/// IF __M[7+i] == 0
529/// result[7+j:j] := __V1[7+j:j]
530/// ELSE
531/// result[7+j:j] := __V2[7+j:j]
532/// FI
533/// ENDFOR
534/// \endcode
535///
536/// \headerfile <immintrin.h>
537///
538/// This intrinsic corresponds to the \c VPBLENDVB instruction.
539///
540/// \param __V1
541/// A 256-bit integer vector containing source values.
542/// \param __V2
543/// A 256-bit integer vector containing source values.
544/// \param __M
545/// A 256-bit integer vector, with bit [7] of each byte specifying the
546/// source for each corresponding byte of the result. When the mask bit
547/// is 0, the byte is copied from \a __V1; otherwise, it is copied from
548/// \a __V2.
549/// \returns A 256-bit integer vector containing the result.
550static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
551_mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M) {
552 return (__m256i)__builtin_ia32_pblendvb256((__v32qi)__V1, (__v32qi)__V2,
553 (__v32qi)__M);
554}
555
556/// Merges 16-bit integer values from either of the two 256-bit vectors
557/// \a V1 or \a V2, as specified by the immediate integer operand \a M,
558/// and returns the resulting 256-bit vector of [16 x i16].
559///
560/// \code{.operation}
561/// FOR i := 0 TO 7
562/// j := i*16
563/// IF M[i] == 0
564/// result[7+j:j] := V1[7+j:j]
565/// result[135+j:128+j] := V1[135+j:128+j]
566/// ELSE
567/// result[7+j:j] := V2[7+j:j]
568/// result[135+j:128+j] := V2[135+j:128+j]
569/// FI
570/// ENDFOR
571/// \endcode
572///
573/// \headerfile <immintrin.h>
574///
575/// \code
576/// __m256i _mm256_blend_epi16(__m256i V1, __m256i V2, const int M);
577/// \endcode
578///
579/// This intrinsic corresponds to the \c VPBLENDW instruction.
580///
581/// \param V1
582/// A 256-bit vector of [16 x i16] containing source values.
583/// \param V2
584/// A 256-bit vector of [16 x i16] containing source values.
585/// \param M
586/// An immediate 8-bit integer operand, with bits [7:0] specifying the
587/// source for each element of the result. The position of the mask bit
588/// corresponds to the index of a copied value. When a mask bit is 0, the
589/// element is copied from \a V1; otherwise, it is copied from \a V2.
590/// \a M[0] determines the source for elements 0 and 8, \a M[1] for
591/// elements 1 and 9, and so forth.
592/// \returns A 256-bit vector of [16 x i16] containing the result.
593#define _mm256_blend_epi16(V1, V2, M) \
594 ((__m256i)__builtin_ia32_pblendw256((__v16hi)(__m256i)(V1), \
595 (__v16hi)(__m256i)(V2), (int)(M)))
596
597/// Compares corresponding bytes in the 256-bit integer vectors in \a __a and
598/// \a __b for equality and returns the outcomes in the corresponding
599/// bytes of the 256-bit result.
600///
601/// \code{.operation}
602/// FOR i := 0 TO 31
603/// j := i*8
604/// result[j+7:j] := (__a[j+7:j] == __b[j+7:j]) ? 0xFF : 0
605/// ENDFOR
606/// \endcode
607///
608/// \headerfile <immintrin.h>
609///
610/// This intrinsic corresponds to the \c VPCMPEQB instruction.
611///
612/// \param __a
613/// A 256-bit integer vector containing one of the inputs.
614/// \param __b
615/// A 256-bit integer vector containing one of the inputs.
616/// \returns A 256-bit integer vector containing the result.
617static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
618_mm256_cmpeq_epi8(__m256i __a, __m256i __b)
619{
620 return (__m256i)((__v32qi)__a == (__v32qi)__b);
621}
622
623/// Compares corresponding elements in the 256-bit vectors of [16 x i16] in
624/// \a __a and \a __b for equality and returns the outcomes in the
625/// corresponding elements of the 256-bit result.
626///
627/// \code{.operation}
628/// FOR i := 0 TO 15
629/// j := i*16
630/// result[j+15:j] := (__a[j+15:j] == __b[j+15:j]) ? 0xFFFF : 0
631/// ENDFOR
632/// \endcode
633///
634/// \headerfile <immintrin.h>
635///
636/// This intrinsic corresponds to the \c VPCMPEQW instruction.
637///
638/// \param __a
639/// A 256-bit vector of [16 x i16] containing one of the inputs.
640/// \param __b
641/// A 256-bit vector of [16 x i16] containing one of the inputs.
642/// \returns A 256-bit vector of [16 x i16] containing the result.
643static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
644_mm256_cmpeq_epi16(__m256i __a, __m256i __b)
645{
646 return (__m256i)((__v16hi)__a == (__v16hi)__b);
647}
648
649/// Compares corresponding elements in the 256-bit vectors of [8 x i32] in
650/// \a __a and \a __b for equality and returns the outcomes in the
651/// corresponding elements of the 256-bit result.
652///
653/// \code{.operation}
654/// FOR i := 0 TO 7
655/// j := i*32
656/// result[j+31:j] := (__a[j+31:j] == __b[j+31:j]) ? 0xFFFFFFFF : 0
657/// ENDFOR
658/// \endcode
659///
660/// \headerfile <immintrin.h>
661///
662/// This intrinsic corresponds to the \c VPCMPEQD instruction.
663///
664/// \param __a
665/// A 256-bit vector of [8 x i32] containing one of the inputs.
666/// \param __b
667/// A 256-bit vector of [8 x i32] containing one of the inputs.
668/// \returns A 256-bit vector of [8 x i32] containing the result.
669static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
670_mm256_cmpeq_epi32(__m256i __a, __m256i __b)
671{
672 return (__m256i)((__v8si)__a == (__v8si)__b);
673}
674
675/// Compares corresponding elements in the 256-bit vectors of [4 x i64] in
676/// \a __a and \a __b for equality and returns the outcomes in the
677/// corresponding elements of the 256-bit result.
678///
679/// \code{.operation}
680/// FOR i := 0 TO 3
681/// j := i*64
682/// result[j+63:j] := (__a[j+63:j] == __b[j+63:j]) ? 0xFFFFFFFFFFFFFFFF : 0
683/// ENDFOR
684/// \endcode
685///
686/// \headerfile <immintrin.h>
687///
688/// This intrinsic corresponds to the \c VPCMPEQQ instruction.
689///
690/// \param __a
691/// A 256-bit vector of [4 x i64] containing one of the inputs.
692/// \param __b
693/// A 256-bit vector of [4 x i64] containing one of the inputs.
694/// \returns A 256-bit vector of [4 x i64] containing the result.
695static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
696_mm256_cmpeq_epi64(__m256i __a, __m256i __b)
697{
698 return (__m256i)((__v4di)__a == (__v4di)__b);
699}
700
701/// Compares corresponding signed bytes in the 256-bit integer vectors in
702/// \a __a and \a __b for greater-than and returns the outcomes in the
703/// corresponding bytes of the 256-bit result.
704///
705/// \code{.operation}
706/// FOR i := 0 TO 31
707/// j := i*8
708/// result[j+7:j] := (__a[j+7:j] > __b[j+7:j]) ? 0xFF : 0
709/// ENDFOR
710/// \endcode
711///
712/// \headerfile <immintrin.h>
713///
714/// This intrinsic corresponds to the \c VPCMPGTB instruction.
715///
716/// \param __a
717/// A 256-bit integer vector containing one of the inputs.
718/// \param __b
719/// A 256-bit integer vector containing one of the inputs.
720/// \returns A 256-bit integer vector containing the result.
721static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
722_mm256_cmpgt_epi8(__m256i __a, __m256i __b)
723{
724 /* This function always performs a signed comparison, but __v32qi is a char
725 which may be signed or unsigned, so use __v32qs. */
726 return (__m256i)((__v32qs)__a > (__v32qs)__b);
727}
728
729/// Compares corresponding signed elements in the 256-bit vectors of
730/// [16 x i16] in \a __a and \a __b for greater-than and returns the
731/// outcomes in the corresponding elements of the 256-bit result.
732///
733/// \code{.operation}
734/// FOR i := 0 TO 15
735/// j := i*16
736/// result[j+15:j] := (__a[j+15:j] > __b[j+15:j]) ? 0xFFFF : 0
737/// ENDFOR
738/// \endcode
739///
740/// \headerfile <immintrin.h>
741///
742/// This intrinsic corresponds to the \c VPCMPGTW instruction.
743///
744/// \param __a
745/// A 256-bit vector of [16 x i16] containing one of the inputs.
746/// \param __b
747/// A 256-bit vector of [16 x i16] containing one of the inputs.
748/// \returns A 256-bit vector of [16 x i16] containing the result.
749static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
750_mm256_cmpgt_epi16(__m256i __a, __m256i __b)
751{
752 return (__m256i)((__v16hi)__a > (__v16hi)__b);
753}
754
755/// Compares corresponding signed elements in the 256-bit vectors of
756/// [8 x i32] in \a __a and \a __b for greater-than and returns the
757/// outcomes in the corresponding elements of the 256-bit result.
758///
759/// \code{.operation}
760/// FOR i := 0 TO 7
761/// j := i*32
762/// result[j+31:j] := (__a[j+31:j] > __b[j+31:j]) ? 0xFFFFFFFF : 0
763/// ENDFOR
764/// \endcode
765///
766/// \headerfile <immintrin.h>
767///
768/// This intrinsic corresponds to the \c VPCMPGTD instruction.
769///
770/// \param __a
771/// A 256-bit vector of [8 x i32] containing one of the inputs.
772/// \param __b
773/// A 256-bit vector of [8 x i32] containing one of the inputs.
774/// \returns A 256-bit vector of [8 x i32] containing the result.
775static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
776_mm256_cmpgt_epi32(__m256i __a, __m256i __b)
777{
778 return (__m256i)((__v8si)__a > (__v8si)__b);
779}
780
781/// Compares corresponding signed elements in the 256-bit vectors of
782/// [4 x i64] in \a __a and \a __b for greater-than and returns the
783/// outcomes in the corresponding elements of the 256-bit result.
784///
785/// \code{.operation}
786/// FOR i := 0 TO 3
787/// j := i*64
788/// result[j+63:j] := (__a[j+63:j] > __b[j+63:j]) ? 0xFFFFFFFFFFFFFFFF : 0
789/// ENDFOR
790/// \endcode
791///
792/// \headerfile <immintrin.h>
793///
794/// This intrinsic corresponds to the \c VPCMPGTQ instruction.
795///
796/// \param __a
797/// A 256-bit vector of [4 x i64] containing one of the inputs.
798/// \param __b
799/// A 256-bit vector of [4 x i64] containing one of the inputs.
800/// \returns A 256-bit vector of [4 x i64] containing the result.
801static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
802_mm256_cmpgt_epi64(__m256i __a, __m256i __b)
803{
804 return (__m256i)((__v4di)__a > (__v4di)__b);
805}
806
807/// Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit
808/// vectors of [16 x i16] and returns the lower 16 bits of each sum in an
809/// element of the [16 x i16] result (overflow is ignored). Sums from
810/// \a __a are returned in the lower 64 bits of each 128-bit half of the
811/// result; sums from \a __b are returned in the upper 64 bits of each
812/// 128-bit half of the result.
813///
814/// \code{.operation}
815/// FOR i := 0 TO 1
816/// j := i*128
817/// result[j+15:j] := __a[j+15:j] + __a[j+31:j+16]
818/// result[j+31:j+16] := __a[j+47:j+32] + __a[j+63:j+48]
819/// result[j+47:j+32] := __a[j+79:j+64] + __a[j+95:j+80]
820/// result[j+63:j+48] := __a[j+111:j+96] + __a[j+127:j+112]
821/// result[j+79:j+64] := __b[j+15:j] + __b[j+31:j+16]
822/// result[j+95:j+80] := __b[j+47:j+32] + __b[j+63:j+48]
823/// result[j+111:j+96] := __b[j+79:j+64] + __b[j+95:j+80]
824/// result[j+127:j+112] := __b[j+111:j+96] + __b[j+127:j+112]
825/// ENDFOR
826/// \endcode
827///
828/// \headerfile <immintrin.h>
829///
830/// This intrinsic corresponds to the \c VPHADDW instruction.
831///
832/// \param __a
833/// A 256-bit vector of [16 x i16] containing one of the source operands.
834/// \param __b
835/// A 256-bit vector of [16 x i16] containing one of the source operands.
836/// \returns A 256-bit vector of [16 x i16] containing the sums.
837static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
838_mm256_hadd_epi16(__m256i __a, __m256i __b) {
839 return (__m256i)__builtin_ia32_phaddw256((__v16hi)__a, (__v16hi)__b);
840}
841
842/// Horizontally adds the adjacent pairs of 32-bit integers from two 256-bit
843/// vectors of [8 x i32] and returns the lower 32 bits of each sum in an
844/// element of the [8 x i32] result (overflow is ignored). Sums from \a __a
845/// are returned in the lower 64 bits of each 128-bit half of the result;
846/// sums from \a __b are returned in the upper 64 bits of each 128-bit half
847/// of the result.
848///
849/// \code{.operation}
850/// FOR i := 0 TO 1
851/// j := i*128
852/// result[j+31:j] := __a[j+31:j] + __a[j+63:j+32]
853/// result[j+63:j+32] := __a[j+95:j+64] + __a[j+127:j+96]
854/// result[j+95:j+64] := __b[j+31:j] + __b[j+63:j+32]
855/// result[j+127:j+96] := __b[j+95:j+64] + __b[j+127:j+96]
856/// ENDFOR
857/// \endcode
858///
859/// \headerfile <immintrin.h>
860///
861/// This intrinsic corresponds to the \c VPHADDD instruction.
862///
863/// \param __a
864/// A 256-bit vector of [8 x i32] containing one of the source operands.
865/// \param __b
866/// A 256-bit vector of [8 x i32] containing one of the source operands.
867/// \returns A 256-bit vector of [8 x i32] containing the sums.
868static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
869_mm256_hadd_epi32(__m256i __a, __m256i __b) {
870 return (__m256i)__builtin_ia32_phaddd256((__v8si)__a, (__v8si)__b);
871}
872
873/// Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit
874/// vectors of [16 x i16] using signed saturation and returns each sum in
875/// an element of the [16 x i16] result. Sums from \a __a are returned in
876/// the lower 64 bits of each 128-bit half of the result; sums from \a __b
877/// are returned in the upper 64 bits of each 128-bit half of the result.
878///
879/// \code{.operation}
880/// FOR i := 0 TO 1
881/// j := i*128
882/// result[j+15:j] := SATURATE16(__a[j+15:j] + __a[j+31:j+16])
883/// result[j+31:j+16] := SATURATE16(__a[j+47:j+32] + __a[j+63:j+48])
884/// result[j+47:j+32] := SATURATE16(__a[j+79:j+64] + __a[j+95:j+80])
885/// result[j+63:j+48] := SATURATE16(__a[j+111:j+96] + __a[j+127:j+112])
886/// result[j+79:j+64] := SATURATE16(__b[j+15:j] + __b[j+31:j+16])
887/// result[j+95:j+80] := SATURATE16(__b[j+47:j+32] + __b[j+63:j+48])
888/// result[j+111:j+96] := SATURATE16(__b[j+79:j+64] + __b[j+95:j+80])
889/// result[j+127:j+112] := SATURATE16(__b[j+111:j+96] + __b[j+127:j+112])
890/// ENDFOR
891/// \endcode
892///
893/// \headerfile <immintrin.h>
894///
895/// This intrinsic corresponds to the \c VPHADDSW instruction.
896///
897/// \param __a
898/// A 256-bit vector of [16 x i16] containing one of the source operands.
899/// \param __b
900/// A 256-bit vector of [16 x i16] containing one of the source operands.
901/// \returns A 256-bit vector of [16 x i16] containing the sums.
902static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
903_mm256_hadds_epi16(__m256i __a, __m256i __b) {
904 return (__m256i)__builtin_ia32_phaddsw256((__v16hi)__a, (__v16hi)__b);
905}
906
907/// Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit
908/// vectors of [16 x i16] and returns the lower 16 bits of each difference
909/// in an element of the [16 x i16] result (overflow is ignored).
910/// Differences from \a __a are returned in the lower 64 bits of each
911/// 128-bit half of the result; differences from \a __b are returned in the
912/// upper 64 bits of each 128-bit half of the result.
913///
914/// \code{.operation}
915/// FOR i := 0 TO 1
916/// j := i*128
917/// result[j+15:j] := __a[j+15:j] - __a[j+31:j+16]
918/// result[j+31:j+16] := __a[j+47:j+32] - __a[j+63:j+48]
919/// result[j+47:j+32] := __a[j+79:j+64] - __a[j+95:j+80]
920/// result[j+63:j+48] := __a[j+111:j+96] - __a[j+127:j+112]
921/// result[j+79:j+64] := __b[j+15:j] - __b[j+31:j+16]
922/// result[j+95:j+80] := __b[j+47:j+32] - __b[j+63:j+48]
923/// result[j+111:j+96] := __b[j+79:j+64] - __b[j+95:j+80]
924/// result[j+127:j+112] := __b[j+111:j+96] - __b[j+127:j+112]
925/// ENDFOR
926/// \endcode
927///
928/// \headerfile <immintrin.h>
929///
930/// This intrinsic corresponds to the \c VPHSUBW instruction.
931///
932/// \param __a
933/// A 256-bit vector of [16 x i16] containing one of the source operands.
934/// \param __b
935/// A 256-bit vector of [16 x i16] containing one of the source operands.
936/// \returns A 256-bit vector of [16 x i16] containing the differences.
937static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
938_mm256_hsub_epi16(__m256i __a, __m256i __b) {
939 return (__m256i)__builtin_ia32_phsubw256((__v16hi)__a, (__v16hi)__b);
940}
941
942/// Horizontally subtracts adjacent pairs of 32-bit integers from two 256-bit
943/// vectors of [8 x i32] and returns the lower 32 bits of each difference in
944/// an element of the [8 x i32] result (overflow is ignored). Differences
945/// from \a __a are returned in the lower 64 bits of each 128-bit half of
946/// the result; differences from \a __b are returned in the upper 64 bits
947/// of each 128-bit half of the result.
948///
949/// \code{.operation}
950/// FOR i := 0 TO 1
951/// j := i*128
952/// result[j+31:j] := __a[j+31:j] - __a[j+63:j+32]
953/// result[j+63:j+32] := __a[j+95:j+64] - __a[j+127:j+96]
954/// result[j+95:j+64] := __b[j+31:j] - __b[j+63:j+32]
955/// result[j+127:j+96] := __b[j+95:j+64] - __b[j+127:j+96]
956/// ENDFOR
957/// \endcode
958///
959/// \headerfile <immintrin.h>
960///
961/// This intrinsic corresponds to the \c VPHSUBD instruction.
962///
963/// \param __a
964/// A 256-bit vector of [8 x i32] containing one of the source operands.
965/// \param __b
966/// A 256-bit vector of [8 x i32] containing one of the source operands.
967/// \returns A 256-bit vector of [8 x i32] containing the differences.
968static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
969_mm256_hsub_epi32(__m256i __a, __m256i __b) {
970 return (__m256i)__builtin_ia32_phsubd256((__v8si)__a, (__v8si)__b);
971}
972
973/// Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit
974/// vectors of [16 x i16] using signed saturation and returns each sum in
975/// an element of the [16 x i16] result. Differences from \a __a are
976/// returned in the lower 64 bits of each 128-bit half of the result;
977/// differences from \a __b are returned in the upper 64 bits of each
978/// 128-bit half of the result.
979///
980/// \code{.operation}
981/// FOR i := 0 TO 1
982/// j := i*128
983/// result[j+15:j] := SATURATE16(__a[j+15:j] - __a[j+31:j+16])
984/// result[j+31:j+16] := SATURATE16(__a[j+47:j+32] - __a[j+63:j+48])
985/// result[j+47:j+32] := SATURATE16(__a[j+79:j+64] - __a[j+95:j+80])
986/// result[j+63:j+48] := SATURATE16(__a[j+111:j+96] - __a[j+127:j+112])
987/// result[j+79:j+64] := SATURATE16(__b[j+15:j] - __b[j+31:j+16])
988/// result[j+95:j+80] := SATURATE16(__b[j+47:j+32] - __b[j+63:j+48])
989/// result[j+111:j+96] := SATURATE16(__b[j+79:j+64] - __b[j+95:j+80])
990/// result[j+127:j+112] := SATURATE16(__b[j+111:j+96] - __b[j+127:j+112])
991/// ENDFOR
992/// \endcode
993///
994/// \headerfile <immintrin.h>
995///
996/// This intrinsic corresponds to the \c VPHSUBSW instruction.
997///
998/// \param __a
999/// A 256-bit vector of [16 x i16] containing one of the source operands.
1000/// \param __b
1001/// A 256-bit vector of [16 x i16] containing one of the source operands.
1002/// \returns A 256-bit vector of [16 x i16] containing the differences.
1003static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1004_mm256_hsubs_epi16(__m256i __a, __m256i __b) {
1005 return (__m256i)__builtin_ia32_phsubsw256((__v16hi)__a, (__v16hi)__b);
1006}
1007
1008/// Multiplies each unsigned byte from the 256-bit integer vector in \a __a
1009/// with the corresponding signed byte from the 256-bit integer vector in
1010/// \a __b, forming signed 16-bit intermediate products. Adds adjacent
1011/// pairs of those products using signed saturation to form 16-bit sums
1012/// returned as elements of the [16 x i16] result.
1013///
1014/// \code{.operation}
1015/// FOR i := 0 TO 15
1016/// j := i*16
1017/// temp1 := __a[j+7:j] * __b[j+7:j]
1018/// temp2 := __a[j+15:j+8] * __b[j+15:j+8]
1019/// result[j+15:j] := SATURATE16(temp1 + temp2)
1020/// ENDFOR
1021/// \endcode
1022///
1023/// \headerfile <immintrin.h>
1024///
1025/// This intrinsic corresponds to the \c VPMADDUBSW instruction.
1026///
1027/// \param __a
1028/// A 256-bit vector containing one of the source operands.
1029/// \param __b
1030/// A 256-bit vector containing one of the source operands.
1031/// \returns A 256-bit vector of [16 x i16] containing the result.
1032static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1033_mm256_maddubs_epi16(__m256i __a, __m256i __b) {
1034 return (__m256i)__builtin_ia32_pmaddubsw256((__v32qi)__a, (__v32qi)__b);
1035}
1036
1037/// Multiplies corresponding 16-bit elements of two 256-bit vectors of
1038/// [16 x i16], forming 32-bit intermediate products, and adds pairs of
1039/// those products to form 32-bit sums returned as elements of the
1040/// [8 x i32] result.
1041///
1042/// There is only one wraparound case: when all four of the 16-bit sources
1043/// are \c 0x8000, the result will be \c 0x80000000.
1044///
1045/// \code{.operation}
1046/// FOR i := 0 TO 7
1047/// j := i*32
1048/// temp1 := __a[j+15:j] * __b[j+15:j]
1049/// temp2 := __a[j+31:j+16] * __b[j+31:j+16]
1050/// result[j+31:j] := temp1 + temp2
1051/// ENDFOR
1052/// \endcode
1053///
1054/// \headerfile <immintrin.h>
1055///
1056/// This intrinsic corresponds to the \c VPMADDWD instruction.
1057///
1058/// \param __a
1059/// A 256-bit vector of [16 x i16] containing one of the source operands.
1060/// \param __b
1061/// A 256-bit vector of [16 x i16] containing one of the source operands.
1062/// \returns A 256-bit vector of [8 x i32] containing the result.
1063static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1064_mm256_madd_epi16(__m256i __a, __m256i __b) {
1065 return (__m256i)__builtin_ia32_pmaddwd256((__v16hi)__a, (__v16hi)__b);
1066}
1067
1068/// Compares the corresponding signed bytes in the two 256-bit integer vectors
1069/// in \a __a and \a __b and returns the larger of each pair in the
1070/// corresponding byte of the 256-bit result.
1071///
1072/// \headerfile <immintrin.h>
1073///
1074/// This intrinsic corresponds to the \c VPMAXSB instruction.
1075///
1076/// \param __a
1077/// A 256-bit integer vector.
1078/// \param __b
1079/// A 256-bit integer vector.
1080/// \returns A 256-bit integer vector containing the result.
1081static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1082_mm256_max_epi8(__m256i __a, __m256i __b) {
1083 return (__m256i)__builtin_elementwise_max((__v32qs)__a, (__v32qs)__b);
1084}
1085
1086/// Compares the corresponding signed 16-bit integers in the two 256-bit
1087/// vectors of [16 x i16] in \a __a and \a __b and returns the larger of
1088/// each pair in the corresponding element of the 256-bit result.
1089///
1090/// \headerfile <immintrin.h>
1091///
1092/// This intrinsic corresponds to the \c VPMAXSW instruction.
1093///
1094/// \param __a
1095/// A 256-bit vector of [16 x i16].
1096/// \param __b
1097/// A 256-bit vector of [16 x i16].
1098/// \returns A 256-bit vector of [16 x i16] containing the result.
1099static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1100_mm256_max_epi16(__m256i __a, __m256i __b) {
1101 return (__m256i)__builtin_elementwise_max((__v16hi)__a, (__v16hi)__b);
1102}
1103
1104/// Compares the corresponding signed 32-bit integers in the two 256-bit
1105/// vectors of [8 x i32] in \a __a and \a __b and returns the larger of
1106/// each pair in the corresponding element of the 256-bit result.
1107///
1108/// \headerfile <immintrin.h>
1109///
1110/// This intrinsic corresponds to the \c VPMAXSD instruction.
1111///
1112/// \param __a
1113/// A 256-bit vector of [8 x i32].
1114/// \param __b
1115/// A 256-bit vector of [8 x i32].
1116/// \returns A 256-bit vector of [8 x i32] containing the result.
1117static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1118_mm256_max_epi32(__m256i __a, __m256i __b) {
1119 return (__m256i)__builtin_elementwise_max((__v8si)__a, (__v8si)__b);
1120}
1121
1122/// Compares the corresponding unsigned bytes in the two 256-bit integer
1123/// vectors in \a __a and \a __b and returns the larger of each pair in
1124/// the corresponding byte of the 256-bit result.
1125///
1126/// \headerfile <immintrin.h>
1127///
1128/// This intrinsic corresponds to the \c VPMAXUB instruction.
1129///
1130/// \param __a
1131/// A 256-bit integer vector.
1132/// \param __b
1133/// A 256-bit integer vector.
1134/// \returns A 256-bit integer vector containing the result.
1135static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1136_mm256_max_epu8(__m256i __a, __m256i __b) {
1137 return (__m256i)__builtin_elementwise_max((__v32qu)__a, (__v32qu)__b);
1138}
1139
1140/// Compares the corresponding unsigned 16-bit integers in the two 256-bit
1141/// vectors of [16 x i16] in \a __a and \a __b and returns the larger of
1142/// each pair in the corresponding element of the 256-bit result.
1143///
1144/// \headerfile <immintrin.h>
1145///
1146/// This intrinsic corresponds to the \c VPMAXUW instruction.
1147///
1148/// \param __a
1149/// A 256-bit vector of [16 x i16].
1150/// \param __b
1151/// A 256-bit vector of [16 x i16].
1152/// \returns A 256-bit vector of [16 x i16] containing the result.
1153static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1154_mm256_max_epu16(__m256i __a, __m256i __b) {
1155 return (__m256i)__builtin_elementwise_max((__v16hu)__a, (__v16hu)__b);
1156}
1157
1158/// Compares the corresponding unsigned 32-bit integers in the two 256-bit
1159/// vectors of [8 x i32] in \a __a and \a __b and returns the larger of
1160/// each pair in the corresponding element of the 256-bit result.
1161///
1162/// \headerfile <immintrin.h>
1163///
1164/// This intrinsic corresponds to the \c VPMAXUD instruction.
1165///
1166/// \param __a
1167/// A 256-bit vector of [8 x i32].
1168/// \param __b
1169/// A 256-bit vector of [8 x i32].
1170/// \returns A 256-bit vector of [8 x i32] containing the result.
1171static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1172_mm256_max_epu32(__m256i __a, __m256i __b) {
1173 return (__m256i)__builtin_elementwise_max((__v8su)__a, (__v8su)__b);
1174}
1175
1176/// Compares the corresponding signed bytes in the two 256-bit integer vectors
1177/// in \a __a and \a __b and returns the smaller of each pair in the
1178/// corresponding byte of the 256-bit result.
1179///
1180/// \headerfile <immintrin.h>
1181///
1182/// This intrinsic corresponds to the \c VPMINSB instruction.
1183///
1184/// \param __a
1185/// A 256-bit integer vector.
1186/// \param __b
1187/// A 256-bit integer vector.
1188/// \returns A 256-bit integer vector containing the result.
1189static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1190_mm256_min_epi8(__m256i __a, __m256i __b) {
1191 return (__m256i)__builtin_elementwise_min((__v32qs)__a, (__v32qs)__b);
1192}
1193
1194/// Compares the corresponding signed 16-bit integers in the two 256-bit
1195/// vectors of [16 x i16] in \a __a and \a __b and returns the smaller of
1196/// each pair in the corresponding element of the 256-bit result.
1197///
1198/// \headerfile <immintrin.h>
1199///
1200/// This intrinsic corresponds to the \c VPMINSW instruction.
1201///
1202/// \param __a
1203/// A 256-bit vector of [16 x i16].
1204/// \param __b
1205/// A 256-bit vector of [16 x i16].
1206/// \returns A 256-bit vector of [16 x i16] containing the result.
1207static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1208_mm256_min_epi16(__m256i __a, __m256i __b) {
1209 return (__m256i)__builtin_elementwise_min((__v16hi)__a, (__v16hi)__b);
1210}
1211
1212/// Compares the corresponding signed 32-bit integers in the two 256-bit
1213/// vectors of [8 x i32] in \a __a and \a __b and returns the smaller of
1214/// each pair in the corresponding element of the 256-bit result.
1215///
1216/// \headerfile <immintrin.h>
1217///
1218/// This intrinsic corresponds to the \c VPMINSD instruction.
1219///
1220/// \param __a
1221/// A 256-bit vector of [8 x i32].
1222/// \param __b
1223/// A 256-bit vector of [8 x i32].
1224/// \returns A 256-bit vector of [8 x i32] containing the result.
1225static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1226_mm256_min_epi32(__m256i __a, __m256i __b) {
1227 return (__m256i)__builtin_elementwise_min((__v8si)__a, (__v8si)__b);
1228}
1229
1230/// Compares the corresponding unsigned bytes in the two 256-bit integer
1231/// vectors in \a __a and \a __b and returns the smaller of each pair in
1232/// the corresponding byte of the 256-bit result.
1233///
1234/// \headerfile <immintrin.h>
1235///
1236/// This intrinsic corresponds to the \c VPMINUB instruction.
1237///
1238/// \param __a
1239/// A 256-bit integer vector.
1240/// \param __b
1241/// A 256-bit integer vector.
1242/// \returns A 256-bit integer vector containing the result.
1243static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1244_mm256_min_epu8(__m256i __a, __m256i __b) {
1245 return (__m256i)__builtin_elementwise_min((__v32qu)__a, (__v32qu)__b);
1246}
1247
1248/// Compares the corresponding unsigned 16-bit integers in the two 256-bit
1249/// vectors of [16 x i16] in \a __a and \a __b and returns the smaller of
1250/// each pair in the corresponding element of the 256-bit result.
1251///
1252/// \headerfile <immintrin.h>
1253///
1254/// This intrinsic corresponds to the \c VPMINUW instruction.
1255///
1256/// \param __a
1257/// A 256-bit vector of [16 x i16].
1258/// \param __b
1259/// A 256-bit vector of [16 x i16].
1260/// \returns A 256-bit vector of [16 x i16] containing the result.
1261static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1262_mm256_min_epu16(__m256i __a, __m256i __b) {
1263 return (__m256i)__builtin_elementwise_min((__v16hu)__a, (__v16hu)__b);
1264}
1265
1266/// Compares the corresponding unsigned 32-bit integers in the two 256-bit
1267/// vectors of [8 x i32] in \a __a and \a __b and returns the smaller of
1268/// each pair in the corresponding element of the 256-bit result.
1269///
1270/// \headerfile <immintrin.h>
1271///
1272/// This intrinsic corresponds to the \c VPMINUD instruction.
1273///
1274/// \param __a
1275/// A 256-bit vector of [8 x i32].
1276/// \param __b
1277/// A 256-bit vector of [8 x i32].
1278/// \returns A 256-bit vector of [8 x i32] containing the result.
1279static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1280_mm256_min_epu32(__m256i __a, __m256i __b) {
1281 return (__m256i)__builtin_elementwise_min((__v8su)__a, (__v8su)__b);
1282}
1283
1284/// Creates a 32-bit integer mask from the most significant bit of each byte
1285/// in the 256-bit integer vector in \a __a and returns the result.
1286///
1287/// \code{.operation}
1288/// FOR i := 0 TO 31
1289/// j := i*8
1290/// result[i] := __a[j+7]
1291/// ENDFOR
1292/// \endcode
1293///
1294/// \headerfile <immintrin.h>
1295///
1296/// This intrinsic corresponds to the \c VPMOVMSKB instruction.
1297///
1298/// \param __a
1299/// A 256-bit integer vector containing the source bytes.
1300/// \returns The 32-bit integer mask.
1301static __inline__ int __DEFAULT_FN_ATTRS256_CONSTEXPR
1303 return __builtin_ia32_pmovmskb256((__v32qi)__a);
1304}
1305
1306/// Sign-extends bytes from the 128-bit integer vector in \a __V and returns
1307/// the 16-bit values in the corresponding elements of a 256-bit vector
1308/// of [16 x i16].
1309///
1310/// \code{.operation}
1311/// FOR i := 0 TO 15
1312/// j := i*8
1313/// k := i*16
1314/// result[k+15:k] := SignExtend(__V[j+7:j])
1315/// ENDFOR
1316/// \endcode
1317///
1318/// \headerfile <immintrin.h>
1319///
1320/// This intrinsic corresponds to the \c VPMOVSXBW instruction.
1321///
1322/// \param __V
1323/// A 128-bit integer vector containing the source bytes.
1324/// \returns A 256-bit vector of [16 x i16] containing the sign-extended
1325/// values.
1326static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1328 /* This function always performs a signed extension, but __v16qi is a char
1329 which may be signed or unsigned, so use __v16qs. */
1330 return (__m256i)__builtin_convertvector((__v16qs)__V, __v16hi);
1331}
1332
1333/// Sign-extends bytes from the lower half of the 128-bit integer vector in
1334/// \a __V and returns the 32-bit values in the corresponding elements of a
1335/// 256-bit vector of [8 x i32].
1336///
1337/// \code{.operation}
1338/// FOR i := 0 TO 7
1339/// j := i*8
1340/// k := i*32
1341/// result[k+31:k] := SignExtend(__V[j+7:j])
1342/// ENDFOR
1343/// \endcode
1344///
1345/// \headerfile <immintrin.h>
1346///
1347/// This intrinsic corresponds to the \c VPMOVSXBD instruction.
1348///
1349/// \param __V
1350/// A 128-bit integer vector containing the source bytes.
1351/// \returns A 256-bit vector of [8 x i32] containing the sign-extended
1352/// values.
1353static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1355 /* This function always performs a signed extension, but __v16qi is a char
1356 which may be signed or unsigned, so use __v16qs. */
1357 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8si);
1358}
1359
1360/// Sign-extends the first four bytes from the 128-bit integer vector in
1361/// \a __V and returns the 64-bit values in the corresponding elements of a
1362/// 256-bit vector of [4 x i64].
1363///
1364/// \code{.operation}
1365/// result[63:0] := SignExtend(__V[7:0])
1366/// result[127:64] := SignExtend(__V[15:8])
1367/// result[191:128] := SignExtend(__V[23:16])
1368/// result[255:192] := SignExtend(__V[31:24])
1369/// \endcode
1370///
1371/// \headerfile <immintrin.h>
1372///
1373/// This intrinsic corresponds to the \c VPMOVSXBQ instruction.
1374///
1375/// \param __V
1376/// A 128-bit integer vector containing the source bytes.
1377/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
1378/// values.
1379static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1381 /* This function always performs a signed extension, but __v16qi is a char
1382 which may be signed or unsigned, so use __v16qs. */
1383 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4di);
1384}
1385
1386/// Sign-extends 16-bit elements from the 128-bit vector of [8 x i16] in
1387/// \a __V and returns the 32-bit values in the corresponding elements of a
1388/// 256-bit vector of [8 x i32].
1389///
1390/// \code{.operation}
1391/// FOR i := 0 TO 7
1392/// j := i*16
1393/// k := i*32
1394/// result[k+31:k] := SignExtend(__V[j+15:j])
1395/// ENDFOR
1396/// \endcode
1397///
1398/// \headerfile <immintrin.h>
1399///
1400/// This intrinsic corresponds to the \c VPMOVSXWD instruction.
1401///
1402/// \param __V
1403/// A 128-bit vector of [8 x i16] containing the source values.
1404/// \returns A 256-bit vector of [8 x i32] containing the sign-extended
1405/// values.
1406static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1408 return (__m256i)__builtin_convertvector((__v8hi)__V, __v8si);
1409}
1410
1411/// Sign-extends 16-bit elements from the lower half of the 128-bit vector of
1412/// [8 x i16] in \a __V and returns the 64-bit values in the corresponding
1413/// elements of a 256-bit vector of [4 x i64].
1414///
1415/// \code{.operation}
1416/// result[63:0] := SignExtend(__V[15:0])
1417/// result[127:64] := SignExtend(__V[31:16])
1418/// result[191:128] := SignExtend(__V[47:32])
1419/// result[255:192] := SignExtend(__V[64:48])
1420/// \endcode
1421///
1422/// \headerfile <immintrin.h>
1423///
1424/// This intrinsic corresponds to the \c VPMOVSXWQ instruction.
1425///
1426/// \param __V
1427/// A 128-bit vector of [8 x i16] containing the source values.
1428/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
1429/// values.
1430static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1432 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4di);
1433}
1434
1435/// Sign-extends 32-bit elements from the 128-bit vector of [4 x i32] in
1436/// \a __V and returns the 64-bit values in the corresponding elements of a
1437/// 256-bit vector of [4 x i64].
1438///
1439/// \code{.operation}
1440/// result[63:0] := SignExtend(__V[31:0])
1441/// result[127:64] := SignExtend(__V[63:32])
1442/// result[191:128] := SignExtend(__V[95:64])
1443/// result[255:192] := SignExtend(__V[127:96])
1444/// \endcode
1445///
1446/// \headerfile <immintrin.h>
1447///
1448/// This intrinsic corresponds to the \c VPMOVSXDQ instruction.
1449///
1450/// \param __V
1451/// A 128-bit vector of [4 x i32] containing the source values.
1452/// \returns A 256-bit vector of [4 x i64] containing the sign-extended
1453/// values.
1454static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1456 return (__m256i)__builtin_convertvector((__v4si)__V, __v4di);
1457}
1458
1459/// Zero-extends bytes from the 128-bit integer vector in \a __V and returns
1460/// the 16-bit values in the corresponding elements of a 256-bit vector
1461/// of [16 x i16].
1462///
1463/// \code{.operation}
1464/// FOR i := 0 TO 15
1465/// j := i*8
1466/// k := i*16
1467/// result[k+15:k] := ZeroExtend(__V[j+7:j])
1468/// ENDFOR
1469/// \endcode
1470///
1471/// \headerfile <immintrin.h>
1472///
1473/// This intrinsic corresponds to the \c VPMOVZXBW instruction.
1474///
1475/// \param __V
1476/// A 128-bit integer vector containing the source bytes.
1477/// \returns A 256-bit vector of [16 x i16] containing the zero-extended
1478/// values.
1479static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1481 return (__m256i)__builtin_convertvector((__v16qu)__V, __v16hi);
1482}
1483
1484/// Zero-extends bytes from the lower half of the 128-bit integer vector in
1485/// \a __V and returns the 32-bit values in the corresponding elements of a
1486/// 256-bit vector of [8 x i32].
1487///
1488/// \code{.operation}
1489/// FOR i := 0 TO 7
1490/// j := i*8
1491/// k := i*32
1492/// result[k+31:k] := ZeroExtend(__V[j+7:j])
1493/// ENDFOR
1494/// \endcode
1495///
1496/// \headerfile <immintrin.h>
1497///
1498/// This intrinsic corresponds to the \c VPMOVZXBD instruction.
1499///
1500/// \param __V
1501/// A 128-bit integer vector containing the source bytes.
1502/// \returns A 256-bit vector of [8 x i32] containing the zero-extended
1503/// values.
1504static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1506 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8si);
1507}
1508
1509/// Zero-extends the first four bytes from the 128-bit integer vector in
1510/// \a __V and returns the 64-bit values in the corresponding elements of a
1511/// 256-bit vector of [4 x i64].
1512///
1513/// \code{.operation}
1514/// result[63:0] := ZeroExtend(__V[7:0])
1515/// result[127:64] := ZeroExtend(__V[15:8])
1516/// result[191:128] := ZeroExtend(__V[23:16])
1517/// result[255:192] := ZeroExtend(__V[31:24])
1518/// \endcode
1519///
1520/// \headerfile <immintrin.h>
1521///
1522/// This intrinsic corresponds to the \c VPMOVZXBQ instruction.
1523///
1524/// \param __V
1525/// A 128-bit integer vector containing the source bytes.
1526/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
1527/// values.
1528static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1530 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4di);
1531}
1532
1533/// Zero-extends 16-bit elements from the 128-bit vector of [8 x i16] in
1534/// \a __V and returns the 32-bit values in the corresponding elements of a
1535/// 256-bit vector of [8 x i32].
1536///
1537/// \code{.operation}
1538/// FOR i := 0 TO 7
1539/// j := i*16
1540/// k := i*32
1541/// result[k+31:k] := ZeroExtend(__V[j+15:j])
1542/// ENDFOR
1543/// \endcode
1544///
1545/// \headerfile <immintrin.h>
1546///
1547/// This intrinsic corresponds to the \c VPMOVZXWD instruction.
1548///
1549/// \param __V
1550/// A 128-bit vector of [8 x i16] containing the source values.
1551/// \returns A 256-bit vector of [8 x i32] containing the zero-extended
1552/// values.
1553static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1555 return (__m256i)__builtin_convertvector((__v8hu)__V, __v8si);
1556}
1557
1558/// Zero-extends 16-bit elements from the lower half of the 128-bit vector of
1559/// [8 x i16] in \a __V and returns the 64-bit values in the corresponding
1560/// elements of a 256-bit vector of [4 x i64].
1561///
1562/// \code{.operation}
1563/// result[63:0] := ZeroExtend(__V[15:0])
1564/// result[127:64] := ZeroExtend(__V[31:16])
1565/// result[191:128] := ZeroExtend(__V[47:32])
1566/// result[255:192] := ZeroExtend(__V[64:48])
1567/// \endcode
1568///
1569/// \headerfile <immintrin.h>
1570///
1571/// This intrinsic corresponds to the \c VPMOVSXWQ instruction.
1572///
1573/// \param __V
1574/// A 128-bit vector of [8 x i16] containing the source values.
1575/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
1576/// values.
1577static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1579 return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4di);
1580}
1581
1582/// Zero-extends 32-bit elements from the 128-bit vector of [4 x i32] in
1583/// \a __V and returns the 64-bit values in the corresponding elements of a
1584/// 256-bit vector of [4 x i64].
1585///
1586/// \code{.operation}
1587/// result[63:0] := ZeroExtend(__V[31:0])
1588/// result[127:64] := ZeroExtend(__V[63:32])
1589/// result[191:128] := ZeroExtend(__V[95:64])
1590/// result[255:192] := ZeroExtend(__V[127:96])
1591/// \endcode
1592///
1593/// \headerfile <immintrin.h>
1594///
1595/// This intrinsic corresponds to the \c VPMOVZXDQ instruction.
1596///
1597/// \param __V
1598/// A 128-bit vector of [4 x i32] containing the source values.
1599/// \returns A 256-bit vector of [4 x i64] containing the zero-extended
1600/// values.
1601static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1603 return (__m256i)__builtin_convertvector((__v4su)__V, __v4di);
1604}
1605
1606/// Multiplies signed 32-bit integers from even-numbered elements of two
1607/// 256-bit vectors of [8 x i32] and returns the 64-bit products in the
1608/// [4 x i64] result.
1609///
1610/// \code{.operation}
1611/// result[63:0] := __a[31:0] * __b[31:0]
1612/// result[127:64] := __a[95:64] * __b[95:64]
1613/// result[191:128] := __a[159:128] * __b[159:128]
1614/// result[255:192] := __a[223:192] * __b[223:192]
1615/// \endcode
1616///
1617/// \headerfile <immintrin.h>
1618///
1619/// This intrinsic corresponds to the \c VPMULDQ instruction.
1620///
1621/// \param __a
1622/// A 256-bit vector of [8 x i32] containing one of the source operands.
1623/// \param __b
1624/// A 256-bit vector of [8 x i32] containing one of the source operands.
1625/// \returns A 256-bit vector of [4 x i64] containing the products.
1626static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1627_mm256_mul_epi32(__m256i __a, __m256i __b) {
1628 return (__m256i)__builtin_ia32_pmuldq256((__v8si)__a, (__v8si)__b);
1629}
1630
1631/// Multiplies signed 16-bit integer elements of two 256-bit vectors of
1632/// [16 x i16], truncates the 32-bit results to the most significant 18
1633/// bits, rounds by adding 1, and returns bits [16:1] of each rounded
1634/// product in the [16 x i16] result.
1635///
1636/// \code{.operation}
1637/// FOR i := 0 TO 15
1638/// j := i*16
1639/// temp := ((__a[j+15:j] * __b[j+15:j]) >> 14) + 1
1640/// result[j+15:j] := temp[16:1]
1641/// \endcode
1642///
1643/// \headerfile <immintrin.h>
1644///
1645/// This intrinsic corresponds to the \c VPMULHRSW instruction.
1646///
1647/// \param __a
1648/// A 256-bit vector of [16 x i16] containing one of the source operands.
1649/// \param __b
1650/// A 256-bit vector of [16 x i16] containing one of the source operands.
1651/// \returns A 256-bit vector of [16 x i16] containing the rounded products.
1652static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1653_mm256_mulhrs_epi16(__m256i __a, __m256i __b) {
1654 return (__m256i)__builtin_ia32_pmulhrsw256((__v16hi)__a, (__v16hi)__b);
1655}
1656
1657/// Multiplies unsigned 16-bit integer elements of two 256-bit vectors of
1658/// [16 x i16], and returns the upper 16 bits of each 32-bit product in the
1659/// [16 x i16] result.
1660///
1661/// \headerfile <immintrin.h>
1662///
1663/// This intrinsic corresponds to the \c VPMULHUW instruction.
1664///
1665/// \param __a
1666/// A 256-bit vector of [16 x i16] containing one of the source operands.
1667/// \param __b
1668/// A 256-bit vector of [16 x i16] containing one of the source operands.
1669/// \returns A 256-bit vector of [16 x i16] containing the products.
1670static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1671_mm256_mulhi_epu16(__m256i __a, __m256i __b) {
1672 return (__m256i)__builtin_ia32_pmulhuw256((__v16hu)__a, (__v16hu)__b);
1673}
1674
1675/// Multiplies signed 16-bit integer elements of two 256-bit vectors of
1676/// [16 x i16], and returns the upper 16 bits of each 32-bit product in the
1677/// [16 x i16] result.
1678///
1679/// \headerfile <immintrin.h>
1680///
1681/// This intrinsic corresponds to the \c VPMULHW instruction.
1682///
1683/// \param __a
1684/// A 256-bit vector of [16 x i16] containing one of the source operands.
1685/// \param __b
1686/// A 256-bit vector of [16 x i16] containing one of the source operands.
1687/// \returns A 256-bit vector of [16 x i16] containing the products.
1688static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1689_mm256_mulhi_epi16(__m256i __a, __m256i __b)
1690{
1691 return (__m256i)__builtin_ia32_pmulhw256((__v16hi)__a, (__v16hi)__b);
1692}
1693
1694/// Multiplies signed 16-bit integer elements of two 256-bit vectors of
1695/// [16 x i16], and returns the lower 16 bits of each 32-bit product in the
1696/// [16 x i16] result.
1697///
1698/// \headerfile <immintrin.h>
1699///
1700/// This intrinsic corresponds to the \c VPMULLW instruction.
1701///
1702/// \param __a
1703/// A 256-bit vector of [16 x i16] containing one of the source operands.
1704/// \param __b
1705/// A 256-bit vector of [16 x i16] containing one of the source operands.
1706/// \returns A 256-bit vector of [16 x i16] containing the products.
1707static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1708_mm256_mullo_epi16(__m256i __a, __m256i __b)
1709{
1710 return (__m256i)((__v16hu)__a * (__v16hu)__b);
1711}
1712
1713/// Multiplies signed 32-bit integer elements of two 256-bit vectors of
1714/// [8 x i32], and returns the lower 32 bits of each 64-bit product in the
1715/// [8 x i32] result.
1716///
1717/// \headerfile <immintrin.h>
1718///
1719/// This intrinsic corresponds to the \c VPMULLD instruction.
1720///
1721/// \param __a
1722/// A 256-bit vector of [8 x i32] containing one of the source operands.
1723/// \param __b
1724/// A 256-bit vector of [8 x i32] containing one of the source operands.
1725/// \returns A 256-bit vector of [8 x i32] containing the products.
1726static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1727_mm256_mullo_epi32(__m256i __a, __m256i __b) {
1728 return (__m256i)((__v8su)__a * (__v8su)__b);
1729}
1730
1731/// Multiplies unsigned 32-bit integers from even-numered elements of two
1732/// 256-bit vectors of [8 x i32] and returns the 64-bit products in the
1733/// [4 x i64] result.
1734///
1735/// \code{.operation}
1736/// result[63:0] := __a[31:0] * __b[31:0]
1737/// result[127:64] := __a[95:64] * __b[95:64]
1738/// result[191:128] := __a[159:128] * __b[159:128]
1739/// result[255:192] := __a[223:192] * __b[223:192]
1740/// \endcode
1741///
1742/// \headerfile <immintrin.h>
1743///
1744/// This intrinsic corresponds to the \c VPMULUDQ instruction.
1745///
1746/// \param __a
1747/// A 256-bit vector of [8 x i32] containing one of the source operands.
1748/// \param __b
1749/// A 256-bit vector of [8 x i32] containing one of the source operands.
1750/// \returns A 256-bit vector of [4 x i64] containing the products.
1751static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1752_mm256_mul_epu32(__m256i __a, __m256i __b) {
1753 return __builtin_ia32_pmuludq256((__v8si)__a, (__v8si)__b);
1754}
1755
1756/// Computes the bitwise OR of the 256-bit integer vectors in \a __a and
1757/// \a __b.
1758///
1759/// \headerfile <immintrin.h>
1760///
1761/// This intrinsic corresponds to the \c VPOR instruction.
1762///
1763/// \param __a
1764/// A 256-bit integer vector.
1765/// \param __b
1766/// A 256-bit integer vector.
1767/// \returns A 256-bit integer vector containing the result.
1768static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1769_mm256_or_si256(__m256i __a, __m256i __b)
1770{
1771 return (__m256i)((__v4du)__a | (__v4du)__b);
1772}
1773
1774/// Computes four sum of absolute difference (SAD) operations on sets of eight
1775/// unsigned 8-bit integers from the 256-bit integer vectors \a __a and
1776/// \a __b.
1777///
1778/// One SAD result is computed for each set of eight bytes from \a __a and
1779/// eight bytes from \a __b. The zero-extended SAD value is returned in the
1780/// corresponding 64-bit element of the result.
1781///
1782/// A single SAD operation takes the differences between the corresponding
1783/// bytes of \a __a and \a __b, takes the absolute value of each difference,
1784/// and sums these eight values to form one 16-bit result. This operation
1785/// is repeated four times with successive sets of eight bytes.
1786///
1787/// \code{.operation}
1788/// FOR i := 0 TO 3
1789/// j := i*64
1790/// temp0 := ABS(__a[j+7:j] - __b[j+7:j])
1791/// temp1 := ABS(__a[j+15:j+8] - __b[j+15:j+8])
1792/// temp2 := ABS(__a[j+23:j+16] - __b[j+23:j+16])
1793/// temp3 := ABS(__a[j+31:j+24] - __b[j+31:j+24])
1794/// temp4 := ABS(__a[j+39:j+32] - __b[j+39:j+32])
1795/// temp5 := ABS(__a[j+47:j+40] - __b[j+47:j+40])
1796/// temp6 := ABS(__a[j+55:j+48] - __b[j+55:j+48])
1797/// temp7 := ABS(__a[j+63:j+56] - __b[j+63:j+56])
1798/// result[j+15:j] := temp0 + temp1 + temp2 + temp3 +
1799/// temp4 + temp5 + temp6 + temp7
1800/// result[j+63:j+16] := 0
1801/// ENDFOR
1802/// \endcode
1803///
1804/// \headerfile <immintrin.h>
1805///
1806/// This intrinsic corresponds to the \c VPSADBW instruction.
1807///
1808/// \param __a
1809/// A 256-bit integer vector.
1810/// \param __b
1811/// A 256-bit integer vector.
1812/// \returns A 256-bit integer vector containing the result.
1813static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1814_mm256_sad_epu8(__m256i __a, __m256i __b) {
1815 return __builtin_ia32_psadbw256((__v32qu)__a, (__v32qu)__b);
1816}
1817
1818/// Shuffles 8-bit integers in the 256-bit integer vector \a __a according
1819/// to control information in the 256-bit integer vector \a __b, and
1820/// returns the 256-bit result. In effect there are two separate 128-bit
1821/// shuffles in the lower and upper halves.
1822///
1823/// \code{.operation}
1824/// FOR i := 0 TO 31
1825/// j := i*8
1826/// IF __b[j+7] == 1
1827/// result[j+7:j] := 0
1828/// ELSE
1829/// k := __b[j+3:j] * 8
1830/// IF i > 15
1831/// k := k + 128
1832/// FI
1833/// result[j+7:j] := __a[k+7:k]
1834/// FI
1835/// ENDFOR
1836/// \endcode
1837///
1838/// \headerfile <immintrin.h>
1839///
1840/// This intrinsic corresponds to the \c VPSHUFB instruction.
1841///
1842/// \param __a
1843/// A 256-bit integer vector containing source values.
1844/// \param __b
1845/// A 256-bit integer vector containing control information to determine
1846/// what goes into the corresponding byte of the result. If bit 7 of the
1847/// control byte is 1, the result byte is 0; otherwise, bits 3:0 of the
1848/// control byte specify the index (within the same 128-bit half) of \a __a
1849/// to copy to the result byte.
1850/// \returns A 256-bit integer vector containing the result.
1851static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1852_mm256_shuffle_epi8(__m256i __a, __m256i __b) {
1853 return (__m256i)__builtin_ia32_pshufb256((__v32qi)__a, (__v32qi)__b);
1854}
1855
1856/// Shuffles 32-bit integers from the 256-bit vector of [8 x i32] in \a a
1857/// according to control information in the integer literal \a imm, and
1858/// returns the 256-bit result. In effect there are two parallel 128-bit
1859/// shuffles in the lower and upper halves.
1860///
1861/// \code{.operation}
1862/// FOR i := 0 to 3
1863/// j := i*32
1864/// k := (imm >> i*2)[1:0] * 32
1865/// result[j+31:j] := a[k+31:k]
1866/// result[128+j+31:128+j] := a[128+k+31:128+k]
1867/// ENDFOR
1868/// \endcode
1869///
1870/// \headerfile <immintrin.h>
1871///
1872/// \code
1873/// __m256i _mm256_shuffle_epi32(__m256i a, const int imm);
1874/// \endcode
1875///
1876/// This intrinsic corresponds to the \c VPSHUFB instruction.
1877///
1878/// \param a
1879/// A 256-bit vector of [8 x i32] containing source values.
1880/// \param imm
1881/// An immediate 8-bit value specifying which elements to copy from \a a.
1882/// \a imm[1:0] specifies the index in \a a for elements 0 and 4 of the
1883/// result, \a imm[3:2] specifies the index for elements 1 and 5, and so
1884/// forth.
1885/// \returns A 256-bit vector of [8 x i32] containing the result.
1886#define _mm256_shuffle_epi32(a, imm) \
1887 ((__m256i)__builtin_ia32_pshufd256((__v8si)(__m256i)(a), (int)(imm)))
1888
1889/// Shuffles 16-bit integers from the 256-bit vector of [16 x i16] in \a a
1890/// according to control information in the integer literal \a imm, and
1891/// returns the 256-bit result. The upper 64 bits of each 128-bit half
1892/// are shuffled in parallel; the lower 64 bits of each 128-bit half are
1893/// copied from \a a unchanged.
1894///
1895/// \code{.operation}
1896/// result[63:0] := a[63:0]
1897/// result[191:128] := a[191:128]
1898/// FOR i := 0 TO 3
1899/// j := i * 16 + 64
1900/// k := (imm >> i*2)[1:0] * 16 + 64
1901/// result[j+15:j] := a[k+15:k]
1902/// result[128+j+15:128+j] := a[128+k+15:128+k]
1903/// ENDFOR
1904/// \endcode
1905///
1906/// \headerfile <immintrin.h>
1907///
1908/// \code
1909/// __m256i _mm256_shufflehi_epi16(__m256i a, const int imm);
1910/// \endcode
1911///
1912/// This intrinsic corresponds to the \c VPSHUFHW instruction.
1913///
1914/// \param a
1915/// A 256-bit vector of [16 x i16] containing source values.
1916/// \param imm
1917/// An immediate 8-bit value specifying which elements to copy from \a a.
1918/// \a imm[1:0] specifies the index in \a a for elements 4 and 8 of the
1919/// result, \a imm[3:2] specifies the index for elements 5 and 9, and so
1920/// forth. Indexes are offset by 4 (so 0 means index 4, and so forth).
1921/// \returns A 256-bit vector of [16 x i16] containing the result.
1922#define _mm256_shufflehi_epi16(a, imm) \
1923 ((__m256i)__builtin_ia32_pshufhw256((__v16hi)(__m256i)(a), (int)(imm)))
1924
1925/// Shuffles 16-bit integers from the 256-bit vector of [16 x i16] \a a
1926/// according to control information in the integer literal \a imm, and
1927/// returns the 256-bit [16 x i16] result. The lower 64 bits of each
1928/// 128-bit half are shuffled; the upper 64 bits of each 128-bit half are
1929/// copied from \a a unchanged.
1930///
1931/// \code{.operation}
1932/// result[127:64] := a[127:64]
1933/// result[255:192] := a[255:192]
1934/// FOR i := 0 TO 3
1935/// j := i * 16
1936/// k := (imm >> i*2)[1:0] * 16
1937/// result[j+15:j] := a[k+15:k]
1938/// result[128+j+15:128+j] := a[128+k+15:128+k]
1939/// ENDFOR
1940/// \endcode
1941///
1942/// \headerfile <immintrin.h>
1943///
1944/// \code
1945/// __m256i _mm256_shufflelo_epi16(__m256i a, const int imm);
1946/// \endcode
1947///
1948/// This intrinsic corresponds to the \c VPSHUFLW instruction.
1949///
1950/// \param a
1951/// A 256-bit vector of [16 x i16] to use as a source of data for the
1952/// result.
1953/// \param imm
1954/// An immediate 8-bit value specifying which elements to copy from \a a.
1955/// \a imm[1:0] specifies the index in \a a for elements 0 and 8 of the
1956/// result, \a imm[3:2] specifies the index for elements 1 and 9, and so
1957/// forth.
1958/// \returns A 256-bit vector of [16 x i16] containing the result.
1959#define _mm256_shufflelo_epi16(a, imm) \
1960 ((__m256i)__builtin_ia32_pshuflw256((__v16hi)(__m256i)(a), (int)(imm)))
1961
1962/// Sets each byte of the result to the corresponding byte of the 256-bit
1963/// integer vector in \a __a, the negative of that byte, or zero, depending
1964/// on whether the corresponding byte of the 256-bit integer vector in
1965/// \a __b is greater than zero, less than zero, or equal to zero,
1966/// respectively.
1967///
1968/// \headerfile <immintrin.h>
1969///
1970/// This intrinsic corresponds to the \c VPSIGNB instruction.
1971///
1972/// \param __a
1973/// A 256-bit integer vector.
1974/// \param __b
1975/// A 256-bit integer vector].
1976/// \returns A 256-bit integer vector containing the result.
1977static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1978_mm256_sign_epi8(__m256i __a, __m256i __b) {
1979 return (__m256i)__builtin_ia32_psignb256((__v32qi)__a, (__v32qi)__b);
1980}
1981
1982/// Sets each element of the result to the corresponding element of the
1983/// 256-bit vector of [16 x i16] in \a __a, the negative of that element,
1984/// or zero, depending on whether the corresponding element of the 256-bit
1985/// vector of [16 x i16] in \a __b is greater than zero, less than zero, or
1986/// equal to zero, respectively.
1987///
1988/// \headerfile <immintrin.h>
1989///
1990/// This intrinsic corresponds to the \c VPSIGNW instruction.
1991///
1992/// \param __a
1993/// A 256-bit vector of [16 x i16].
1994/// \param __b
1995/// A 256-bit vector of [16 x i16].
1996/// \returns A 256-bit vector of [16 x i16] containing the result.
1997static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
1998_mm256_sign_epi16(__m256i __a, __m256i __b) {
1999 return (__m256i)__builtin_ia32_psignw256((__v16hi)__a, (__v16hi)__b);
2000}
2001
2002/// Sets each element of the result to the corresponding element of the
2003/// 256-bit vector of [8 x i32] in \a __a, the negative of that element, or
2004/// zero, depending on whether the corresponding element of the 256-bit
2005/// vector of [8 x i32] in \a __b is greater than zero, less than zero, or
2006/// equal to zero, respectively.
2007///
2008/// \headerfile <immintrin.h>
2009///
2010/// This intrinsic corresponds to the \c VPSIGND instruction.
2011///
2012/// \param __a
2013/// A 256-bit vector of [8 x i32].
2014/// \param __b
2015/// A 256-bit vector of [8 x i32].
2016/// \returns A 256-bit vector of [8 x i32] containing the result.
2017static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2018_mm256_sign_epi32(__m256i __a, __m256i __b) {
2019 return (__m256i)__builtin_ia32_psignd256((__v8si)__a, (__v8si)__b);
2020}
2021
2022/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
2023/// \a imm bytes, shifting in zero bytes, and returns the result. If \a imm
2024/// is greater than 15, the returned result is all zeroes.
2025///
2026/// \headerfile <immintrin.h>
2027///
2028/// \code
2029/// __m256i _mm256_slli_si256(__m256i a, const int imm);
2030/// \endcode
2031///
2032/// This intrinsic corresponds to the \c VPSLLDQ instruction.
2033///
2034/// \param a
2035/// A 256-bit integer vector to be shifted.
2036/// \param imm
2037/// An unsigned immediate value specifying the shift count (in bytes).
2038/// \returns A 256-bit integer vector containing the result.
2039#define _mm256_slli_si256(a, imm) \
2040 ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v32qi)(__m256i)(a), \
2041 (int)(imm)))
2042
2043/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
2044/// \a imm bytes, shifting in zero bytes, and returns the result. If \a imm
2045/// is greater than 15, the returned result is all zeroes.
2046///
2047/// \headerfile <immintrin.h>
2048///
2049/// \code
2050/// __m256i _mm256_bslli_epi128(__m256i a, const int imm);
2051/// \endcode
2052///
2053/// This intrinsic corresponds to the \c VPSLLDQ instruction.
2054///
2055/// \param a
2056/// A 256-bit integer vector to be shifted.
2057/// \param imm
2058/// An unsigned immediate value specifying the shift count (in bytes).
2059/// \returns A 256-bit integer vector containing the result.
2060#define _mm256_bslli_epi128(a, imm) \
2061 ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v32qi)(__m256i)(a), \
2062 (int)(imm)))
2063
2064/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2065/// left by \a __count bits, shifting in zero bits, and returns the result.
2066/// If \a __count is greater than 15, the returned result is all zeroes.
2067///
2068/// \headerfile <immintrin.h>
2069///
2070/// This intrinsic corresponds to the \c VPSLLW instruction.
2071///
2072/// \param __a
2073/// A 256-bit vector of [16 x i16] to be shifted.
2074/// \param __count
2075/// An unsigned integer value specifying the shift count (in bits).
2076/// \returns A 256-bit vector of [16 x i16] containing the result.
2077static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2078_mm256_slli_epi16(__m256i __a, int __count) {
2079 return (__m256i)__builtin_ia32_psllwi256((__v16hi)__a, __count);
2080}
2081
2082/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2083/// left by the number of bits specified by the lower 64 bits of \a __count,
2084/// shifting in zero bits, and returns the result. If \a __count is greater
2085/// than 15, the returned result is all zeroes.
2086///
2087/// \headerfile <immintrin.h>
2088///
2089/// This intrinsic corresponds to the \c VPSLLW instruction.
2090///
2091/// \param __a
2092/// A 256-bit vector of [16 x i16] to be shifted.
2093/// \param __count
2094/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2095/// shift count (in bits). The upper element is ignored.
2096/// \returns A 256-bit vector of [16 x i16] containing the result.
2097static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2098_mm256_sll_epi16(__m256i __a, __m128i __count) {
2099 return (__m256i)__builtin_ia32_psllw256((__v16hi)__a, (__v8hi)__count);
2100}
2101
2102/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2103/// left by \a __count bits, shifting in zero bits, and returns the result.
2104/// If \a __count is greater than 31, the returned result is all zeroes.
2105///
2106/// \headerfile <immintrin.h>
2107///
2108/// This intrinsic corresponds to the \c VPSLLD instruction.
2109///
2110/// \param __a
2111/// A 256-bit vector of [8 x i32] to be shifted.
2112/// \param __count
2113/// An unsigned integer value specifying the shift count (in bits).
2114/// \returns A 256-bit vector of [8 x i32] containing the result.
2115static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2116_mm256_slli_epi32(__m256i __a, int __count) {
2117 return (__m256i)__builtin_ia32_pslldi256((__v8si)__a, __count);
2118}
2119
2120/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2121/// left by the number of bits given in the lower 64 bits of \a __count,
2122/// shifting in zero bits, and returns the result. If \a __count is greater
2123/// than 31, the returned result is all zeroes.
2124///
2125/// \headerfile <immintrin.h>
2126///
2127/// This intrinsic corresponds to the \c VPSLLD instruction.
2128///
2129/// \param __a
2130/// A 256-bit vector of [8 x i32] to be shifted.
2131/// \param __count
2132/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2133/// shift count (in bits). The upper element is ignored.
2134/// \returns A 256-bit vector of [8 x i32] containing the result.
2135static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2136_mm256_sll_epi32(__m256i __a, __m128i __count) {
2137 return (__m256i)__builtin_ia32_pslld256((__v8si)__a, (__v4si)__count);
2138}
2139
2140/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a
2141/// left by \a __count bits, shifting in zero bits, and returns the result.
2142/// If \a __count is greater than 63, the returned result is all zeroes.
2143///
2144/// \headerfile <immintrin.h>
2145///
2146/// This intrinsic corresponds to the \c VPSLLQ instruction.
2147///
2148/// \param __a
2149/// A 256-bit vector of [4 x i64] to be shifted.
2150/// \param __count
2151/// An unsigned integer value specifying the shift count (in bits).
2152/// \returns A 256-bit vector of [4 x i64] containing the result.
2153static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2154_mm256_slli_epi64(__m256i __a, int __count) {
2155 return __builtin_ia32_psllqi256((__v4di)__a, __count);
2156}
2157
2158/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a
2159/// left by the number of bits given in the lower 64 bits of \a __count,
2160/// shifting in zero bits, and returns the result. If \a __count is greater
2161/// than 63, the returned result is all zeroes.
2162///
2163/// \headerfile <immintrin.h>
2164///
2165/// This intrinsic corresponds to the \c VPSLLQ instruction.
2166///
2167/// \param __a
2168/// A 256-bit vector of [4 x i64] to be shifted.
2169/// \param __count
2170/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2171/// shift count (in bits). The upper element is ignored.
2172/// \returns A 256-bit vector of [4 x i64] containing the result.
2173static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2174_mm256_sll_epi64(__m256i __a, __m128i __count) {
2175 return __builtin_ia32_psllq256((__v4di)__a, __count);
2176}
2177
2178/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2179/// right by \a __count bits, shifting in sign bits, and returns the result.
2180/// If \a __count is greater than 15, each element of the result is either
2181/// 0 or -1 according to the corresponding input sign bit.
2182///
2183/// \headerfile <immintrin.h>
2184///
2185/// This intrinsic corresponds to the \c VPSRAW instruction.
2186///
2187/// \param __a
2188/// A 256-bit vector of [16 x i16] to be shifted.
2189/// \param __count
2190/// An unsigned integer value specifying the shift count (in bits).
2191/// \returns A 256-bit vector of [16 x i16] containing the result.
2192static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2193_mm256_srai_epi16(__m256i __a, int __count) {
2194 return (__m256i)__builtin_ia32_psrawi256((__v16hi)__a, __count);
2195}
2196
2197/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2198/// right by the number of bits given in the lower 64 bits of \a __count,
2199/// shifting in sign bits, and returns the result. If \a __count is greater
2200/// than 15, each element of the result is either 0 or -1 according to the
2201/// corresponding input sign bit.
2202///
2203/// \headerfile <immintrin.h>
2204///
2205/// This intrinsic corresponds to the \c VPSRAW instruction.
2206///
2207/// \param __a
2208/// A 256-bit vector of [16 x i16] to be shifted.
2209/// \param __count
2210/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2211/// shift count (in bits). The upper element is ignored.
2212/// \returns A 256-bit vector of [16 x i16] containing the result.
2213static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2214_mm256_sra_epi16(__m256i __a, __m128i __count) {
2215 return (__m256i)__builtin_ia32_psraw256((__v16hi)__a, (__v8hi)__count);
2216}
2217
2218/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2219/// right by \a __count bits, shifting in sign bits, and returns the result.
2220/// If \a __count is greater than 31, each element of the result is either
2221/// 0 or -1 according to the corresponding input sign bit.
2222///
2223/// \headerfile <immintrin.h>
2224///
2225/// This intrinsic corresponds to the \c VPSRAD instruction.
2226///
2227/// \param __a
2228/// A 256-bit vector of [8 x i32] to be shifted.
2229/// \param __count
2230/// An unsigned integer value specifying the shift count (in bits).
2231/// \returns A 256-bit vector of [8 x i32] containing the result.
2232static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2233_mm256_srai_epi32(__m256i __a, int __count) {
2234 return (__m256i)__builtin_ia32_psradi256((__v8si)__a, __count);
2235}
2236
2237/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2238/// right by the number of bits given in the lower 64 bits of \a __count,
2239/// shifting in sign bits, and returns the result. If \a __count is greater
2240/// than 31, each element of the result is either 0 or -1 according to the
2241/// corresponding input sign bit.
2242///
2243/// \headerfile <immintrin.h>
2244///
2245/// This intrinsic corresponds to the \c VPSRAD instruction.
2246///
2247/// \param __a
2248/// A 256-bit vector of [8 x i32] to be shifted.
2249/// \param __count
2250/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2251/// shift count (in bits). The upper element is ignored.
2252/// \returns A 256-bit vector of [8 x i32] containing the result.
2253static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2254_mm256_sra_epi32(__m256i __a, __m128i __count) {
2255 return (__m256i)__builtin_ia32_psrad256((__v8si)__a, (__v4si)__count);
2256}
2257
2258/// Shifts each 128-bit half of the 256-bit integer vector in \a a right by
2259/// \a imm bytes, shifting in zero bytes, and returns the result. If
2260/// \a imm is greater than 15, the returned result is all zeroes.
2261///
2262/// \headerfile <immintrin.h>
2263///
2264/// \code
2265/// __m256i _mm256_srli_si256(__m256i a, const int imm);
2266/// \endcode
2267///
2268/// This intrinsic corresponds to the \c VPSRLDQ instruction.
2269///
2270/// \param a
2271/// A 256-bit integer vector to be shifted.
2272/// \param imm
2273/// An unsigned immediate value specifying the shift count (in bytes).
2274/// \returns A 256-bit integer vector containing the result.
2275#define _mm256_srli_si256(a, imm) \
2276 ((__m256i)__builtin_ia32_psrldqi256_byteshift((__v32qi)(__m256i)(a), \
2277 (int)(imm)))
2278
2279/// Shifts each 128-bit half of the 256-bit integer vector in \a a right by
2280/// \a imm bytes, shifting in zero bytes, and returns the result. If
2281/// \a imm is greater than 15, the returned result is all zeroes.
2282///
2283/// \headerfile <immintrin.h>
2284///
2285/// \code
2286/// __m256i _mm256_bsrli_epi128(__m256i a, const int imm);
2287/// \endcode
2288///
2289/// This intrinsic corresponds to the \c VPSRLDQ instruction.
2290///
2291/// \param a
2292/// A 256-bit integer vector to be shifted.
2293/// \param imm
2294/// An unsigned immediate value specifying the shift count (in bytes).
2295/// \returns A 256-bit integer vector containing the result.
2296#define _mm256_bsrli_epi128(a, imm) \
2297 ((__m256i)__builtin_ia32_psrldqi256_byteshift((__v32qi)(__m256i)(a), \
2298 (int)(imm)))
2299
2300/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2301/// right by \a __count bits, shifting in zero bits, and returns the result.
2302/// If \a __count is greater than 15, the returned result is all zeroes.
2303///
2304/// \headerfile <immintrin.h>
2305///
2306/// This intrinsic corresponds to the \c VPSRLW instruction.
2307///
2308/// \param __a
2309/// A 256-bit vector of [16 x i16] to be shifted.
2310/// \param __count
2311/// An unsigned integer value specifying the shift count (in bits).
2312/// \returns A 256-bit vector of [16 x i16] containing the result.
2313static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2314_mm256_srli_epi16(__m256i __a, int __count) {
2315 return (__m256i)__builtin_ia32_psrlwi256((__v16hi)__a, __count);
2316}
2317
2318/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
2319/// right by the number of bits given in the lower 64 bits of \a __count,
2320/// shifting in zero bits, and returns the result. If \a __count is greater
2321/// than 15, the returned result is all zeroes.
2322///
2323/// \headerfile <immintrin.h>
2324///
2325/// This intrinsic corresponds to the \c VPSRLW instruction.
2326///
2327/// \param __a
2328/// A 256-bit vector of [16 x i16] to be shifted.
2329/// \param __count
2330/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2331/// shift count (in bits). The upper element is ignored.
2332/// \returns A 256-bit vector of [16 x i16] containing the result.
2333static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2334_mm256_srl_epi16(__m256i __a, __m128i __count) {
2335 return (__m256i)__builtin_ia32_psrlw256((__v16hi)__a, (__v8hi)__count);
2336}
2337
2338/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2339/// right by \a __count bits, shifting in zero bits, and returns the result.
2340/// If \a __count is greater than 31, the returned result is all zeroes.
2341///
2342/// \headerfile <immintrin.h>
2343///
2344/// This intrinsic corresponds to the \c VPSRLD instruction.
2345///
2346/// \param __a
2347/// A 256-bit vector of [8 x i32] to be shifted.
2348/// \param __count
2349/// An unsigned integer value specifying the shift count (in bits).
2350/// \returns A 256-bit vector of [8 x i32] containing the result.
2351static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2352_mm256_srli_epi32(__m256i __a, int __count) {
2353 return (__m256i)__builtin_ia32_psrldi256((__v8si)__a, __count);
2354}
2355
2356/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
2357/// right by the number of bits given in the lower 64 bits of \a __count,
2358/// shifting in zero bits, and returns the result. If \a __count is greater
2359/// than 31, the returned result is all zeroes.
2360///
2361/// \headerfile <immintrin.h>
2362///
2363/// This intrinsic corresponds to the \c VPSRLD instruction.
2364///
2365/// \param __a
2366/// A 256-bit vector of [8 x i32] to be shifted.
2367/// \param __count
2368/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2369/// shift count (in bits). The upper element is ignored.
2370/// \returns A 256-bit vector of [8 x i32] containing the result.
2371static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2372_mm256_srl_epi32(__m256i __a, __m128i __count) {
2373 return (__m256i)__builtin_ia32_psrld256((__v8si)__a, (__v4si)__count);
2374}
2375
2376/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a
2377/// right by \a __count bits, shifting in zero bits, and returns the result.
2378/// If \a __count is greater than 63, the returned result is all zeroes.
2379///
2380/// \headerfile <immintrin.h>
2381///
2382/// This intrinsic corresponds to the \c VPSRLQ instruction.
2383///
2384/// \param __a
2385/// A 256-bit vector of [4 x i64] to be shifted.
2386/// \param __count
2387/// An unsigned integer value specifying the shift count (in bits).
2388/// \returns A 256-bit vector of [4 x i64] containing the result.
2389static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2390_mm256_srli_epi64(__m256i __a, int __count) {
2391 return __builtin_ia32_psrlqi256((__v4di)__a, __count);
2392}
2393
2394/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a
2395/// right by the number of bits given in the lower 64 bits of \a __count,
2396/// shifting in zero bits, and returns the result. If \a __count is greater
2397/// than 63, the returned result is all zeroes.
2398///
2399/// \headerfile <immintrin.h>
2400///
2401/// This intrinsic corresponds to the \c VPSRLQ instruction.
2402///
2403/// \param __a
2404/// A 256-bit vector of [4 x i64] to be shifted.
2405/// \param __count
2406/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned
2407/// shift count (in bits). The upper element is ignored.
2408/// \returns A 256-bit vector of [4 x i64] containing the result.
2409static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2410_mm256_srl_epi64(__m256i __a, __m128i __count) {
2411 return __builtin_ia32_psrlq256((__v4di)__a, __count);
2412}
2413
2414/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer
2415/// vectors. Returns the lower 8 bits of each difference in the
2416/// corresponding byte of the 256-bit integer vector result (overflow is
2417/// ignored).
2418///
2419/// \code{.operation}
2420/// FOR i := 0 TO 31
2421/// j := i*8
2422/// result[j+7:j] := __a[j+7:j] - __b[j+7:j]
2423/// ENDFOR
2424/// \endcode
2425///
2426/// \headerfile <immintrin.h>
2427///
2428/// This intrinsic corresponds to the \c VPSUBB instruction.
2429///
2430/// \param __a
2431/// A 256-bit integer vector containing the minuends.
2432/// \param __b
2433/// A 256-bit integer vector containing the subtrahends.
2434/// \returns A 256-bit integer vector containing the differences.
2435static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2436_mm256_sub_epi8(__m256i __a, __m256i __b) {
2437 return (__m256i)((__v32qu)__a - (__v32qu)__b);
2438}
2439
2440/// Subtracts 16-bit integers from corresponding elements of two 256-bit
2441/// vectors of [16 x i16]. Returns the lower 16 bits of each difference in
2442/// the corresponding element of the [16 x i16] result (overflow is
2443/// ignored).
2444///
2445/// \code{.operation}
2446/// FOR i := 0 TO 15
2447/// j := i*16
2448/// result[j+15:j] := __a[j+15:j] - __b[j+15:j]
2449/// ENDFOR
2450/// \endcode
2451///
2452/// \headerfile <immintrin.h>
2453///
2454/// This intrinsic corresponds to the \c VPSUBW instruction.
2455///
2456/// \param __a
2457/// A 256-bit vector of [16 x i16] containing the minuends.
2458/// \param __b
2459/// A 256-bit vector of [16 x i16] containing the subtrahends.
2460/// \returns A 256-bit vector of [16 x i16] containing the differences.
2461static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2462_mm256_sub_epi16(__m256i __a, __m256i __b) {
2463 return (__m256i)((__v16hu)__a - (__v16hu)__b);
2464}
2465
2466/// Subtracts 32-bit integers from corresponding elements of two 256-bit
2467/// vectors of [8 x i32]. Returns the lower 32 bits of each difference in
2468/// the corresponding element of the [8 x i32] result (overflow is ignored).
2469///
2470/// \code{.operation}
2471/// FOR i := 0 TO 7
2472/// j := i*32
2473/// result[j+31:j] := __a[j+31:j] - __b[j+31:j]
2474/// ENDFOR
2475/// \endcode
2476///
2477/// \headerfile <immintrin.h>
2478///
2479/// This intrinsic corresponds to the \c VPSUBD instruction.
2480///
2481/// \param __a
2482/// A 256-bit vector of [8 x i32] containing the minuends.
2483/// \param __b
2484/// A 256-bit vector of [8 x i32] containing the subtrahends.
2485/// \returns A 256-bit vector of [8 x i32] containing the differences.
2486static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2487_mm256_sub_epi32(__m256i __a, __m256i __b) {
2488 return (__m256i)((__v8su)__a - (__v8su)__b);
2489}
2490
2491/// Subtracts 64-bit integers from corresponding elements of two 256-bit
2492/// vectors of [4 x i64]. Returns the lower 64 bits of each difference in
2493/// the corresponding element of the [4 x i64] result (overflow is ignored).
2494///
2495/// \code{.operation}
2496/// FOR i := 0 TO 3
2497/// j := i*64
2498/// result[j+63:j] := __a[j+63:j] - __b[j+63:j]
2499/// ENDFOR
2500/// \endcode
2501///
2502/// \headerfile <immintrin.h>
2503///
2504/// This intrinsic corresponds to the \c VPSUBQ instruction.
2505///
2506/// \param __a
2507/// A 256-bit vector of [4 x i64] containing the minuends.
2508/// \param __b
2509/// A 256-bit vector of [4 x i64] containing the subtrahends.
2510/// \returns A 256-bit vector of [4 x i64] containing the differences.
2511static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2512_mm256_sub_epi64(__m256i __a, __m256i __b) {
2513 return (__m256i)((__v4du)__a - (__v4du)__b);
2514}
2515
2516/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer
2517/// vectors using signed saturation, and returns each differences in the
2518/// corresponding byte of the 256-bit integer vector result.
2519///
2520/// \code{.operation}
2521/// FOR i := 0 TO 31
2522/// j := i*8
2523/// result[j+7:j] := SATURATE8(__a[j+7:j] - __b[j+7:j])
2524/// ENDFOR
2525/// \endcode
2526///
2527/// \headerfile <immintrin.h>
2528///
2529/// This intrinsic corresponds to the \c VPSUBSB instruction.
2530///
2531/// \param __a
2532/// A 256-bit integer vector containing the minuends.
2533/// \param __b
2534/// A 256-bit integer vector containing the subtrahends.
2535/// \returns A 256-bit integer vector containing the differences.
2536static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2537_mm256_subs_epi8(__m256i __a, __m256i __b) {
2538 return (__m256i)__builtin_elementwise_sub_sat((__v32qs)__a, (__v32qs)__b);
2539}
2540
2541/// Subtracts 16-bit integers from corresponding elements of two 256-bit
2542/// vectors of [16 x i16] using signed saturation, and returns each
2543/// difference in the corresponding element of the [16 x i16] result.
2544///
2545/// \code{.operation}
2546/// FOR i := 0 TO 15
2547/// j := i*16
2548/// result[j+7:j] := SATURATE16(__a[j+7:j] - __b[j+7:j])
2549/// ENDFOR
2550/// \endcode
2551///
2552/// \headerfile <immintrin.h>
2553///
2554/// This intrinsic corresponds to the \c VPSUBSW instruction.
2555///
2556/// \param __a
2557/// A 256-bit vector of [16 x i16] containing the minuends.
2558/// \param __b
2559/// A 256-bit vector of [16 x i16] containing the subtrahends.
2560/// \returns A 256-bit vector of [16 x i16] containing the differences.
2561static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2562_mm256_subs_epi16(__m256i __a, __m256i __b) {
2563 return (__m256i)__builtin_elementwise_sub_sat((__v16hi)__a, (__v16hi)__b);
2564}
2565
2566/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer
2567/// vectors using unsigned saturation, and returns each difference in the
2568/// corresponding byte of the 256-bit integer vector result. For each byte,
2569/// computes <c> result = __a - __b </c>.
2570///
2571/// \code{.operation}
2572/// FOR i := 0 TO 31
2573/// j := i*8
2574/// result[j+7:j] := SATURATE8U(__a[j+7:j] - __b[j+7:j])
2575/// ENDFOR
2576/// \endcode
2577///
2578/// \headerfile <immintrin.h>
2579///
2580/// This intrinsic corresponds to the \c VPSUBUSB instruction.
2581///
2582/// \param __a
2583/// A 256-bit integer vector containing the minuends.
2584/// \param __b
2585/// A 256-bit integer vector containing the subtrahends.
2586/// \returns A 256-bit integer vector containing the differences.
2587static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2588_mm256_subs_epu8(__m256i __a, __m256i __b) {
2589 return (__m256i)__builtin_elementwise_sub_sat((__v32qu)__a, (__v32qu)__b);
2590}
2591
2592/// Subtracts 16-bit integers from corresponding elements of two 256-bit
2593/// vectors of [16 x i16] using unsigned saturation, and returns each
2594/// difference in the corresponding element of the [16 x i16] result.
2595///
2596/// \code{.operation}
2597/// FOR i := 0 TO 15
2598/// j := i*16
2599/// result[j+15:j] := SATURATE16U(__a[j+15:j] - __b[j+15:j])
2600/// ENDFOR
2601/// \endcode
2602///
2603/// \headerfile <immintrin.h>
2604///
2605/// This intrinsic corresponds to the \c VPSUBUSW instruction.
2606///
2607/// \param __a
2608/// A 256-bit vector of [16 x i16] containing the minuends.
2609/// \param __b
2610/// A 256-bit vector of [16 x i16] containing the subtrahends.
2611/// \returns A 256-bit vector of [16 x i16] containing the differences.
2612static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2613_mm256_subs_epu16(__m256i __a, __m256i __b) {
2614 return (__m256i)__builtin_elementwise_sub_sat((__v16hu)__a, (__v16hu)__b);
2615}
2616
2617/// Unpacks and interleaves 8-bit integers from parts of the 256-bit integer
2618/// vectors in \a __a and \a __b to form the 256-bit result. Specifically,
2619/// uses the upper 64 bits of each 128-bit half of \a __a and \a __b as
2620/// input; other bits in these parameters are ignored.
2621///
2622/// \code{.operation}
2623/// result[7:0] := __a[71:64]
2624/// result[15:8] := __b[71:64]
2625/// result[23:16] := __a[79:72]
2626/// result[31:24] := __b[79:72]
2627/// . . .
2628/// result[127:120] := __b[127:120]
2629/// result[135:128] := __a[199:192]
2630/// . . .
2631/// result[255:248] := __b[255:248]
2632/// \endcode
2633///
2634/// \headerfile <immintrin.h>
2635///
2636/// This intrinsic corresponds to the \c VPUNPCKHBW instruction.
2637///
2638/// \param __a
2639/// A 256-bit integer vector used as the source for the even-numbered bytes
2640/// of the result.
2641/// \param __b
2642/// A 256-bit integer vector used as the source for the odd-numbered bytes
2643/// of the result.
2644/// \returns A 256-bit integer vector containing the result.
2645static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2646_mm256_unpackhi_epi8(__m256i __a, __m256i __b) {
2647 return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 8, 32+8, 9, 32+9, 10, 32+10, 11, 32+11, 12, 32+12, 13, 32+13, 14, 32+14, 15, 32+15, 24, 32+24, 25, 32+25, 26, 32+26, 27, 32+27, 28, 32+28, 29, 32+29, 30, 32+30, 31, 32+31);
2648}
2649
2650/// Unpacks and interleaves 16-bit integers from parts of the 256-bit vectors
2651/// of [16 x i16] in \a __a and \a __b to return the resulting 256-bit
2652/// vector of [16 x i16]. Specifically, uses the upper 64 bits of each
2653/// 128-bit half of \a __a and \a __b as input; other bits in these
2654/// parameters are ignored.
2655///
2656/// \code{.operation}
2657/// result[15:0] := __a[79:64]
2658/// result[31:16] := __b[79:64]
2659/// result[47:32] := __a[95:80]
2660/// result[63:48] := __b[95:80]
2661/// . . .
2662/// result[127:112] := __b[127:112]
2663/// result[143:128] := __a[211:196]
2664/// . . .
2665/// result[255:240] := __b[255:240]
2666/// \endcode
2667///
2668/// \headerfile <immintrin.h>
2669///
2670/// This intrinsic corresponds to the \c VPUNPCKHWD instruction.
2671///
2672/// \param __a
2673/// A 256-bit vector of [16 x i16] used as the source for the even-numbered
2674/// elements of the result.
2675/// \param __b
2676/// A 256-bit vector of [16 x i16] used as the source for the odd-numbered
2677/// elements of the result.
2678/// \returns A 256-bit vector of [16 x i16] containing the result.
2679static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2680_mm256_unpackhi_epi16(__m256i __a, __m256i __b) {
2681 return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15);
2682}
2683
2684/// Unpacks and interleaves 32-bit integers from parts of the 256-bit vectors
2685/// of [8 x i32] in \a __a and \a __b to return the resulting 256-bit vector
2686/// of [8 x i32]. Specifically, uses the upper 64 bits of each 128-bit half
2687/// of \a __a and \a __b as input; other bits in these parameters are
2688/// ignored.
2689///
2690/// \code{.operation}
2691/// result[31:0] := __a[95:64]
2692/// result[63:32] := __b[95:64]
2693/// result[95:64] := __a[127:96]
2694/// result[127:96] := __b[127:96]
2695/// result[159:128] := __a[223:192]
2696/// result[191:160] := __b[223:192]
2697/// result[223:192] := __a[255:224]
2698/// result[255:224] := __b[255:224]
2699/// \endcode
2700///
2701/// \headerfile <immintrin.h>
2702///
2703/// This intrinsic corresponds to the \c VPUNPCKHDQ instruction.
2704///
2705/// \param __a
2706/// A 256-bit vector of [8 x i32] used as the source for the even-numbered
2707/// elements of the result.
2708/// \param __b
2709/// A 256-bit vector of [8 x i32] used as the source for the odd-numbered
2710/// elements of the result.
2711/// \returns A 256-bit vector of [8 x i32] containing the result.
2712static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2713_mm256_unpackhi_epi32(__m256i __a, __m256i __b) {
2714 return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 2, 8+2, 3, 8+3, 6, 8+6, 7, 8+7);
2715}
2716
2717/// Unpacks and interleaves 64-bit integers from parts of the 256-bit vectors
2718/// of [4 x i64] in \a __a and \a __b to return the resulting 256-bit vector
2719/// of [4 x i64]. Specifically, uses the upper 64 bits of each 128-bit half
2720/// of \a __a and \a __b as input; other bits in these parameters are
2721/// ignored.
2722///
2723/// \code{.operation}
2724/// result[63:0] := __a[127:64]
2725/// result[127:64] := __b[127:64]
2726/// result[191:128] := __a[255:192]
2727/// result[255:192] := __b[255:192]
2728/// \endcode
2729///
2730/// \headerfile <immintrin.h>
2731///
2732/// This intrinsic corresponds to the \c VPUNPCKHQDQ instruction.
2733///
2734/// \param __a
2735/// A 256-bit vector of [4 x i64] used as the source for the even-numbered
2736/// elements of the result.
2737/// \param __b
2738/// A 256-bit vector of [4 x i64] used as the source for the odd-numbered
2739/// elements of the result.
2740/// \returns A 256-bit vector of [4 x i64] containing the result.
2741static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2742_mm256_unpackhi_epi64(__m256i __a, __m256i __b) {
2743 return (__m256i)__builtin_shufflevector((__v4di)__a, (__v4di)__b, 1, 4+1, 3, 4+3);
2744}
2745
2746/// Unpacks and interleaves 8-bit integers from parts of the 256-bit integer
2747/// vectors in \a __a and \a __b to form the 256-bit result. Specifically,
2748/// uses the lower 64 bits of each 128-bit half of \a __a and \a __b as
2749/// input; other bits in these parameters are ignored.
2750///
2751/// \code{.operation}
2752/// result[7:0] := __a[7:0]
2753/// result[15:8] := __b[7:0]
2754/// result[23:16] := __a[15:8]
2755/// result[31:24] := __b[15:8]
2756/// . . .
2757/// result[127:120] := __b[63:56]
2758/// result[135:128] := __a[135:128]
2759/// . . .
2760/// result[255:248] := __b[191:184]
2761/// \endcode
2762///
2763/// \headerfile <immintrin.h>
2764///
2765/// This intrinsic corresponds to the \c VPUNPCKLBW instruction.
2766///
2767/// \param __a
2768/// A 256-bit integer vector used as the source for the even-numbered bytes
2769/// of the result.
2770/// \param __b
2771/// A 256-bit integer vector used as the source for the odd-numbered bytes
2772/// of the result.
2773/// \returns A 256-bit integer vector containing the result.
2774static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2775_mm256_unpacklo_epi8(__m256i __a, __m256i __b) {
2776 return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 0, 32+0, 1, 32+1, 2, 32+2, 3, 32+3, 4, 32+4, 5, 32+5, 6, 32+6, 7, 32+7, 16, 32+16, 17, 32+17, 18, 32+18, 19, 32+19, 20, 32+20, 21, 32+21, 22, 32+22, 23, 32+23);
2777}
2778
2779/// Unpacks and interleaves 16-bit integers from parts of the 256-bit vectors
2780/// of [16 x i16] in \a __a and \a __b to return the resulting 256-bit
2781/// vector of [16 x i16]. Specifically, uses the lower 64 bits of each
2782/// 128-bit half of \a __a and \a __b as input; other bits in these
2783/// parameters are ignored.
2784///
2785/// \code{.operation}
2786/// result[15:0] := __a[15:0]
2787/// result[31:16] := __b[15:0]
2788/// result[47:32] := __a[31:16]
2789/// result[63:48] := __b[31:16]
2790/// . . .
2791/// result[127:112] := __b[63:48]
2792/// result[143:128] := __a[143:128]
2793/// . . .
2794/// result[255:239] := __b[191:176]
2795/// \endcode
2796///
2797/// \headerfile <immintrin.h>
2798///
2799/// This intrinsic corresponds to the \c VPUNPCKLWD instruction.
2800///
2801/// \param __a
2802/// A 256-bit vector of [16 x i16] used as the source for the even-numbered
2803/// elements of the result.
2804/// \param __b
2805/// A 256-bit vector of [16 x i16] used as the source for the odd-numbered
2806/// elements of the result.
2807/// \returns A 256-bit vector of [16 x i16] containing the result.
2808static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2809_mm256_unpacklo_epi16(__m256i __a, __m256i __b) {
2810 return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11);
2811}
2812
2813/// Unpacks and interleaves 32-bit integers from parts of the 256-bit vectors
2814/// of [8 x i32] in \a __a and \a __b to return the resulting 256-bit vector
2815/// of [8 x i32]. Specifically, uses the lower 64 bits of each 128-bit half
2816/// of \a __a and \a __b as input; other bits in these parameters are
2817/// ignored.
2818///
2819/// \code{.operation}
2820/// result[31:0] := __a[31:0]
2821/// result[63:32] := __b[31:0]
2822/// result[95:64] := __a[63:32]
2823/// result[127:96] := __b[63:32]
2824/// result[159:128] := __a[159:128]
2825/// result[191:160] := __b[159:128]
2826/// result[223:192] := __a[191:160]
2827/// result[255:224] := __b[191:190]
2828/// \endcode
2829///
2830/// \headerfile <immintrin.h>
2831///
2832/// This intrinsic corresponds to the \c VPUNPCKLDQ instruction.
2833///
2834/// \param __a
2835/// A 256-bit vector of [8 x i32] used as the source for the even-numbered
2836/// elements of the result.
2837/// \param __b
2838/// A 256-bit vector of [8 x i32] used as the source for the odd-numbered
2839/// elements of the result.
2840/// \returns A 256-bit vector of [8 x i32] containing the result.
2841static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2842_mm256_unpacklo_epi32(__m256i __a, __m256i __b) {
2843 return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 0, 8+0, 1, 8+1, 4, 8+4, 5, 8+5);
2844}
2845
2846/// Unpacks and interleaves 64-bit integers from parts of the 256-bit vectors
2847/// of [4 x i64] in \a __a and \a __b to return the resulting 256-bit vector
2848/// of [4 x i64]. Specifically, uses the lower 64 bits of each 128-bit half
2849/// of \a __a and \a __b as input; other bits in these parameters are
2850/// ignored.
2851///
2852/// \code{.operation}
2853/// result[63:0] := __a[63:0]
2854/// result[127:64] := __b[63:0]
2855/// result[191:128] := __a[191:128]
2856/// result[255:192] := __b[191:128]
2857/// \endcode
2858///
2859/// \headerfile <immintrin.h>
2860///
2861/// This intrinsic corresponds to the \c VPUNPCKLQDQ instruction.
2862///
2863/// \param __a
2864/// A 256-bit vector of [4 x i64] used as the source for the even-numbered
2865/// elements of the result.
2866/// \param __b
2867/// A 256-bit vector of [4 x i64] used as the source for the odd-numbered
2868/// elements of the result.
2869/// \returns A 256-bit vector of [4 x i64] containing the result.
2870static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2871_mm256_unpacklo_epi64(__m256i __a, __m256i __b) {
2872 return (__m256i)__builtin_shufflevector((__v4di)__a, (__v4di)__b, 0, 4+0, 2, 4+2);
2873}
2874
2875/// Computes the bitwise XOR of the 256-bit integer vectors in \a __a and
2876/// \a __b.
2877///
2878/// \headerfile <immintrin.h>
2879///
2880/// This intrinsic corresponds to the \c VPXOR instruction.
2881///
2882/// \param __a
2883/// A 256-bit integer vector.
2884/// \param __b
2885/// A 256-bit integer vector.
2886/// \returns A 256-bit integer vector containing the result.
2887static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2888_mm256_xor_si256(__m256i __a, __m256i __b)
2889{
2890 return (__m256i)((__v4du)__a ^ (__v4du)__b);
2891}
2892
2893/// Loads the 256-bit integer vector from memory \a __V using a non-temporal
2894/// memory hint and returns the vector. \a __V must be aligned on a 32-byte
2895/// boundary.
2896///
2897/// \headerfile <immintrin.h>
2898///
2899/// This intrinsic corresponds to the \c VMOVNTDQA instruction.
2900///
2901/// \param __V
2902/// A pointer to the 32-byte aligned memory containing the vector to load.
2903/// \returns A 256-bit integer vector loaded from memory.
2904static __inline__ __m256i __DEFAULT_FN_ATTRS256
2906{
2907 typedef __v4di __v4di_aligned __attribute__((aligned(32)));
2908 return (__m256i)__builtin_nontemporal_load((const __v4di_aligned *)__V);
2909}
2910
2911/// Broadcasts the 32-bit floating-point value from the low element of the
2912/// 128-bit vector of [4 x float] in \a __X to all elements of the result's
2913/// 128-bit vector of [4 x float].
2914///
2915/// \headerfile <immintrin.h>
2916///
2917/// This intrinsic corresponds to the \c VBROADCASTSS instruction.
2918///
2919/// \param __X
2920/// A 128-bit vector of [4 x float] whose low element will be broadcast.
2921/// \returns A 128-bit vector of [4 x float] containing the result.
2922static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR
2924 return (__m128)__builtin_shufflevector((__v4sf)__X, (__v4sf)__X, 0, 0, 0, 0);
2925}
2926
2927/// Broadcasts the 64-bit floating-point value from the low element of the
2928/// 128-bit vector of [2 x double] in \a __a to both elements of the
2929/// result's 128-bit vector of [2 x double].
2930///
2931/// \headerfile <immintrin.h>
2932///
2933/// This intrinsic corresponds to the \c MOVDDUP instruction.
2934///
2935/// \param __a
2936/// A 128-bit vector of [2 x double] whose low element will be broadcast.
2937/// \returns A 128-bit vector of [2 x double] containing the result.
2938static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR
2940 return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
2941}
2942
2943/// Broadcasts the 32-bit floating-point value from the low element of the
2944/// 128-bit vector of [4 x float] in \a __X to all elements of the
2945/// result's 256-bit vector of [8 x float].
2946///
2947/// \headerfile <immintrin.h>
2948///
2949/// This intrinsic corresponds to the \c VBROADCASTSS instruction.
2950///
2951/// \param __X
2952/// A 128-bit vector of [4 x float] whose low element will be broadcast.
2953/// \returns A 256-bit vector of [8 x float] containing the result.
2954static __inline__ __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR
2956 return (__m256)__builtin_shufflevector((__v4sf)__X, (__v4sf)__X, 0, 0, 0, 0, 0, 0, 0, 0);
2957}
2958
2959/// Broadcasts the 64-bit floating-point value from the low element of the
2960/// 128-bit vector of [2 x double] in \a __X to all elements of the
2961/// result's 256-bit vector of [4 x double].
2962///
2963/// \headerfile <immintrin.h>
2964///
2965/// This intrinsic corresponds to the \c VBROADCASTSD instruction.
2966///
2967/// \param __X
2968/// A 128-bit vector of [2 x double] whose low element will be broadcast.
2969/// \returns A 256-bit vector of [4 x double] containing the result.
2970static __inline__ __m256d __DEFAULT_FN_ATTRS256_CONSTEXPR
2972 return (__m256d)__builtin_shufflevector((__v2df)__X, (__v2df)__X, 0, 0, 0, 0);
2973}
2974
2975/// Broadcasts the 128-bit integer data from \a __X to both the lower and
2976/// upper halves of the 256-bit result.
2977///
2978/// \headerfile <immintrin.h>
2979///
2980/// This intrinsic corresponds to the \c VBROADCASTI128 instruction.
2981///
2982/// \param __X
2983/// A 128-bit integer vector to be broadcast.
2984/// \returns A 256-bit integer vector containing the result.
2985static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
2987 return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 1, 0, 1);
2988}
2989
2990#define _mm_broadcastsi128_si256(X) _mm256_broadcastsi128_si256(X)
2991
2992/// Merges 32-bit integer elements from either of the two 128-bit vectors of
2993/// [4 x i32] in \a V1 or \a V2 to the result's 128-bit vector of [4 x i32],
2994/// as specified by the immediate integer operand \a M.
2995///
2996/// \code{.operation}
2997/// FOR i := 0 TO 3
2998/// j := i*32
2999/// IF M[i] == 0
3000/// result[31+j:j] := V1[31+j:j]
3001/// ELSE
3002/// result[31+j:j] := V2[32+j:j]
3003/// FI
3004/// ENDFOR
3005/// \endcode
3006///
3007/// \headerfile <immintrin.h>
3008///
3009/// \code
3010/// __m128i _mm_blend_epi32(__m128i V1, __m128i V2, const int M);
3011/// \endcode
3012///
3013/// This intrinsic corresponds to the \c VPBLENDDD instruction.
3014///
3015/// \param V1
3016/// A 128-bit vector of [4 x i32] containing source values.
3017/// \param V2
3018/// A 128-bit vector of [4 x i32] containing source values.
3019/// \param M
3020/// An immediate 8-bit integer operand, with bits [3:0] specifying the
3021/// source for each element of the result. The position of the mask bit
3022/// corresponds to the index of a copied value. When a mask bit is 0, the
3023/// element is copied from \a V1; otherwise, it is copied from \a V2.
3024/// \returns A 128-bit vector of [4 x i32] containing the result.
3025#define _mm_blend_epi32(V1, V2, M) \
3026 ((__m128i)__builtin_ia32_pblendd128((__v4si)(__m128i)(V1), \
3027 (__v4si)(__m128i)(V2), (int)(M)))
3028
3029/// Merges 32-bit integer elements from either of the two 256-bit vectors of
3030/// [8 x i32] in \a V1 or \a V2 to return a 256-bit vector of [8 x i32],
3031/// as specified by the immediate integer operand \a M.
3032///
3033/// \code{.operation}
3034/// FOR i := 0 TO 7
3035/// j := i*32
3036/// IF M[i] == 0
3037/// result[31+j:j] := V1[31+j:j]
3038/// ELSE
3039/// result[31+j:j] := V2[32+j:j]
3040/// FI
3041/// ENDFOR
3042/// \endcode
3043///
3044/// \headerfile <immintrin.h>
3045///
3046/// \code
3047/// __m256i _mm256_blend_epi32(__m256i V1, __m256i V2, const int M);
3048/// \endcode
3049///
3050/// This intrinsic corresponds to the \c VPBLENDDD instruction.
3051///
3052/// \param V1
3053/// A 256-bit vector of [8 x i32] containing source values.
3054/// \param V2
3055/// A 256-bit vector of [8 x i32] containing source values.
3056/// \param M
3057/// An immediate 8-bit integer operand, with bits [7:0] specifying the
3058/// source for each element of the result. The position of the mask bit
3059/// corresponds to the index of a copied value. When a mask bit is 0, the
3060/// element is copied from \a V1; otherwise, it is copied from \a V2.
3061/// \returns A 256-bit vector of [8 x i32] containing the result.
3062#define _mm256_blend_epi32(V1, V2, M) \
3063 ((__m256i)__builtin_ia32_pblendd256((__v8si)(__m256i)(V1), \
3064 (__v8si)(__m256i)(V2), (int)(M)))
3065
3066/// Broadcasts the low byte from the 128-bit integer vector in \a __X to all
3067/// bytes of the 256-bit result.
3068///
3069/// \headerfile <immintrin.h>
3070///
3071/// This intrinsic corresponds to the \c VPBROADCASTB instruction.
3072///
3073/// \param __X
3074/// A 128-bit integer vector whose low byte will be broadcast.
3075/// \returns A 256-bit integer vector containing the result.
3076static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3078 return (__m256i)__builtin_shufflevector((__v16qi)__X, (__v16qi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
3079}
3080
3081/// Broadcasts the low element from the 128-bit vector of [8 x i16] in \a __X
3082/// to all elements of the result's 256-bit vector of [16 x i16].
3083///
3084/// \headerfile <immintrin.h>
3085///
3086/// This intrinsic corresponds to the \c VPBROADCASTW instruction.
3087///
3088/// \param __X
3089/// A 128-bit vector of [8 x i16] whose low element will be broadcast.
3090/// \returns A 256-bit vector of [16 x i16] containing the result.
3091static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3093 return (__m256i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
3094}
3095
3096/// Broadcasts the low element from the 128-bit vector of [4 x i32] in \a __X
3097/// to all elements of the result's 256-bit vector of [8 x i32].
3098///
3099/// \headerfile <immintrin.h>
3100///
3101/// This intrinsic corresponds to the \c VPBROADCASTD instruction.
3102///
3103/// \param __X
3104/// A 128-bit vector of [4 x i32] whose low element will be broadcast.
3105/// \returns A 256-bit vector of [8 x i32] containing the result.
3106static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3108 return (__m256i)__builtin_shufflevector((__v4si)__X, (__v4si)__X, 0, 0, 0, 0, 0, 0, 0, 0);
3109}
3110
3111/// Broadcasts the low element from the 128-bit vector of [2 x i64] in \a __X
3112/// to all elements of the result's 256-bit vector of [4 x i64].
3113///
3114/// \headerfile <immintrin.h>
3115///
3116/// This intrinsic corresponds to the \c VPBROADCASTQ instruction.
3117///
3118/// \param __X
3119/// A 128-bit vector of [2 x i64] whose low element will be broadcast.
3120/// \returns A 256-bit vector of [4 x i64] containing the result.
3121static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3123 return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 0, 0, 0);
3124}
3125
3126/// Broadcasts the low byte from the 128-bit integer vector in \a __X to all
3127/// bytes of the 128-bit result.
3128///
3129/// \headerfile <immintrin.h>
3130///
3131/// This intrinsic corresponds to the \c VPBROADCASTB instruction.
3132///
3133/// \param __X
3134/// A 128-bit integer vector whose low byte will be broadcast.
3135/// \returns A 128-bit integer vector containing the result.
3136static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3138 return (__m128i)__builtin_shufflevector((__v16qi)__X, (__v16qi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
3139}
3140
3141/// Broadcasts the low element from the 128-bit vector of [8 x i16] in
3142/// \a __X to all elements of the result's 128-bit vector of [8 x i16].
3143///
3144/// \headerfile <immintrin.h>
3145///
3146/// This intrinsic corresponds to the \c VPBROADCASTW instruction.
3147///
3148/// \param __X
3149/// A 128-bit vector of [8 x i16] whose low element will be broadcast.
3150/// \returns A 128-bit vector of [8 x i16] containing the result.
3151static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3153 return (__m128i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0);
3154}
3155
3156/// Broadcasts the low element from the 128-bit vector of [4 x i32] in \a __X
3157/// to all elements of the result's vector of [4 x i32].
3158///
3159/// \headerfile <immintrin.h>
3160///
3161/// This intrinsic corresponds to the \c VPBROADCASTD instruction.
3162///
3163/// \param __X
3164/// A 128-bit vector of [4 x i32] whose low element will be broadcast.
3165/// \returns A 128-bit vector of [4 x i32] containing the result.
3166static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3168 return (__m128i)__builtin_shufflevector((__v4si)__X, (__v4si)__X, 0, 0, 0, 0);
3169}
3170
3171/// Broadcasts the low element from the 128-bit vector of [2 x i64] in \a __X
3172/// to both elements of the result's 128-bit vector of [2 x i64].
3173///
3174/// \headerfile <immintrin.h>
3175///
3176/// This intrinsic corresponds to the \c VPBROADCASTQ instruction.
3177///
3178/// \param __X
3179/// A 128-bit vector of [2 x i64] whose low element will be broadcast.
3180/// \returns A 128-bit vector of [2 x i64] containing the result.
3181static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3183 return (__m128i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 0);
3184}
3185
3186/// Sets the result's 256-bit vector of [8 x i32] to copies of elements of the
3187/// 256-bit vector of [8 x i32] in \a __a as specified by indexes in the
3188/// elements of the 256-bit vector of [8 x i32] in \a __b.
3189///
3190/// \code{.operation}
3191/// FOR i := 0 TO 7
3192/// j := i*32
3193/// k := __b[j+2:j] * 32
3194/// result[j+31:j] := __a[k+31:k]
3195/// ENDFOR
3196/// \endcode
3197///
3198/// \headerfile <immintrin.h>
3199///
3200/// This intrinsic corresponds to the \c VPERMD instruction.
3201///
3202/// \param __a
3203/// A 256-bit vector of [8 x i32] containing the source values.
3204/// \param __b
3205/// A 256-bit vector of [8 x i32] containing indexes of values to use from
3206/// \a __a.
3207/// \returns A 256-bit vector of [8 x i32] containing the result.
3208static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3210 return (__m256i)__builtin_ia32_permvarsi256((__v8si)__a, (__v8si)__b);
3211}
3212
3213/// Sets the result's 256-bit vector of [4 x double] to copies of elements of
3214/// the 256-bit vector of [4 x double] in \a V as specified by the
3215/// immediate value \a M.
3216///
3217/// \code{.operation}
3218/// FOR i := 0 TO 3
3219/// j := i*64
3220/// k := (M >> i*2)[1:0] * 64
3221/// result[j+63:j] := V[k+63:k]
3222/// ENDFOR
3223/// \endcode
3224///
3225/// \headerfile <immintrin.h>
3226///
3227/// \code
3228/// __m256d _mm256_permute4x64_pd(__m256d V, const int M);
3229/// \endcode
3230///
3231/// This intrinsic corresponds to the \c VPERMPD instruction.
3232///
3233/// \param V
3234/// A 256-bit vector of [4 x double] containing the source values.
3235/// \param M
3236/// An immediate 8-bit value specifying which elements to copy from \a V.
3237/// \a M[1:0] specifies the index in \a a for element 0 of the result,
3238/// \a M[3:2] specifies the index for element 1, and so forth.
3239/// \returns A 256-bit vector of [4 x double] containing the result.
3240#define _mm256_permute4x64_pd(V, M) \
3241 ((__m256d)__builtin_ia32_permdf256((__v4df)(__m256d)(V), (int)(M)))
3242
3243/// Sets the result's 256-bit vector of [8 x float] to copies of elements of
3244/// the 256-bit vector of [8 x float] in \a __a as specified by indexes in
3245/// the elements of the 256-bit vector of [8 x i32] in \a __b.
3246///
3247/// \code{.operation}
3248/// FOR i := 0 TO 7
3249/// j := i*32
3250/// k := __b[j+2:j] * 32
3251/// result[j+31:j] := __a[k+31:k]
3252/// ENDFOR
3253/// \endcode
3254///
3255/// \headerfile <immintrin.h>
3256///
3257/// This intrinsic corresponds to the \c VPERMPS instruction.
3258///
3259/// \param __a
3260/// A 256-bit vector of [8 x float] containing the source values.
3261/// \param __b
3262/// A 256-bit vector of [8 x i32] containing indexes of values to use from
3263/// \a __a.
3264/// \returns A 256-bit vector of [8 x float] containing the result.
3265static __inline__ __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR
3267 return (__m256)__builtin_ia32_permvarsf256((__v8sf)__a, (__v8si)__b);
3268}
3269
3270/// Sets the result's 256-bit vector of [4 x i64] result to copies of elements
3271/// of the 256-bit vector of [4 x i64] in \a V as specified by the
3272/// immediate value \a M.
3273///
3274/// \code{.operation}
3275/// FOR i := 0 TO 3
3276/// j := i*64
3277/// k := (M >> i*2)[1:0] * 64
3278/// result[j+63:j] := V[k+63:k]
3279/// ENDFOR
3280/// \endcode
3281///
3282/// \headerfile <immintrin.h>
3283///
3284/// \code
3285/// __m256i _mm256_permute4x64_epi64(__m256i V, const int M);
3286/// \endcode
3287///
3288/// This intrinsic corresponds to the \c VPERMQ instruction.
3289///
3290/// \param V
3291/// A 256-bit vector of [4 x i64] containing the source values.
3292/// \param M
3293/// An immediate 8-bit value specifying which elements to copy from \a V.
3294/// \a M[1:0] specifies the index in \a a for element 0 of the result,
3295/// \a M[3:2] specifies the index for element 1, and so forth.
3296/// \returns A 256-bit vector of [4 x i64] containing the result.
3297#define _mm256_permute4x64_epi64(V, M) \
3298 ((__m256i)__builtin_ia32_permdi256((__v4di)(__m256i)(V), (int)(M)))
3299
3300/// Sets each half of the 256-bit result either to zero or to one of the
3301/// four possible 128-bit halves of the 256-bit vectors \a V1 and \a V2,
3302/// as specified by the immediate value \a M.
3303///
3304/// \code{.operation}
3305/// FOR i := 0 TO 1
3306/// j := i*128
3307/// k := M >> (i*4)
3308/// IF k[3] == 0
3309/// CASE (k[1:0]) OF
3310/// 0: result[127+j:j] := V1[127:0]
3311/// 1: result[127+j:j] := V1[255:128]
3312/// 2: result[127+j:j] := V2[127:0]
3313/// 3: result[127+j:j] := V2[255:128]
3314/// ESAC
3315/// ELSE
3316/// result[127+j:j] := 0
3317/// FI
3318/// ENDFOR
3319/// \endcode
3320///
3321/// \headerfile <immintrin.h>
3322///
3323/// \code
3324/// __m256i _mm256_permute2x128_si256(__m256i V1, __m256i V2, const int M);
3325/// \endcode
3326///
3327/// This intrinsic corresponds to the \c VPERM2I128 instruction.
3328///
3329/// \param V1
3330/// A 256-bit integer vector containing source values.
3331/// \param V2
3332/// A 256-bit integer vector containing source values.
3333/// \param M
3334/// An immediate value specifying how to form the result. Bits [3:0]
3335/// control the lower half of the result, bits [7:4] control the upper half.
3336/// Within each 4-bit control value, if bit 3 is 1, the result is zero,
3337/// otherwise bits [1:0] determine the source as follows. \n
3338/// 0: the lower half of \a V1 \n
3339/// 1: the upper half of \a V1 \n
3340/// 2: the lower half of \a V2 \n
3341/// 3: the upper half of \a V2
3342/// \returns A 256-bit integer vector containing the result.
3343#define _mm256_permute2x128_si256(V1, V2, M) \
3344 ((__m256i)__builtin_ia32_permti256((__m256i)(V1), (__m256i)(V2), (int)(M)))
3345
3346/// Extracts half of the 256-bit vector \a V to the 128-bit result. If bit 0
3347/// of the immediate \a M is zero, extracts the lower half of the result;
3348/// otherwise, extracts the upper half.
3349///
3350/// \headerfile <immintrin.h>
3351///
3352/// \code
3353/// __m128i _mm256_extracti128_si256(__m256i V, const int M);
3354/// \endcode
3355///
3356/// This intrinsic corresponds to the \c VEXTRACTI128 instruction.
3357///
3358/// \param V
3359/// A 256-bit integer vector containing the source values.
3360/// \param M
3361/// An immediate value specifying which half of \a V to extract.
3362/// \returns A 128-bit integer vector containing the result.
3363#define _mm256_extracti128_si256(V, M) \
3364 ((__m128i)__builtin_ia32_extract128i256((__v4di)(__m256i)(V), (int)(M)))
3365
3366/// Copies the 256-bit vector \a V1 to the result, then overwrites half of the
3367/// result with the 128-bit vector \a V2. If bit 0 of the immediate \a M
3368/// is zero, overwrites the lower half of the result; otherwise,
3369/// overwrites the upper half.
3370///
3371/// \headerfile <immintrin.h>
3372///
3373/// \code
3374/// __m256i _mm256_inserti128_si256(__m256i V1, __m128i V2, const int M);
3375/// \endcode
3376///
3377/// This intrinsic corresponds to the \c VINSERTI128 instruction.
3378///
3379/// \param V1
3380/// A 256-bit integer vector containing a source value.
3381/// \param V2
3382/// A 128-bit integer vector containing a source value.
3383/// \param M
3384/// An immediate value specifying where to put \a V2 in the result.
3385/// \returns A 256-bit integer vector containing the result.
3386#define _mm256_inserti128_si256(V1, V2, M) \
3387 ((__m256i)__builtin_ia32_insert128i256((__v4di)(__m256i)(V1), \
3388 (__v2di)(__m128i)(V2), (int)(M)))
3389
3390/// Conditionally loads eight 32-bit integer elements from memory \a __X, if
3391/// the most significant bit of the corresponding element in the mask
3392/// \a __M is set; otherwise, sets that element of the result to zero.
3393/// Returns the 256-bit [8 x i32] result.
3394///
3395/// \code{.operation}
3396/// FOR i := 0 TO 7
3397/// j := i*32
3398/// IF __M[j+31] == 1
3399/// result[j+31:j] := Load32(__X+(i*4))
3400/// ELSE
3401/// result[j+31:j] := 0
3402/// FI
3403/// ENDFOR
3404/// \endcode
3405///
3406/// \headerfile <immintrin.h>
3407///
3408/// This intrinsic corresponds to the \c VPMASKMOVD instruction.
3409///
3410/// \param __X
3411/// A pointer to the memory used for loading values.
3412/// \param __M
3413/// A 256-bit vector of [8 x i32] containing the mask bits.
3414/// \returns A 256-bit vector of [8 x i32] containing the loaded or zeroed
3415/// elements.
3416static __inline__ __m256i __DEFAULT_FN_ATTRS256
3417_mm256_maskload_epi32(int const *__X, __m256i __M)
3418{
3419 return (__m256i)__builtin_ia32_maskloadd256((const __v8si *)__X, (__v8si)__M);
3420}
3421
3422/// Conditionally loads four 64-bit integer elements from memory \a __X, if
3423/// the most significant bit of the corresponding element in the mask
3424/// \a __M is set; otherwise, sets that element of the result to zero.
3425/// Returns the 256-bit [4 x i64] result.
3426///
3427/// \code{.operation}
3428/// FOR i := 0 TO 3
3429/// j := i*64
3430/// IF __M[j+63] == 1
3431/// result[j+63:j] := Load64(__X+(i*8))
3432/// ELSE
3433/// result[j+63:j] := 0
3434/// FI
3435/// ENDFOR
3436/// \endcode
3437///
3438/// \headerfile <immintrin.h>
3439///
3440/// This intrinsic corresponds to the \c VPMASKMOVQ instruction.
3441///
3442/// \param __X
3443/// A pointer to the memory used for loading values.
3444/// \param __M
3445/// A 256-bit vector of [4 x i64] containing the mask bits.
3446/// \returns A 256-bit vector of [4 x i64] containing the loaded or zeroed
3447/// elements.
3448static __inline__ __m256i __DEFAULT_FN_ATTRS256
3449_mm256_maskload_epi64(long long const *__X, __m256i __M)
3450{
3451 return (__m256i)__builtin_ia32_maskloadq256((const __v4di *)__X, (__v4di)__M);
3452}
3453
3454/// Conditionally loads four 32-bit integer elements from memory \a __X, if
3455/// the most significant bit of the corresponding element in the mask
3456/// \a __M is set; otherwise, sets that element of the result to zero.
3457/// Returns the 128-bit [4 x i32] result.
3458///
3459/// \code{.operation}
3460/// FOR i := 0 TO 3
3461/// j := i*32
3462/// IF __M[j+31] == 1
3463/// result[j+31:j] := Load32(__X+(i*4))
3464/// ELSE
3465/// result[j+31:j] := 0
3466/// FI
3467/// ENDFOR
3468/// \endcode
3469///
3470/// \headerfile <immintrin.h>
3471///
3472/// This intrinsic corresponds to the \c VPMASKMOVD instruction.
3473///
3474/// \param __X
3475/// A pointer to the memory used for loading values.
3476/// \param __M
3477/// A 128-bit vector of [4 x i32] containing the mask bits.
3478/// \returns A 128-bit vector of [4 x i32] containing the loaded or zeroed
3479/// elements.
3480static __inline__ __m128i __DEFAULT_FN_ATTRS128
3481_mm_maskload_epi32(int const *__X, __m128i __M)
3482{
3483 return (__m128i)__builtin_ia32_maskloadd((const __v4si *)__X, (__v4si)__M);
3484}
3485
3486/// Conditionally loads two 64-bit integer elements from memory \a __X, if
3487/// the most significant bit of the corresponding element in the mask
3488/// \a __M is set; otherwise, sets that element of the result to zero.
3489/// Returns the 128-bit [2 x i64] result.
3490///
3491/// \code{.operation}
3492/// FOR i := 0 TO 1
3493/// j := i*64
3494/// IF __M[j+63] == 1
3495/// result[j+63:j] := Load64(__X+(i*8))
3496/// ELSE
3497/// result[j+63:j] := 0
3498/// FI
3499/// ENDFOR
3500/// \endcode
3501///
3502/// \headerfile <immintrin.h>
3503///
3504/// This intrinsic corresponds to the \c VPMASKMOVQ instruction.
3505///
3506/// \param __X
3507/// A pointer to the memory used for loading values.
3508/// \param __M
3509/// A 128-bit vector of [2 x i64] containing the mask bits.
3510/// \returns A 128-bit vector of [2 x i64] containing the loaded or zeroed
3511/// elements.
3512static __inline__ __m128i __DEFAULT_FN_ATTRS128
3513_mm_maskload_epi64(long long const *__X, __m128i __M)
3514{
3515 return (__m128i)__builtin_ia32_maskloadq((const __v2di *)__X, (__v2di)__M);
3516}
3517
3518/// Conditionally stores eight 32-bit integer elements from the 256-bit vector
3519/// of [8 x i32] in \a __Y to memory \a __X, if the most significant bit of
3520/// the corresponding element in the mask \a __M is set; otherwise, the
3521/// memory element is unchanged.
3522///
3523/// \code{.operation}
3524/// FOR i := 0 TO 7
3525/// j := i*32
3526/// IF __M[j+31] == 1
3527/// Store32(__X+(i*4), __Y[j+31:j])
3528/// FI
3529/// ENDFOR
3530/// \endcode
3531///
3532/// \headerfile <immintrin.h>
3533///
3534/// This intrinsic corresponds to the \c VPMASKMOVD instruction.
3535///
3536/// \param __X
3537/// A pointer to the memory used for storing values.
3538/// \param __M
3539/// A 256-bit vector of [8 x i32] containing the mask bits.
3540/// \param __Y
3541/// A 256-bit vector of [8 x i32] containing the values to store.
3542static __inline__ void __DEFAULT_FN_ATTRS256
3543_mm256_maskstore_epi32(int *__X, __m256i __M, __m256i __Y)
3544{
3545 __builtin_ia32_maskstored256((__v8si *)__X, (__v8si)__M, (__v8si)__Y);
3546}
3547
3548/// Conditionally stores four 64-bit integer elements from the 256-bit vector
3549/// of [4 x i64] in \a __Y to memory \a __X, if the most significant bit of
3550/// the corresponding element in the mask \a __M is set; otherwise, the
3551/// memory element is unchanged.
3552///
3553/// \code{.operation}
3554/// FOR i := 0 TO 3
3555/// j := i*64
3556/// IF __M[j+63] == 1
3557/// Store64(__X+(i*8), __Y[j+63:j])
3558/// FI
3559/// ENDFOR
3560/// \endcode
3561///
3562/// \headerfile <immintrin.h>
3563///
3564/// This intrinsic corresponds to the \c VPMASKMOVQ instruction.
3565///
3566/// \param __X
3567/// A pointer to the memory used for storing values.
3568/// \param __M
3569/// A 256-bit vector of [4 x i64] containing the mask bits.
3570/// \param __Y
3571/// A 256-bit vector of [4 x i64] containing the values to store.
3572static __inline__ void __DEFAULT_FN_ATTRS256
3573_mm256_maskstore_epi64(long long *__X, __m256i __M, __m256i __Y)
3574{
3575 __builtin_ia32_maskstoreq256((__v4di *)__X, (__v4di)__M, (__v4di)__Y);
3576}
3577
3578/// Conditionally stores four 32-bit integer elements from the 128-bit vector
3579/// of [4 x i32] in \a __Y to memory \a __X, if the most significant bit of
3580/// the corresponding element in the mask \a __M is set; otherwise, the
3581/// memory element is unchanged.
3582///
3583/// \code{.operation}
3584/// FOR i := 0 TO 3
3585/// j := i*32
3586/// IF __M[j+31] == 1
3587/// Store32(__X+(i*4), __Y[j+31:j])
3588/// FI
3589/// ENDFOR
3590/// \endcode
3591///
3592/// \headerfile <immintrin.h>
3593///
3594/// This intrinsic corresponds to the \c VPMASKMOVD instruction.
3595///
3596/// \param __X
3597/// A pointer to the memory used for storing values.
3598/// \param __M
3599/// A 128-bit vector of [4 x i32] containing the mask bits.
3600/// \param __Y
3601/// A 128-bit vector of [4 x i32] containing the values to store.
3602static __inline__ void __DEFAULT_FN_ATTRS128
3603_mm_maskstore_epi32(int *__X, __m128i __M, __m128i __Y)
3604{
3605 __builtin_ia32_maskstored((__v4si *)__X, (__v4si)__M, (__v4si)__Y);
3606}
3607
3608/// Conditionally stores two 64-bit integer elements from the 128-bit vector
3609/// of [2 x i64] in \a __Y to memory \a __X, if the most significant bit of
3610/// the corresponding element in the mask \a __M is set; otherwise, the
3611/// memory element is unchanged.
3612///
3613/// \code{.operation}
3614/// FOR i := 0 TO 1
3615/// j := i*64
3616/// IF __M[j+63] == 1
3617/// Store64(__X+(i*8), __Y[j+63:j])
3618/// FI
3619/// ENDFOR
3620/// \endcode
3621///
3622/// \headerfile <immintrin.h>
3623///
3624/// This intrinsic corresponds to the \c VPMASKMOVQ instruction.
3625///
3626/// \param __X
3627/// A pointer to the memory used for storing values.
3628/// \param __M
3629/// A 128-bit vector of [2 x i64] containing the mask bits.
3630/// \param __Y
3631/// A 128-bit vector of [2 x i64] containing the values to store.
3632static __inline__ void __DEFAULT_FN_ATTRS128
3633_mm_maskstore_epi64(long long *__X, __m128i __M, __m128i __Y)
3634{
3635 __builtin_ia32_maskstoreq(( __v2di *)__X, (__v2di)__M, (__v2di)__Y);
3636}
3637
3638/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X
3639/// left by the number of bits given in the corresponding element of the
3640/// 256-bit vector of [8 x i32] in \a __Y, shifting in zero bits, and
3641/// returns the result. If the shift count for any element is greater than
3642/// 31, the result for that element is zero.
3643///
3644/// \headerfile <immintrin.h>
3645///
3646/// This intrinsic corresponds to the \c VPSLLVD instruction.
3647///
3648/// \param __X
3649/// A 256-bit vector of [8 x i32] to be shifted.
3650/// \param __Y
3651/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in
3652/// bits).
3653/// \returns A 256-bit vector of [8 x i32] containing the result.
3654static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3655_mm256_sllv_epi32(__m256i __X, __m256i __Y)
3656{
3657 return (__m256i)__builtin_ia32_psllv8si((__v8si)__X, (__v8si)__Y);
3658}
3659
3660/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X
3661/// left by the number of bits given in the corresponding element of the
3662/// 128-bit vector of [4 x i32] in \a __Y, shifting in zero bits, and
3663/// returns the result. If the shift count for any element is greater than
3664/// 31, the result for that element is zero.
3665///
3666/// \headerfile <immintrin.h>
3667///
3668/// This intrinsic corresponds to the \c VPSLLVD instruction.
3669///
3670/// \param __X
3671/// A 128-bit vector of [4 x i32] to be shifted.
3672/// \param __Y
3673/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in
3674/// bits).
3675/// \returns A 128-bit vector of [4 x i32] containing the result.
3676static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3677_mm_sllv_epi32(__m128i __X, __m128i __Y)
3678{
3679 return (__m128i)__builtin_ia32_psllv4si((__v4si)__X, (__v4si)__Y);
3680}
3681
3682/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __X
3683/// left by the number of bits given in the corresponding element of the
3684/// 128-bit vector of [4 x i64] in \a __Y, shifting in zero bits, and
3685/// returns the result. If the shift count for any element is greater than
3686/// 63, the result for that element is zero.
3687///
3688/// \headerfile <immintrin.h>
3689///
3690/// This intrinsic corresponds to the \c VPSLLVQ instruction.
3691///
3692/// \param __X
3693/// A 256-bit vector of [4 x i64] to be shifted.
3694/// \param __Y
3695/// A 256-bit vector of [4 x i64] containing the unsigned shift counts (in
3696/// bits).
3697/// \returns A 256-bit vector of [4 x i64] containing the result.
3698static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3699_mm256_sllv_epi64(__m256i __X, __m256i __Y)
3700{
3701 return (__m256i)__builtin_ia32_psllv4di((__v4di)__X, (__v4di)__Y);
3702}
3703
3704/// Shifts each 64-bit element of the 128-bit vector of [2 x i64] in \a __X
3705/// left by the number of bits given in the corresponding element of the
3706/// 128-bit vector of [2 x i64] in \a __Y, shifting in zero bits, and
3707/// returns the result. If the shift count for any element is greater than
3708/// 63, the result for that element is zero.
3709///
3710/// \headerfile <immintrin.h>
3711///
3712/// This intrinsic corresponds to the \c VPSLLVQ instruction.
3713///
3714/// \param __X
3715/// A 128-bit vector of [2 x i64] to be shifted.
3716/// \param __Y
3717/// A 128-bit vector of [2 x i64] containing the unsigned shift counts (in
3718/// bits).
3719/// \returns A 128-bit vector of [2 x i64] containing the result.
3720static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3721_mm_sllv_epi64(__m128i __X, __m128i __Y)
3722{
3723 return (__m128i)__builtin_ia32_psllv2di((__v2di)__X, (__v2di)__Y);
3724}
3725
3726/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X
3727/// right by the number of bits given in the corresponding element of the
3728/// 256-bit vector of [8 x i32] in \a __Y, shifting in sign bits, and
3729/// returns the result. If the shift count for any element is greater than
3730/// 31, the result for that element is 0 or -1 according to the sign bit
3731/// for that element.
3732///
3733/// \headerfile <immintrin.h>
3734///
3735/// This intrinsic corresponds to the \c VPSRAVD instruction.
3736///
3737/// \param __X
3738/// A 256-bit vector of [8 x i32] to be shifted.
3739/// \param __Y
3740/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in
3741/// bits).
3742/// \returns A 256-bit vector of [8 x i32] containing the result.
3743static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3744_mm256_srav_epi32(__m256i __X, __m256i __Y)
3745{
3746 return (__m256i)__builtin_ia32_psrav8si((__v8si)__X, (__v8si)__Y);
3747}
3748
3749/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X
3750/// right by the number of bits given in the corresponding element of the
3751/// 128-bit vector of [4 x i32] in \a __Y, shifting in sign bits, and
3752/// returns the result. If the shift count for any element is greater than
3753/// 31, the result for that element is 0 or -1 according to the sign bit
3754/// for that element.
3755///
3756/// \headerfile <immintrin.h>
3757///
3758/// This intrinsic corresponds to the \c VPSRAVD instruction.
3759///
3760/// \param __X
3761/// A 128-bit vector of [4 x i32] to be shifted.
3762/// \param __Y
3763/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in
3764/// bits).
3765/// \returns A 128-bit vector of [4 x i32] containing the result.
3766static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3767_mm_srav_epi32(__m128i __X, __m128i __Y)
3768{
3769 return (__m128i)__builtin_ia32_psrav4si((__v4si)__X, (__v4si)__Y);
3770}
3771
3772/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X
3773/// right by the number of bits given in the corresponding element of the
3774/// 256-bit vector of [8 x i32] in \a __Y, shifting in zero bits, and
3775/// returns the result. If the shift count for any element is greater than
3776/// 31, the result for that element is zero.
3777///
3778/// \headerfile <immintrin.h>
3779///
3780/// This intrinsic corresponds to the \c VPSRLVD instruction.
3781///
3782/// \param __X
3783/// A 256-bit vector of [8 x i32] to be shifted.
3784/// \param __Y
3785/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in
3786/// bits).
3787/// \returns A 256-bit vector of [8 x i32] containing the result.
3788static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3789_mm256_srlv_epi32(__m256i __X, __m256i __Y)
3790{
3791 return (__m256i)__builtin_ia32_psrlv8si((__v8si)__X, (__v8si)__Y);
3792}
3793
3794/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X
3795/// right by the number of bits given in the corresponding element of the
3796/// 128-bit vector of [4 x i32] in \a __Y, shifting in zero bits, and
3797/// returns the result. If the shift count for any element is greater than
3798/// 31, the result for that element is zero.
3799///
3800/// \headerfile <immintrin.h>
3801///
3802/// This intrinsic corresponds to the \c VPSRLVD instruction.
3803///
3804/// \param __X
3805/// A 128-bit vector of [4 x i32] to be shifted.
3806/// \param __Y
3807/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in
3808/// bits).
3809/// \returns A 128-bit vector of [4 x i32] containing the result.
3810static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3811_mm_srlv_epi32(__m128i __X, __m128i __Y)
3812{
3813 return (__m128i)__builtin_ia32_psrlv4si((__v4si)__X, (__v4si)__Y);
3814}
3815
3816/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __X
3817/// right by the number of bits given in the corresponding element of the
3818/// 128-bit vector of [4 x i64] in \a __Y, shifting in zero bits, and
3819/// returns the result. If the shift count for any element is greater than
3820/// 63, the result for that element is zero.
3821///
3822/// \headerfile <immintrin.h>
3823///
3824/// This intrinsic corresponds to the \c VPSRLVQ instruction.
3825///
3826/// \param __X
3827/// A 256-bit vector of [4 x i64] to be shifted.
3828/// \param __Y
3829/// A 256-bit vector of [4 x i64] containing the unsigned shift counts (in
3830/// bits).
3831/// \returns A 256-bit vector of [4 x i64] containing the result.
3832static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
3833_mm256_srlv_epi64(__m256i __X, __m256i __Y)
3834{
3835 return (__m256i)__builtin_ia32_psrlv4di((__v4di)__X, (__v4di)__Y);
3836}
3837
3838/// Shifts each 64-bit element of the 128-bit vector of [2 x i64] in \a __X
3839/// right by the number of bits given in the corresponding element of the
3840/// 128-bit vector of [2 x i64] in \a __Y, shifting in zero bits, and
3841/// returns the result. If the shift count for any element is greater than
3842/// 63, the result for that element is zero.
3843///
3844/// \headerfile <immintrin.h>
3845///
3846/// This intrinsic corresponds to the \c VPSRLVQ instruction.
3847///
3848/// \param __X
3849/// A 128-bit vector of [2 x i64] to be shifted.
3850/// \param __Y
3851/// A 128-bit vector of [2 x i64] containing the unsigned shift counts (in
3852/// bits).
3853/// \returns A 128-bit vector of [2 x i64] containing the result.
3854static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
3855_mm_srlv_epi64(__m128i __X, __m128i __Y)
3856{
3857 return (__m128i)__builtin_ia32_psrlv2di((__v2di)__X, (__v2di)__Y);
3858}
3859
3860/// Conditionally gathers two 64-bit floating-point values, either from the
3861/// 128-bit vector of [2 x double] in \a a, or from memory \a m using scaled
3862/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
3863/// of [2 x double] in \a mask determines the source for each element.
3864///
3865/// \code{.operation}
3866/// FOR element := 0 to 1
3867/// j := element*64
3868/// k := element*32
3869/// IF mask[j+63] == 0
3870/// result[j+63:j] := a[j+63:j]
3871/// ELSE
3872/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
3873/// FI
3874/// ENDFOR
3875/// \endcode
3876///
3877/// \headerfile <immintrin.h>
3878///
3879/// \code
3880/// __m128d _mm_mask_i32gather_pd(__m128d a, const double *m, __m128i i,
3881/// __m128d mask, const int s);
3882/// \endcode
3883///
3884/// This intrinsic corresponds to the \c VGATHERDPD instruction.
3885///
3886/// \param a
3887/// A 128-bit vector of [2 x double] used as the source when a mask bit is
3888/// zero.
3889/// \param m
3890/// A pointer to the memory used for loading values.
3891/// \param i
3892/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
3893/// the first two elements are used.
3894/// \param mask
3895/// A 128-bit vector of [2 x double] containing the mask. The most
3896/// significant bit of each element in the mask vector represents the mask
3897/// bits. If a mask bit is zero, the corresponding value from vector \a a
3898/// is gathered; otherwise the value is loaded from memory.
3899/// \param s
3900/// A literal constant scale factor for the indexes in \a i. Must be
3901/// 1, 2, 4, or 8.
3902/// \returns A 128-bit vector of [2 x double] containing the gathered values.
3903#define _mm_mask_i32gather_pd(a, m, i, mask, s) \
3904 ((__m128d)__builtin_ia32_gatherd_pd((__v2df)(__m128i)(a), \
3905 (double const *)(m), \
3906 (__v4si)(__m128i)(i), \
3907 (__v2df)(__m128d)(mask), (s)))
3908
3909/// Conditionally gathers four 64-bit floating-point values, either from the
3910/// 256-bit vector of [4 x double] in \a a, or from memory \a m using scaled
3911/// indexes from the 128-bit vector of [4 x i32] in \a i. The 256-bit vector
3912/// of [4 x double] in \a mask determines the source for each element.
3913///
3914/// \code{.operation}
3915/// FOR element := 0 to 3
3916/// j := element*64
3917/// k := element*32
3918/// IF mask[j+63] == 0
3919/// result[j+63:j] := a[j+63:j]
3920/// ELSE
3921/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
3922/// FI
3923/// ENDFOR
3924/// \endcode
3925///
3926/// \headerfile <immintrin.h>
3927///
3928/// \code
3929/// __m256d _mm256_mask_i32gather_pd(__m256d a, const double *m, __m128i i,
3930/// __m256d mask, const int s);
3931/// \endcode
3932///
3933/// This intrinsic corresponds to the \c VGATHERDPD instruction.
3934///
3935/// \param a
3936/// A 256-bit vector of [4 x double] used as the source when a mask bit is
3937/// zero.
3938/// \param m
3939/// A pointer to the memory used for loading values.
3940/// \param i
3941/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
3942/// \param mask
3943/// A 256-bit vector of [4 x double] containing the mask. The most
3944/// significant bit of each element in the mask vector represents the mask
3945/// bits. If a mask bit is zero, the corresponding value from vector \a a
3946/// is gathered; otherwise the value is loaded from memory.
3947/// \param s
3948/// A literal constant scale factor for the indexes in \a i. Must be
3949/// 1, 2, 4, or 8.
3950/// \returns A 256-bit vector of [4 x double] containing the gathered values.
3951#define _mm256_mask_i32gather_pd(a, m, i, mask, s) \
3952 ((__m256d)__builtin_ia32_gatherd_pd256((__v4df)(__m256d)(a), \
3953 (double const *)(m), \
3954 (__v4si)(__m128i)(i), \
3955 (__v4df)(__m256d)(mask), (s)))
3956
3957/// Conditionally gathers two 64-bit floating-point values, either from the
3958/// 128-bit vector of [2 x double] in \a a, or from memory \a m using scaled
3959/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
3960/// of [2 x double] in \a mask determines the source for each element.
3961///
3962/// \code{.operation}
3963/// FOR element := 0 to 1
3964/// j := element*64
3965/// k := element*64
3966/// IF mask[j+63] == 0
3967/// result[j+63:j] := a[j+63:j]
3968/// ELSE
3969/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
3970/// FI
3971/// ENDFOR
3972/// \endcode
3973///
3974/// \headerfile <immintrin.h>
3975///
3976/// \code
3977/// __m128d _mm_mask_i64gather_pd(__m128d a, const double *m, __m128i i,
3978/// __m128d mask, const int s);
3979/// \endcode
3980///
3981/// This intrinsic corresponds to the \c VGATHERQPD instruction.
3982///
3983/// \param a
3984/// A 128-bit vector of [2 x double] used as the source when a mask bit is
3985/// zero.
3986/// \param m
3987/// A pointer to the memory used for loading values.
3988/// \param i
3989/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
3990/// \param mask
3991/// A 128-bit vector of [2 x double] containing the mask. The most
3992/// significant bit of each element in the mask vector represents the mask
3993/// bits. If a mask bit is zero, the corresponding value from vector \a a
3994/// is gathered; otherwise the value is loaded from memory.
3995/// \param s
3996/// A literal constant scale factor for the indexes in \a i. Must be
3997/// 1, 2, 4, or 8.
3998/// \returns A 128-bit vector of [2 x double] containing the gathered values.
3999#define _mm_mask_i64gather_pd(a, m, i, mask, s) \
4000 ((__m128d)__builtin_ia32_gatherq_pd((__v2df)(__m128d)(a), \
4001 (double const *)(m), \
4002 (__v2di)(__m128i)(i), \
4003 (__v2df)(__m128d)(mask), (s)))
4004
4005/// Conditionally gathers four 64-bit floating-point values, either from the
4006/// 256-bit vector of [4 x double] in \a a, or from memory \a m using scaled
4007/// indexes from the 256-bit vector of [4 x i64] in \a i. The 256-bit vector
4008/// of [4 x double] in \a mask determines the source for each element.
4009///
4010/// \code{.operation}
4011/// FOR element := 0 to 3
4012/// j := element*64
4013/// k := element*64
4014/// IF mask[j+63] == 0
4015/// result[j+63:j] := a[j+63:j]
4016/// ELSE
4017/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4018/// FI
4019/// ENDFOR
4020/// \endcode
4021///
4022/// \headerfile <immintrin.h>
4023///
4024/// \code
4025/// __m256d _mm256_mask_i64gather_pd(__m256d a, const double *m, __m256i i,
4026/// __m256d mask, const int s);
4027/// \endcode
4028///
4029/// This intrinsic corresponds to the \c VGATHERQPD instruction.
4030///
4031/// \param a
4032/// A 256-bit vector of [4 x double] used as the source when a mask bit is
4033/// zero.
4034/// \param m
4035/// A pointer to the memory used for loading values.
4036/// \param i
4037/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4038/// \param mask
4039/// A 256-bit vector of [4 x double] containing the mask. The most
4040/// significant bit of each element in the mask vector represents the mask
4041/// bits. If a mask bit is zero, the corresponding value from vector \a a
4042/// is gathered; otherwise the value is loaded from memory.
4043/// \param s
4044/// A literal constant scale factor for the indexes in \a i. Must be
4045/// 1, 2, 4, or 8.
4046/// \returns A 256-bit vector of [4 x double] containing the gathered values.
4047#define _mm256_mask_i64gather_pd(a, m, i, mask, s) \
4048 ((__m256d)__builtin_ia32_gatherq_pd256((__v4df)(__m256d)(a), \
4049 (double const *)(m), \
4050 (__v4di)(__m256i)(i), \
4051 (__v4df)(__m256d)(mask), (s)))
4052
4053/// Conditionally gathers four 32-bit floating-point values, either from the
4054/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled
4055/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
4056/// of [4 x float] in \a mask determines the source for each element.
4057///
4058/// \code{.operation}
4059/// FOR element := 0 to 3
4060/// j := element*32
4061/// k := element*32
4062/// IF mask[j+31] == 0
4063/// result[j+31:j] := a[j+31:j]
4064/// ELSE
4065/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4066/// FI
4067/// ENDFOR
4068/// \endcode
4069///
4070/// \headerfile <immintrin.h>
4071///
4072/// \code
4073/// __m128 _mm_mask_i32gather_ps(__m128 a, const float *m, __m128i i,
4074/// __m128 mask, const int s);
4075/// \endcode
4076///
4077/// This intrinsic corresponds to the \c VGATHERDPS instruction.
4078///
4079/// \param a
4080/// A 128-bit vector of [4 x float] used as the source when a mask bit is
4081/// zero.
4082/// \param m
4083/// A pointer to the memory used for loading values.
4084/// \param i
4085/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4086/// \param mask
4087/// A 128-bit vector of [4 x float] containing the mask. The most
4088/// significant bit of each element in the mask vector represents the mask
4089/// bits. If a mask bit is zero, the corresponding value from vector \a a
4090/// is gathered; otherwise the value is loaded from memory.
4091/// \param s
4092/// A literal constant scale factor for the indexes in \a i. Must be
4093/// 1, 2, 4, or 8.
4094/// \returns A 128-bit vector of [4 x float] containing the gathered values.
4095#define _mm_mask_i32gather_ps(a, m, i, mask, s) \
4096 ((__m128)__builtin_ia32_gatherd_ps((__v4sf)(__m128)(a), \
4097 (float const *)(m), \
4098 (__v4si)(__m128i)(i), \
4099 (__v4sf)(__m128)(mask), (s)))
4100
4101/// Conditionally gathers eight 32-bit floating-point values, either from the
4102/// 256-bit vector of [8 x float] in \a a, or from memory \a m using scaled
4103/// indexes from the 256-bit vector of [8 x i32] in \a i. The 256-bit vector
4104/// of [8 x float] in \a mask determines the source for each element.
4105///
4106/// \code{.operation}
4107/// FOR element := 0 to 7
4108/// j := element*32
4109/// k := element*32
4110/// IF mask[j+31] == 0
4111/// result[j+31:j] := a[j+31:j]
4112/// ELSE
4113/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4114/// FI
4115/// ENDFOR
4116/// \endcode
4117///
4118/// \headerfile <immintrin.h>
4119///
4120/// \code
4121/// __m256 _mm256_mask_i32gather_ps(__m256 a, const float *m, __m256i i,
4122/// __m256 mask, const int s);
4123/// \endcode
4124///
4125/// This intrinsic corresponds to the \c VGATHERDPS instruction.
4126///
4127/// \param a
4128/// A 256-bit vector of [8 x float] used as the source when a mask bit is
4129/// zero.
4130/// \param m
4131/// A pointer to the memory used for loading values.
4132/// \param i
4133/// A 256-bit vector of [8 x i32] containing signed indexes into \a m.
4134/// \param mask
4135/// A 256-bit vector of [8 x float] containing the mask. The most
4136/// significant bit of each element in the mask vector represents the mask
4137/// bits. If a mask bit is zero, the corresponding value from vector \a a
4138/// is gathered; otherwise the value is loaded from memory.
4139/// \param s
4140/// A literal constant scale factor for the indexes in \a i. Must be
4141/// 1, 2, 4, or 8.
4142/// \returns A 256-bit vector of [8 x float] containing the gathered values.
4143#define _mm256_mask_i32gather_ps(a, m, i, mask, s) \
4144 ((__m256)__builtin_ia32_gatherd_ps256((__v8sf)(__m256)(a), \
4145 (float const *)(m), \
4146 (__v8si)(__m256i)(i), \
4147 (__v8sf)(__m256)(mask), (s)))
4148
4149/// Conditionally gathers two 32-bit floating-point values, either from the
4150/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled
4151/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
4152/// of [4 x float] in \a mask determines the source for the lower two
4153/// elements. The upper two elements of the result are zeroed.
4154///
4155/// \code{.operation}
4156/// FOR element := 0 to 1
4157/// j := element*32
4158/// k := element*64
4159/// IF mask[j+31] == 0
4160/// result[j+31:j] := a[j+31:j]
4161/// ELSE
4162/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4163/// FI
4164/// ENDFOR
4165/// result[127:64] := 0
4166/// \endcode
4167///
4168/// \headerfile <immintrin.h>
4169///
4170/// \code
4171/// __m128 _mm_mask_i64gather_ps(__m128 a, const float *m, __m128i i,
4172/// __m128 mask, const int s);
4173/// \endcode
4174///
4175/// This intrinsic corresponds to the \c VGATHERQPS instruction.
4176///
4177/// \param a
4178/// A 128-bit vector of [4 x float] used as the source when a mask bit is
4179/// zero. Only the first two elements are used.
4180/// \param m
4181/// A pointer to the memory used for loading values.
4182/// \param i
4183/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4184/// \param mask
4185/// A 128-bit vector of [4 x float] containing the mask. The most
4186/// significant bit of each element in the mask vector represents the mask
4187/// bits. If a mask bit is zero, the corresponding value from vector \a a
4188/// is gathered; otherwise the value is loaded from memory. Only the first
4189/// two elements are used.
4190/// \param s
4191/// A literal constant scale factor for the indexes in \a i. Must be
4192/// 1, 2, 4, or 8.
4193/// \returns A 128-bit vector of [4 x float] containing the gathered values.
4194#define _mm_mask_i64gather_ps(a, m, i, mask, s) \
4195 ((__m128)__builtin_ia32_gatherq_ps((__v4sf)(__m128)(a), \
4196 (float const *)(m), \
4197 (__v2di)(__m128i)(i), \
4198 (__v4sf)(__m128)(mask), (s)))
4199
4200/// Conditionally gathers four 32-bit floating-point values, either from the
4201/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled
4202/// indexes from the 256-bit vector of [4 x i64] in \a i. The 128-bit vector
4203/// of [4 x float] in \a mask determines the source for each element.
4204///
4205/// \code{.operation}
4206/// FOR element := 0 to 3
4207/// j := element*32
4208/// k := element*64
4209/// IF mask[j+31] == 0
4210/// result[j+31:j] := a[j+31:j]
4211/// ELSE
4212/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4213/// FI
4214/// ENDFOR
4215/// \endcode
4216///
4217/// \headerfile <immintrin.h>
4218///
4219/// \code
4220/// __m128 _mm256_mask_i64gather_ps(__m128 a, const float *m, __m256i i,
4221/// __m128 mask, const int s);
4222/// \endcode
4223///
4224/// This intrinsic corresponds to the \c VGATHERQPS instruction.
4225///
4226/// \param a
4227/// A 128-bit vector of [4 x float] used as the source when a mask bit is
4228/// zero.
4229/// \param m
4230/// A pointer to the memory used for loading values.
4231/// \param i
4232/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4233/// \param mask
4234/// A 128-bit vector of [4 x float] containing the mask. The most
4235/// significant bit of each element in the mask vector represents the mask
4236/// bits. If a mask bit is zero, the corresponding value from vector \a a
4237/// is gathered; otherwise the value is loaded from memory.
4238/// \param s
4239/// A literal constant scale factor for the indexes in \a i. Must be
4240/// 1, 2, 4, or 8.
4241/// \returns A 128-bit vector of [4 x float] containing the gathered values.
4242#define _mm256_mask_i64gather_ps(a, m, i, mask, s) \
4243 ((__m128)__builtin_ia32_gatherq_ps256((__v4sf)(__m128)(a), \
4244 (float const *)(m), \
4245 (__v4di)(__m256i)(i), \
4246 (__v4sf)(__m128)(mask), (s)))
4247
4248/// Conditionally gathers four 32-bit integer values, either from the
4249/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled
4250/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
4251/// of [4 x i32] in \a mask determines the source for each element.
4252///
4253/// \code{.operation}
4254/// FOR element := 0 to 3
4255/// j := element*32
4256/// k := element*32
4257/// IF mask[j+31] == 0
4258/// result[j+31:j] := a[j+31:j]
4259/// ELSE
4260/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4261/// FI
4262/// ENDFOR
4263/// \endcode
4264///
4265/// \headerfile <immintrin.h>
4266///
4267/// \code
4268/// __m128i _mm_mask_i32gather_epi32(__m128i a, const int *m, __m128i i,
4269/// __m128i mask, const int s);
4270/// \endcode
4271///
4272/// This intrinsic corresponds to the \c VPGATHERDD instruction.
4273///
4274/// \param a
4275/// A 128-bit vector of [4 x i32] used as the source when a mask bit is
4276/// zero.
4277/// \param m
4278/// A pointer to the memory used for loading values.
4279/// \param i
4280/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4281/// \param mask
4282/// A 128-bit vector of [4 x i32] containing the mask. The most significant
4283/// bit of each element in the mask vector represents the mask bits. If a
4284/// mask bit is zero, the corresponding value from vector \a a is gathered;
4285/// otherwise the value is loaded from memory.
4286/// \param s
4287/// A literal constant scale factor for the indexes in \a i. Must be
4288/// 1, 2, 4, or 8.
4289/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
4290#define _mm_mask_i32gather_epi32(a, m, i, mask, s) \
4291 ((__m128i)__builtin_ia32_gatherd_d((__v4si)(__m128i)(a), \
4292 (int const *)(m), \
4293 (__v4si)(__m128i)(i), \
4294 (__v4si)(__m128i)(mask), (s)))
4295
4296/// Conditionally gathers eight 32-bit integer values, either from the
4297/// 256-bit vector of [8 x i32] in \a a, or from memory \a m using scaled
4298/// indexes from the 256-bit vector of [8 x i32] in \a i. The 256-bit vector
4299/// of [8 x i32] in \a mask determines the source for each element.
4300///
4301/// \code{.operation}
4302/// FOR element := 0 to 7
4303/// j := element*32
4304/// k := element*32
4305/// IF mask[j+31] == 0
4306/// result[j+31:j] := a[j+31:j]
4307/// ELSE
4308/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4309/// FI
4310/// ENDFOR
4311/// \endcode
4312///
4313/// \headerfile <immintrin.h>
4314///
4315/// \code
4316/// __m256i _mm256_mask_i32gather_epi32(__m256i a, const int *m, __m256i i,
4317/// __m256i mask, const int s);
4318/// \endcode
4319///
4320/// This intrinsic corresponds to the \c VPGATHERDD instruction.
4321///
4322/// \param a
4323/// A 256-bit vector of [8 x i32] used as the source when a mask bit is
4324/// zero.
4325/// \param m
4326/// A pointer to the memory used for loading values.
4327/// \param i
4328/// A 256-bit vector of [8 x i32] containing signed indexes into \a m.
4329/// \param mask
4330/// A 256-bit vector of [8 x i32] containing the mask. The most significant
4331/// bit of each element in the mask vector represents the mask bits. If a
4332/// mask bit is zero, the corresponding value from vector \a a is gathered;
4333/// otherwise the value is loaded from memory.
4334/// \param s
4335/// A literal constant scale factor for the indexes in \a i. Must be
4336/// 1, 2, 4, or 8.
4337/// \returns A 256-bit vector of [8 x i32] containing the gathered values.
4338#define _mm256_mask_i32gather_epi32(a, m, i, mask, s) \
4339 ((__m256i)__builtin_ia32_gatherd_d256((__v8si)(__m256i)(a), \
4340 (int const *)(m), \
4341 (__v8si)(__m256i)(i), \
4342 (__v8si)(__m256i)(mask), (s)))
4343
4344/// Conditionally gathers two 32-bit integer values, either from the
4345/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled
4346/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
4347/// of [4 x i32] in \a mask determines the source for the lower two
4348/// elements. The upper two elements of the result are zeroed.
4349///
4350/// \code{.operation}
4351/// FOR element := 0 to 1
4352/// j := element*32
4353/// k := element*64
4354/// IF mask[j+31] == 0
4355/// result[j+31:j] := a[j+31:j]
4356/// ELSE
4357/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4358/// FI
4359/// ENDFOR
4360/// result[127:64] := 0
4361/// \endcode
4362///
4363/// \headerfile <immintrin.h>
4364///
4365/// \code
4366/// __m128i _mm_mask_i64gather_epi32(__m128i a, const int *m, __m128i i,
4367/// __m128i mask, const int s);
4368/// \endcode
4369///
4370/// This intrinsic corresponds to the \c VPGATHERQD instruction.
4371///
4372/// \param a
4373/// A 128-bit vector of [4 x i32] used as the source when a mask bit is
4374/// zero. Only the first two elements are used.
4375/// \param m
4376/// A pointer to the memory used for loading values.
4377/// \param i
4378/// A 128-bit vector of [2 x i64] containing indexes into \a m.
4379/// \param mask
4380/// A 128-bit vector of [4 x i32] containing the mask. The most significant
4381/// bit of each element in the mask vector represents the mask bits. If a
4382/// mask bit is zero, the corresponding value from vector \a a is gathered;
4383/// otherwise the value is loaded from memory. Only the first two elements
4384/// are used.
4385/// \param s
4386/// A literal constant scale factor for the indexes in \a i. Must be
4387/// 1, 2, 4, or 8.
4388/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
4389#define _mm_mask_i64gather_epi32(a, m, i, mask, s) \
4390 ((__m128i)__builtin_ia32_gatherq_d((__v4si)(__m128i)(a), \
4391 (int const *)(m), \
4392 (__v2di)(__m128i)(i), \
4393 (__v4si)(__m128i)(mask), (s)))
4394
4395/// Conditionally gathers four 32-bit integer values, either from the
4396/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled
4397/// indexes from the 256-bit vector of [4 x i64] in \a i. The 128-bit vector
4398/// of [4 x i32] in \a mask determines the source for each element.
4399///
4400/// \code{.operation}
4401/// FOR element := 0 to 3
4402/// j := element*32
4403/// k := element*64
4404/// IF mask[j+31] == 0
4405/// result[j+31:j] := a[j+31:j]
4406/// ELSE
4407/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4408/// FI
4409/// ENDFOR
4410/// \endcode
4411///
4412/// \headerfile <immintrin.h>
4413///
4414/// \code
4415/// __m128i _mm256_mask_i64gather_epi32(__m128i a, const int *m, __m256i i,
4416/// __m128i mask, const int s);
4417/// \endcode
4418///
4419/// This intrinsic corresponds to the \c VPGATHERQD instruction.
4420///
4421/// \param a
4422/// A 128-bit vector of [4 x i32] used as the source when a mask bit is
4423/// zero.
4424/// \param m
4425/// A pointer to the memory used for loading values.
4426/// \param i
4427/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4428/// \param mask
4429/// A 128-bit vector of [4 x i32] containing the mask. The most significant
4430/// bit of each element in the mask vector represents the mask bits. If a
4431/// mask bit is zero, the corresponding value from vector \a a is gathered;
4432/// otherwise the value is loaded from memory.
4433/// \param s
4434/// A literal constant scale factor for the indexes in \a i. Must be
4435/// 1, 2, 4, or 8.
4436/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
4437#define _mm256_mask_i64gather_epi32(a, m, i, mask, s) \
4438 ((__m128i)__builtin_ia32_gatherq_d256((__v4si)(__m128i)(a), \
4439 (int const *)(m), \
4440 (__v4di)(__m256i)(i), \
4441 (__v4si)(__m128i)(mask), (s)))
4442
4443/// Conditionally gathers two 64-bit integer values, either from the
4444/// 128-bit vector of [2 x i64] in \a a, or from memory \a m using scaled
4445/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
4446/// of [2 x i64] in \a mask determines the source for each element.
4447///
4448/// \code{.operation}
4449/// FOR element := 0 to 1
4450/// j := element*64
4451/// k := element*32
4452/// IF mask[j+63] == 0
4453/// result[j+63:j] := a[j+63:j]
4454/// ELSE
4455/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
4456/// FI
4457/// ENDFOR
4458/// \endcode
4459///
4460/// \headerfile <immintrin.h>
4461///
4462/// \code
4463/// __m128i _mm_mask_i32gather_epi64(__m128i a, const long long *m, __m128i i,
4464/// __m128i mask, const int s);
4465/// \endcode
4466///
4467/// This intrinsic corresponds to the \c VPGATHERDQ instruction.
4468///
4469/// \param a
4470/// A 128-bit vector of [2 x i64] used as the source when a mask bit is
4471/// zero.
4472/// \param m
4473/// A pointer to the memory used for loading values.
4474/// \param i
4475/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
4476/// the first two elements are used.
4477/// \param mask
4478/// A 128-bit vector of [2 x i64] containing the mask. The most significant
4479/// bit of each element in the mask vector represents the mask bits. If a
4480/// mask bit is zero, the corresponding value from vector \a a is gathered;
4481/// otherwise the value is loaded from memory.
4482/// \param s
4483/// A literal constant scale factor for the indexes in \a i. Must be
4484/// 1, 2, 4, or 8.
4485/// \returns A 128-bit vector of [2 x i64] containing the gathered values.
4486#define _mm_mask_i32gather_epi64(a, m, i, mask, s) \
4487 ((__m128i)__builtin_ia32_gatherd_q((__v2di)(__m128i)(a), \
4488 (long long const *)(m), \
4489 (__v4si)(__m128i)(i), \
4490 (__v2di)(__m128i)(mask), (s)))
4491
4492/// Conditionally gathers four 64-bit integer values, either from the
4493/// 256-bit vector of [4 x i64] in \a a, or from memory \a m using scaled
4494/// indexes from the 128-bit vector of [4 x i32] in \a i. The 256-bit vector
4495/// of [4 x i64] in \a mask determines the source for each element.
4496///
4497/// \code{.operation}
4498/// FOR element := 0 to 3
4499/// j := element*64
4500/// k := element*32
4501/// IF mask[j+63] == 0
4502/// result[j+63:j] := a[j+63:j]
4503/// ELSE
4504/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
4505/// FI
4506/// ENDFOR
4507/// \endcode
4508///
4509/// \headerfile <immintrin.h>
4510///
4511/// \code
4512/// __m256i _mm256_mask_i32gather_epi64(__m256i a, const long long *m,
4513/// __m128i i, __m256i mask, const int s);
4514/// \endcode
4515///
4516/// This intrinsic corresponds to the \c VPGATHERDQ instruction.
4517///
4518/// \param a
4519/// A 256-bit vector of [4 x i64] used as the source when a mask bit is
4520/// zero.
4521/// \param m
4522/// A pointer to the memory used for loading values.
4523/// \param i
4524/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4525/// \param mask
4526/// A 256-bit vector of [4 x i64] containing the mask. The most significant
4527/// bit of each element in the mask vector represents the mask bits. If a
4528/// mask bit is zero, the corresponding value from vector \a a is gathered;
4529/// otherwise the value is loaded from memory.
4530/// \param s
4531/// A literal constant scale factor for the indexes in \a i. Must be
4532/// 1, 2, 4, or 8.
4533/// \returns A 256-bit vector of [4 x i64] containing the gathered values.
4534#define _mm256_mask_i32gather_epi64(a, m, i, mask, s) \
4535 ((__m256i)__builtin_ia32_gatherd_q256((__v4di)(__m256i)(a), \
4536 (long long const *)(m), \
4537 (__v4si)(__m128i)(i), \
4538 (__v4di)(__m256i)(mask), (s)))
4539
4540/// Conditionally gathers two 64-bit integer values, either from the
4541/// 128-bit vector of [2 x i64] in \a a, or from memory \a m using scaled
4542/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
4543/// of [2 x i64] in \a mask determines the source for each element.
4544///
4545/// \code{.operation}
4546/// FOR element := 0 to 1
4547/// j := element*64
4548/// k := element*64
4549/// IF mask[j+63] == 0
4550/// result[j+63:j] := a[j+63:j]
4551/// ELSE
4552/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4553/// FI
4554/// ENDFOR
4555/// \endcode
4556///
4557/// \headerfile <immintrin.h>
4558///
4559/// \code
4560/// __m128i _mm_mask_i64gather_epi64(__m128i a, const long long *m, __m128i i,
4561/// __m128i mask, const int s);
4562/// \endcode
4563///
4564/// This intrinsic corresponds to the \c VPGATHERQQ instruction.
4565///
4566/// \param a
4567/// A 128-bit vector of [2 x i64] used as the source when a mask bit is
4568/// zero.
4569/// \param m
4570/// A pointer to the memory used for loading values.
4571/// \param i
4572/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4573/// \param mask
4574/// A 128-bit vector of [2 x i64] containing the mask. The most significant
4575/// bit of each element in the mask vector represents the mask bits. If a
4576/// mask bit is zero, the corresponding value from vector \a a is gathered;
4577/// otherwise the value is loaded from memory.
4578/// \param s
4579/// A literal constant scale factor for the indexes in \a i. Must be
4580/// 1, 2, 4, or 8.
4581/// \returns A 128-bit vector of [2 x i64] containing the gathered values.
4582#define _mm_mask_i64gather_epi64(a, m, i, mask, s) \
4583 ((__m128i)__builtin_ia32_gatherq_q((__v2di)(__m128i)(a), \
4584 (long long const *)(m), \
4585 (__v2di)(__m128i)(i), \
4586 (__v2di)(__m128i)(mask), (s)))
4587
4588/// Conditionally gathers four 64-bit integer values, either from the
4589/// 256-bit vector of [4 x i64] in \a a, or from memory \a m using scaled
4590/// indexes from the 256-bit vector of [4 x i64] in \a i. The 256-bit vector
4591/// of [4 x i64] in \a mask determines the source for each element.
4592///
4593/// \code{.operation}
4594/// FOR element := 0 to 3
4595/// j := element*64
4596/// k := element*64
4597/// IF mask[j+63] == 0
4598/// result[j+63:j] := a[j+63:j]
4599/// ELSE
4600/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4601/// FI
4602/// ENDFOR
4603/// \endcode
4604///
4605/// \headerfile <immintrin.h>
4606///
4607/// \code
4608/// __m256i _mm256_mask_i64gather_epi64(__m256i a, const long long *m,
4609/// __m256i i, __m256i mask, const int s);
4610/// \endcode
4611///
4612/// This intrinsic corresponds to the \c VPGATHERQQ instruction.
4613///
4614/// \param a
4615/// A 256-bit vector of [4 x i64] used as the source when a mask bit is
4616/// zero.
4617/// \param m
4618/// A pointer to the memory used for loading values.
4619/// \param i
4620/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4621/// \param mask
4622/// A 256-bit vector of [4 x i64] containing the mask. The most significant
4623/// bit of each element in the mask vector represents the mask bits. If a
4624/// mask bit is zero, the corresponding value from vector \a a is gathered;
4625/// otherwise the value is loaded from memory.
4626/// \param s
4627/// A literal constant scale factor for the indexes in \a i. Must be
4628/// 1, 2, 4, or 8.
4629/// \returns A 256-bit vector of [4 x i64] containing the gathered values.
4630#define _mm256_mask_i64gather_epi64(a, m, i, mask, s) \
4631 ((__m256i)__builtin_ia32_gatherq_q256((__v4di)(__m256i)(a), \
4632 (long long const *)(m), \
4633 (__v4di)(__m256i)(i), \
4634 (__v4di)(__m256i)(mask), (s)))
4635
4636/// Gathers two 64-bit floating-point values from memory \a m using scaled
4637/// indexes from the 128-bit vector of [4 x i32] in \a i.
4638///
4639/// \code{.operation}
4640/// FOR element := 0 to 1
4641/// j := element*64
4642/// k := element*32
4643/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
4644/// ENDFOR
4645/// \endcode
4646///
4647/// \headerfile <immintrin.h>
4648///
4649/// \code
4650/// __m128d _mm_i32gather_pd(const double *m, __m128i i, const int s);
4651/// \endcode
4652///
4653/// This intrinsic corresponds to the \c VGATHERDPD instruction.
4654///
4655/// \param m
4656/// A pointer to the memory used for loading values.
4657/// \param i
4658/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
4659/// the first two elements are used.
4660/// \param s
4661/// A literal constant scale factor for the indexes in \a i. Must be
4662/// 1, 2, 4, or 8.
4663/// \returns A 128-bit vector of [2 x double] containing the gathered values.
4664#define _mm_i32gather_pd(m, i, s) \
4665 ((__m128d)__builtin_ia32_gatherd_pd((__v2df)_mm_undefined_pd(), \
4666 (double const *)(m), \
4667 (__v4si)(__m128i)(i), \
4668 (__v2df)_mm_cmpeq_pd(_mm_setzero_pd(), \
4669 _mm_setzero_pd()), \
4670 (s)))
4671
4672/// Gathers four 64-bit floating-point values from memory \a m using scaled
4673/// indexes from the 128-bit vector of [4 x i32] in \a i.
4674///
4675/// \code{.operation}
4676/// FOR element := 0 to 3
4677/// j := element*64
4678/// k := element*32
4679/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
4680/// ENDFOR
4681/// \endcode
4682///
4683/// \headerfile <immintrin.h>
4684///
4685/// \code
4686/// __m256d _mm256_i32gather_pd(const double *m, __m128i i, const int s);
4687/// \endcode
4688///
4689/// This intrinsic corresponds to the \c VGATHERDPD instruction.
4690///
4691/// \param m
4692/// A pointer to the memory used for loading values.
4693/// \param i
4694/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4695/// \param s
4696/// A literal constant scale factor for the indexes in \a i. Must be
4697/// 1, 2, 4, or 8.
4698/// \returns A 256-bit vector of [4 x double] containing the gathered values.
4699#define _mm256_i32gather_pd(m, i, s) \
4700 ((__m256d)__builtin_ia32_gatherd_pd256((__v4df)_mm256_undefined_pd(), \
4701 (double const *)(m), \
4702 (__v4si)(__m128i)(i), \
4703 (__v4df)_mm256_cmp_pd(_mm256_setzero_pd(), \
4704 _mm256_setzero_pd(), \
4705 _CMP_EQ_OQ), \
4706 (s)))
4707
4708/// Gathers two 64-bit floating-point values from memory \a m using scaled
4709/// indexes from the 128-bit vector of [2 x i64] in \a i.
4710///
4711/// \code{.operation}
4712/// FOR element := 0 to 1
4713/// j := element*64
4714/// k := element*64
4715/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4716/// ENDFOR
4717/// \endcode
4718///
4719/// \headerfile <immintrin.h>
4720///
4721/// \code
4722/// __m128d _mm_i64gather_pd(const double *m, __m128i i, const int s);
4723/// \endcode
4724///
4725/// This intrinsic corresponds to the \c VGATHERQPD instruction.
4726///
4727/// \param m
4728/// A pointer to the memory used for loading values.
4729/// \param i
4730/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4731/// \param s
4732/// A literal constant scale factor for the indexes in \a i. Must be
4733/// 1, 2, 4, or 8.
4734/// \returns A 128-bit vector of [2 x double] containing the gathered values.
4735#define _mm_i64gather_pd(m, i, s) \
4736 ((__m128d)__builtin_ia32_gatherq_pd((__v2df)_mm_undefined_pd(), \
4737 (double const *)(m), \
4738 (__v2di)(__m128i)(i), \
4739 (__v2df)_mm_cmpeq_pd(_mm_setzero_pd(), \
4740 _mm_setzero_pd()), \
4741 (s)))
4742
4743/// Gathers four 64-bit floating-point values from memory \a m using scaled
4744/// indexes from the 256-bit vector of [4 x i64] in \a i.
4745///
4746/// \code{.operation}
4747/// FOR element := 0 to 3
4748/// j := element*64
4749/// k := element*64
4750/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
4751/// ENDFOR
4752/// \endcode
4753///
4754/// \headerfile <immintrin.h>
4755///
4756/// \code
4757/// __m256d _mm256_i64gather_pd(const double *m, __m256i i, const int s);
4758/// \endcode
4759///
4760/// This intrinsic corresponds to the \c VGATHERQPD instruction.
4761///
4762/// \param m
4763/// A pointer to the memory used for loading values.
4764/// \param i
4765/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4766/// \param s
4767/// A literal constant scale factor for the indexes in \a i. Must be
4768/// 1, 2, 4, or 8.
4769/// \returns A 256-bit vector of [4 x double] containing the gathered values.
4770#define _mm256_i64gather_pd(m, i, s) \
4771 ((__m256d)__builtin_ia32_gatherq_pd256((__v4df)_mm256_undefined_pd(), \
4772 (double const *)(m), \
4773 (__v4di)(__m256i)(i), \
4774 (__v4df)_mm256_cmp_pd(_mm256_setzero_pd(), \
4775 _mm256_setzero_pd(), \
4776 _CMP_EQ_OQ), \
4777 (s)))
4778
4779/// Gathers four 32-bit floating-point values from memory \a m using scaled
4780/// indexes from the 128-bit vector of [4 x i32] in \a i.
4781///
4782/// \code{.operation}
4783/// FOR element := 0 to 3
4784/// j := element*32
4785/// k := element*32
4786/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4787/// ENDFOR
4788/// \endcode
4789///
4790/// \headerfile <immintrin.h>
4791///
4792/// \code
4793/// __m128 _mm_i32gather_ps(const float *m, __m128i i, const int s);
4794/// \endcode
4795///
4796/// This intrinsic corresponds to the \c VGATHERDPS instruction.
4797///
4798/// \param m
4799/// A pointer to the memory used for loading values.
4800/// \param i
4801/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4802/// \param s
4803/// A literal constant scale factor for the indexes in \a i. Must be
4804/// 1, 2, 4, or 8.
4805/// \returns A 128-bit vector of [4 x float] containing the gathered values.
4806#define _mm_i32gather_ps(m, i, s) \
4807 ((__m128)__builtin_ia32_gatherd_ps((__v4sf)_mm_undefined_ps(), \
4808 (float const *)(m), \
4809 (__v4si)(__m128i)(i), \
4810 (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \
4811 _mm_setzero_ps()), \
4812 (s)))
4813
4814/// Gathers eight 32-bit floating-point values from memory \a m using scaled
4815/// indexes from the 256-bit vector of [8 x i32] in \a i.
4816///
4817/// \code{.operation}
4818/// FOR element := 0 to 7
4819/// j := element*32
4820/// k := element*32
4821/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4822/// ENDFOR
4823/// \endcode
4824///
4825/// \headerfile <immintrin.h>
4826///
4827/// \code
4828/// __m256 _mm256_i32gather_ps(const float *m, __m256i i, const int s);
4829/// \endcode
4830///
4831/// This intrinsic corresponds to the \c VGATHERDPS instruction.
4832///
4833/// \param m
4834/// A pointer to the memory used for loading values.
4835/// \param i
4836/// A 256-bit vector of [8 x i32] containing signed indexes into \a m.
4837/// \param s
4838/// A literal constant scale factor for the indexes in \a i. Must be
4839/// 1, 2, 4, or 8.
4840/// \returns A 256-bit vector of [8 x float] containing the gathered values.
4841#define _mm256_i32gather_ps(m, i, s) \
4842 ((__m256)__builtin_ia32_gatherd_ps256((__v8sf)_mm256_undefined_ps(), \
4843 (float const *)(m), \
4844 (__v8si)(__m256i)(i), \
4845 (__v8sf)_mm256_cmp_ps(_mm256_setzero_ps(), \
4846 _mm256_setzero_ps(), \
4847 _CMP_EQ_OQ), \
4848 (s)))
4849
4850/// Gathers two 32-bit floating-point values from memory \a m using scaled
4851/// indexes from the 128-bit vector of [2 x i64] in \a i. The upper two
4852/// elements of the result are zeroed.
4853///
4854/// \code{.operation}
4855/// FOR element := 0 to 1
4856/// j := element*32
4857/// k := element*64
4858/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4859/// ENDFOR
4860/// result[127:64] := 0
4861/// \endcode
4862///
4863/// \headerfile <immintrin.h>
4864///
4865/// \code
4866/// __m128 _mm_i64gather_ps(const float *m, __m128i i, const int s);
4867/// \endcode
4868///
4869/// This intrinsic corresponds to the \c VGATHERQPS instruction.
4870///
4871/// \param m
4872/// A pointer to the memory used for loading values.
4873/// \param i
4874/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
4875/// \param s
4876/// A literal constant scale factor for the indexes in \a i. Must be
4877/// 1, 2, 4, or 8.
4878/// \returns A 128-bit vector of [4 x float] containing the gathered values.
4879#define _mm_i64gather_ps(m, i, s) \
4880 ((__m128)__builtin_ia32_gatherq_ps((__v4sf)_mm_undefined_ps(), \
4881 (float const *)(m), \
4882 (__v2di)(__m128i)(i), \
4883 (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \
4884 _mm_setzero_ps()), \
4885 (s)))
4886
4887/// Gathers four 32-bit floating-point values from memory \a m using scaled
4888/// indexes from the 256-bit vector of [4 x i64] in \a i.
4889///
4890/// \code{.operation}
4891/// FOR element := 0 to 3
4892/// j := element*32
4893/// k := element*64
4894/// result[j+31:j] := Load32(m + SignExtend(i[k+64:k])*s)
4895/// ENDFOR
4896/// \endcode
4897///
4898/// \headerfile <immintrin.h>
4899///
4900/// \code
4901/// __m128 _mm256_i64gather_ps(const float *m, __m256i i, const int s);
4902/// \endcode
4903///
4904/// This intrinsic corresponds to the \c VGATHERQPS instruction.
4905///
4906/// \param m
4907/// A pointer to the memory used for loading values.
4908/// \param i
4909/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
4910/// \param s
4911/// A literal constant scale factor for the indexes in \a i. Must be
4912/// 1, 2, 4, or 8.
4913/// \returns A 128-bit vector of [4 x float] containing the gathered values.
4914#define _mm256_i64gather_ps(m, i, s) \
4915 ((__m128)__builtin_ia32_gatherq_ps256((__v4sf)_mm_undefined_ps(), \
4916 (float const *)(m), \
4917 (__v4di)(__m256i)(i), \
4918 (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \
4919 _mm_setzero_ps()), \
4920 (s)))
4921
4922/// Gathers four 32-bit floating-point values from memory \a m using scaled
4923/// indexes from the 128-bit vector of [4 x i32] in \a i.
4924///
4925/// \code{.operation}
4926/// FOR element := 0 to 3
4927/// j := element*32
4928/// k := element*32
4929/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4930/// ENDFOR
4931/// \endcode
4932///
4933/// \headerfile <immintrin.h>
4934///
4935/// \code
4936/// __m128i _mm_i32gather_epi32(const int *m, __m128i i, const int s);
4937/// \endcode
4938///
4939/// This intrinsic corresponds to the \c VPGATHERDD instruction.
4940///
4941/// \param m
4942/// A pointer to the memory used for loading values.
4943/// \param i
4944/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
4945/// \param s
4946/// A literal constant scale factor for the indexes in \a i. Must be
4947/// 1, 2, 4, or 8.
4948/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
4949#define _mm_i32gather_epi32(m, i, s) \
4950 ((__m128i)__builtin_ia32_gatherd_d((__v4si)_mm_undefined_si128(), \
4951 (int const *)(m), (__v4si)(__m128i)(i), \
4952 (__v4si)_mm_set1_epi32(-1), (s)))
4953
4954/// Gathers eight 32-bit floating-point values from memory \a m using scaled
4955/// indexes from the 256-bit vector of [8 x i32] in \a i.
4956///
4957/// \code{.operation}
4958/// FOR element := 0 to 7
4959/// j := element*32
4960/// k := element*32
4961/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s)
4962/// ENDFOR
4963/// \endcode
4964///
4965/// \headerfile <immintrin.h>
4966///
4967/// \code
4968/// __m256i _mm256_i32gather_epi32(const int *m, __m256i i, const int s);
4969/// \endcode
4970///
4971/// This intrinsic corresponds to the \c VPGATHERDD instruction.
4972///
4973/// \param m
4974/// A pointer to the memory used for loading values.
4975/// \param i
4976/// A 256-bit vector of [8 x i32] containing signed indexes into \a m.
4977/// \param s
4978/// A literal constant scale factor for the indexes in \a i. Must be
4979/// 1, 2, 4, or 8.
4980/// \returns A 256-bit vector of [8 x i32] containing the gathered values.
4981#define _mm256_i32gather_epi32(m, i, s) \
4982 ((__m256i)__builtin_ia32_gatherd_d256((__v8si)_mm256_undefined_si256(), \
4983 (int const *)(m), (__v8si)(__m256i)(i), \
4984 (__v8si)_mm256_set1_epi32(-1), (s)))
4985
4986/// Gathers two 32-bit integer values from memory \a m using scaled indexes
4987/// from the 128-bit vector of [2 x i64] in \a i. The upper two elements
4988/// of the result are zeroed.
4989///
4990/// \code{.operation}
4991/// FOR element := 0 to 1
4992/// j := element*32
4993/// k := element*64
4994/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
4995/// ENDFOR
4996/// result[127:64] := 0
4997/// \endcode
4998///
4999/// \headerfile <immintrin.h>
5000///
5001/// \code
5002/// __m128i _mm_i64gather_epi32(const int *m, __m128i i, const int s);
5003/// \endcode
5004///
5005/// This intrinsic corresponds to the \c VPGATHERQD instruction.
5006///
5007/// \param m
5008/// A pointer to the memory used for loading values.
5009/// \param i
5010/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
5011/// \param s
5012/// A literal constant scale factor for the indexes in \a i. Must be
5013/// 1, 2, 4, or 8.
5014/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
5015#define _mm_i64gather_epi32(m, i, s) \
5016 ((__m128i)__builtin_ia32_gatherq_d((__v4si)_mm_undefined_si128(), \
5017 (int const *)(m), (__v2di)(__m128i)(i), \
5018 (__v4si)_mm_set1_epi32(-1), (s)))
5019
5020/// Gathers four 32-bit integer values from memory \a m using scaled indexes
5021/// from the 256-bit vector of [4 x i64] in \a i.
5022///
5023/// \code{.operation}
5024/// FOR element := 0 to 3
5025/// j := element*32
5026/// k := element*64
5027/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s)
5028/// ENDFOR
5029/// \endcode
5030///
5031/// \headerfile <immintrin.h>
5032///
5033/// \code
5034/// __m128i _mm256_i64gather_epi32(const int *m, __m256i i, const int s);
5035/// \endcode
5036///
5037/// This intrinsic corresponds to the \c VPGATHERQD instruction.
5038///
5039/// \param m
5040/// A pointer to the memory used for loading values.
5041/// \param i
5042/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
5043/// \param s
5044/// A literal constant scale factor for the indexes in \a i. Must be
5045/// 1, 2, 4, or 8.
5046/// \returns A 128-bit vector of [4 x i32] containing the gathered values.
5047#define _mm256_i64gather_epi32(m, i, s) \
5048 ((__m128i)__builtin_ia32_gatherq_d256((__v4si)_mm_undefined_si128(), \
5049 (int const *)(m), (__v4di)(__m256i)(i), \
5050 (__v4si)_mm_set1_epi32(-1), (s)))
5051
5052/// Gathers two 64-bit integer values from memory \a m using scaled indexes
5053/// from the 128-bit vector of [4 x i32] in \a i.
5054///
5055/// \code{.operation}
5056/// FOR element := 0 to 1
5057/// j := element*64
5058/// k := element*32
5059/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
5060/// ENDFOR
5061/// \endcode
5062///
5063/// \headerfile <immintrin.h>
5064///
5065/// \code
5066/// __m128i _mm_i32gather_epi64(const long long *m, __m128i i, const int s);
5067/// \endcode
5068///
5069/// This intrinsic corresponds to the \c VPGATHERDQ instruction.
5070///
5071/// \param m
5072/// A pointer to the memory used for loading values.
5073/// \param i
5074/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
5075/// the first two elements are used.
5076/// \param s
5077/// A literal constant scale factor for the indexes in \a i. Must be
5078/// 1, 2, 4, or 8.
5079/// \returns A 128-bit vector of [2 x i64] containing the gathered values.
5080#define _mm_i32gather_epi64(m, i, s) \
5081 ((__m128i)__builtin_ia32_gatherd_q((__v2di)_mm_undefined_si128(), \
5082 (long long const *)(m), \
5083 (__v4si)(__m128i)(i), \
5084 (__v2di)_mm_set1_epi64x(-1), (s)))
5085
5086/// Gathers four 64-bit integer values from memory \a m using scaled indexes
5087/// from the 128-bit vector of [4 x i32] in \a i.
5088///
5089/// \code{.operation}
5090/// FOR element := 0 to 3
5091/// j := element*64
5092/// k := element*32
5093/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
5094/// ENDFOR
5095/// \endcode
5096///
5097/// \headerfile <immintrin.h>
5098///
5099/// \code
5100/// __m256i _mm256_i32gather_epi64(const long long *m, __m128i i, const int s);
5101/// \endcode
5102///
5103/// This intrinsic corresponds to the \c VPGATHERDQ instruction.
5104///
5105/// \param m
5106/// A pointer to the memory used for loading values.
5107/// \param i
5108/// A 128-bit vector of [4 x i32] containing signed indexes into \a m.
5109/// \param s
5110/// A literal constant scale factor for the indexes in \a i. Must be
5111/// 1, 2, 4, or 8.
5112/// \returns A 256-bit vector of [4 x i64] containing the gathered values.
5113#define _mm256_i32gather_epi64(m, i, s) \
5114 ((__m256i)__builtin_ia32_gatherd_q256((__v4di)_mm256_undefined_si256(), \
5115 (long long const *)(m), \
5116 (__v4si)(__m128i)(i), \
5117 (__v4di)_mm256_set1_epi64x(-1), (s)))
5118
5119/// Gathers two 64-bit integer values from memory \a m using scaled indexes
5120/// from the 128-bit vector of [2 x i64] in \a i.
5121///
5122/// \code{.operation}
5123/// FOR element := 0 to 1
5124/// j := element*64
5125/// k := element*64
5126/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
5127/// ENDFOR
5128/// \endcode
5129///
5130/// \headerfile <immintrin.h>
5131///
5132/// \code
5133/// __m128i _mm_i64gather_epi64(const long long *m, __m128i i, const int s);
5134/// \endcode
5135///
5136/// This intrinsic corresponds to the \c VPGATHERQQ instruction.
5137///
5138/// \param m
5139/// A pointer to the memory used for loading values.
5140/// \param i
5141/// A 128-bit vector of [2 x i64] containing signed indexes into \a m.
5142/// \param s
5143/// A literal constant scale factor for the indexes in \a i. Must be
5144/// 1, 2, 4, or 8.
5145/// \returns A 128-bit vector of [2 x i64] containing the gathered values.
5146#define _mm_i64gather_epi64(m, i, s) \
5147 ((__m128i)__builtin_ia32_gatherq_q((__v2di)_mm_undefined_si128(), \
5148 (long long const *)(m), \
5149 (__v2di)(__m128i)(i), \
5150 (__v2di)_mm_set1_epi64x(-1), (s)))
5151
5152/// Gathers four 64-bit integer values from memory \a m using scaled indexes
5153/// from the 256-bit vector of [4 x i64] in \a i.
5154///
5155/// \code{.operation}
5156/// FOR element := 0 to 3
5157/// j := element*64
5158/// k := element*64
5159/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s)
5160/// ENDFOR
5161/// \endcode
5162///
5163/// \headerfile <immintrin.h>
5164///
5165/// \code
5166/// __m256i _mm256_i64gather_epi64(const long long *m, __m256i i, const int s);
5167/// \endcode
5168///
5169/// This intrinsic corresponds to the \c VPGATHERQQ instruction.
5170///
5171/// \param m
5172/// A pointer to the memory used for loading values.
5173/// \param i
5174/// A 256-bit vector of [4 x i64] containing signed indexes into \a m.
5175/// \param s
5176/// A literal constant scale factor for the indexes in \a i. Must be
5177/// 1, 2, 4, or 8.
5178/// \returns A 256-bit vector of [4 x i64] containing the gathered values.
5179#define _mm256_i64gather_epi64(m, i, s) \
5180 ((__m256i)__builtin_ia32_gatherq_q256((__v4di)_mm256_undefined_si256(), \
5181 (long long const *)(m), \
5182 (__v4di)(__m256i)(i), \
5183 (__v4di)_mm256_set1_epi64x(-1), (s)))
5184
5185#undef __DEFAULT_FN_ATTRS256
5186#undef __DEFAULT_FN_ATTRS128
5187#undef __DEFAULT_FN_ATTRS256_CONSTEXPR
5188#undef __DEFAULT_FN_ATTRS128_CONSTEXPR
5189
5190#endif /* __AVX2INTRIN_H */
_Float16 __2f16 __attribute__((ext_vector_type(2)))
Zeroes the upper 128 bits (bits 255:128) of all YMM registers.
static __inline__ vector float vector float __b
Definition altivec.h:578
#define __DEFAULT_FN_ATTRS128
#define __DEFAULT_FN_ATTRS256
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sllv_epi32(__m256i __X, __m256i __Y)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __X left by the number of bits given...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepi32_epi64(__m128i __V)
Sign-extends 32-bit elements from the 128-bit vector of [4 x i32] in __V and returns the 64-bit value...
static __inline__ int __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_movemask_epi8(__m256i __a)
Creates a 32-bit integer mask from the most significant bit of each byte in the 256-bit integer vecto...
static __inline__ void __DEFAULT_FN_ATTRS256 _mm256_maskstore_epi64(long long *__X, __m256i __M, __m256i __Y)
Conditionally stores four 64-bit integer elements from the 256-bit vector of [4 x i64] in __Y to memo...
static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_stream_load_si256(const void *__V)
Loads the 256-bit integer vector from memory __V using a non-temporal memory hint and returns the vec...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_hsubs_epi16(__m256i __a, __m256i __b)
Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit vectors of [16 x i16] using...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cmpgt_epi8(__m256i __a, __m256i __b)
Compares corresponding signed bytes in the 256-bit integer vectors in __a and __b for greater-than an...
Definition avx2intrin.h:722
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_max_epi32(__m256i __a, __m256i __b)
Compares the corresponding signed 32-bit integers in the two 256-bit vectors of [8 x i32] in __a and ...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_mul_epu32(__m256i __a, __m256i __b)
Multiplies unsigned 32-bit integers from even-numered elements of two 256-bit vectors of [8 x i32] an...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_max_epu16(__m256i __a, __m256i __b)
Compares the corresponding unsigned 16-bit integers in the two 256-bit vectors of [16 x i16] in __a a...
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_srav_epi32(__m128i __X, __m128i __Y)
Shifts each 32-bit element of the 128-bit vector of [4 x i32] in __X right by the number of bits give...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_unpackhi_epi32(__m256i __a, __m256i __b)
Unpacks and interleaves 32-bit integers from parts of the 256-bit vectors of [8 x i32] in __a and __b...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_andnot_si256(__m256i __a, __m256i __b)
Computes the bitwise AND of the 256-bit integer vector in __b with the bitwise NOT of the 256-bit int...
Definition avx2intrin.h:466
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_mulhi_epi16(__m256i __a, __m256i __b)
Multiplies signed 16-bit integer elements of two 256-bit vectors of [16 x i16], and returns the upper...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_adds_epu8(__m256i __a, __m256i __b)
Adds 8-bit integers from corresponding bytes of two 256-bit integer vectors using unsigned saturation...
Definition avx2intrin.h:386
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_maddubs_epi16(__m256i __a, __m256i __b)
Multiplies each unsigned byte from the 256-bit integer vector in __a with the corresponding signed by...
static __inline__ __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_permutevar8x32_ps(__m256 __a, __m256i __b)
Sets the result's 256-bit vector of [8 x float] to copies of elements of the 256-bit vector of [8 x f...
static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskload_epi64(long long const *__X, __m256i __M)
Conditionally loads four 64-bit integer elements from memory __X, if the most significant bit of the ...
static __inline__ void __DEFAULT_FN_ATTRS256 _mm256_maskstore_epi32(int *__X, __m256i __M, __m256i __Y)
Conditionally stores eight 32-bit integer elements from the 256-bit vector of [8 x i32] in __Y to mem...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_mulhi_epu16(__m256i __a, __m256i __b)
Multiplies unsigned 16-bit integer elements of two 256-bit vectors of [16 x i16], and returns the upp...
#define __DEFAULT_FN_ATTRS128_CONSTEXPR
Definition avx2intrin.h:30
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_broadcastb_epi8(__m128i __X)
Broadcasts the low byte from the 128-bit integer vector in __X to all bytes of the 128-bit result.
static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_broadcastsd_pd(__m128d __a)
Broadcasts the 64-bit floating-point value from the low element of the 128-bit vector of [2 x double]...
static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskload_epi32(int const *__X, __m256i __M)
Conditionally loads eight 32-bit integer elements from memory __X, if the most significant bit of the...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepu8_epi16(__m128i __V)
Zero-extends bytes from the 128-bit integer vector in __V and returns the 16-bit values in the corres...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_subs_epu16(__m256i __a, __m256i __b)
Subtracts 16-bit integers from corresponding elements of two 256-bit vectors of [16 x i16] using unsi...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_packus_epi32(__m256i __V1, __m256i __V2)
Converts elements from two 256-bit vectors of [8 x i32] to 16-bit integers using unsigned saturation,...
Definition avx2intrin.h:261
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_broadcastb_epi8(__m128i __X)
Broadcasts the low byte from the 128-bit integer vector in __X to all bytes of the 256-bit result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sra_epi32(__m256i __a, __m128i __count)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __a right by the number of bits give...
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_broadcastq_epi64(__m128i __X)
Broadcasts the low element from the 128-bit vector of [2 x i64] in __X to both elements of the result...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_slli_epi64(__m256i __a, int __count)
Shifts each 64-bit element of the 256-bit vector of [4 x i64] in __a left by __count bits,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sll_epi32(__m256i __a, __m128i __count)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __a left by the number of bits given...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_unpacklo_epi16(__m256i __a, __m256i __b)
Unpacks and interleaves 16-bit integers from parts of the 256-bit vectors of [16 x i16] in __a and __...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_abs_epi32(__m256i __a)
Computes the absolute value of each signed 32-bit element in the 256-bit vector of [8 x i32] in __a a...
Definition avx2intrin.h:139
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sll_epi64(__m256i __a, __m128i __count)
Shifts each 64-bit element of the 256-bit vector of [4 x i64] in __a left by the number of bits given...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srav_epi32(__m256i __X, __m256i __Y)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __X right by the number of bits give...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_mullo_epi16(__m256i __a, __m256i __b)
Multiplies signed 16-bit integer elements of two 256-bit vectors of [16 x i16], and returns the lower...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepu8_epi64(__m128i __V)
Zero-extends the first four bytes from the 128-bit integer vector in __V and returns the 64-bit value...
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_broadcastw_epi16(__m128i __X)
Broadcasts the low element from the 128-bit vector of [8 x i16] in __X to all elements of the result'...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cmpeq_epi32(__m256i __a, __m256i __b)
Compares corresponding elements in the 256-bit vectors of [8 x i32] in __a and __b for equality and r...
Definition avx2intrin.h:670
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_adds_epi16(__m256i __a, __m256i __b)
Adds 16-bit integers from corresponding elements of two 256-bit vectors of [16 x i16] using signed sa...
Definition avx2intrin.h:368
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_min_epi8(__m256i __a, __m256i __b)
Compares the corresponding signed bytes in the two 256-bit integer vectors in __a and __b and returns...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sign_epi32(__m256i __a, __m256i __b)
Sets each element of the result to the corresponding element of the 256-bit vector of [8 x i32] in __...
static __inline__ void __DEFAULT_FN_ATTRS128 _mm_maskstore_epi64(long long *__X, __m128i __M, __m128i __Y)
Conditionally stores two 64-bit integer elements from the 128-bit vector of [2 x i64] in __Y to memor...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepu32_epi64(__m128i __V)
Zero-extends 32-bit elements from the 128-bit vector of [4 x i32] in __V and returns the 64-bit value...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepu8_epi32(__m128i __V)
Zero-extends bytes from the lower half of the 128-bit integer vector in __V and returns the 32-bit va...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srli_epi16(__m256i __a, int __count)
Shifts each 16-bit element of the 256-bit vector of [16 x i16] in __a right by __count bits,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_max_epi16(__m256i __a, __m256i __b)
Compares the corresponding signed 16-bit integers in the two 256-bit vectors of [16 x i16] in __a and...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_shuffle_epi8(__m256i __a, __m256i __b)
Shuffles 8-bit integers in the 256-bit integer vector __a according to control information in the 256...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepi8_epi16(__m128i __V)
Sign-extends bytes from the 128-bit integer vector in __V and returns the 16-bit values in the corres...
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_srlv_epi32(__m128i __X, __m128i __Y)
Shifts each 32-bit element of the 128-bit vector of [4 x i32] in __X right by the number of bits give...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M)
Merges 8-bit integer values from either of the two 256-bit vectors __V1 or __V2, as specified by the ...
Definition avx2intrin.h:551
static __inline__ __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_broadcastss_ps(__m128 __X)
Broadcasts the 32-bit floating-point value from the low element of the 128-bit vector of [4 x float] ...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cmpeq_epi64(__m256i __a, __m256i __b)
Compares corresponding elements in the 256-bit vectors of [4 x i64] in __a and __b for equality and r...
Definition avx2intrin.h:696
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_unpacklo_epi8(__m256i __a, __m256i __b)
Unpacks and interleaves 8-bit integers from parts of the 256-bit integer vectors in __a and __b to fo...
static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_maskload_epi32(int const *__X, __m128i __M)
Conditionally loads four 32-bit integer elements from memory __X, if the most significant bit of the ...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srli_epi64(__m256i __a, int __count)
Shifts each 64-bit element of the 256-bit vector of [4 x i64] in __a right by __count bits,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srl_epi16(__m256i __a, __m128i __count)
Shifts each 16-bit element of the 256-bit vector of [16 x i16] in __a right by the number of bits giv...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_hsub_epi16(__m256i __a, __m256i __b)
Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit vectors of [16 x i16] and r...
Definition avx2intrin.h:938
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_broadcastw_epi16(__m128i __X)
Broadcasts the low element from the 128-bit vector of [8 x i16] in __X to all elements of the result'...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_unpacklo_epi64(__m256i __a, __m256i __b)
Unpacks and interleaves 64-bit integers from parts of the 256-bit vectors of [4 x i64] in __a and __b...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srl_epi64(__m256i __a, __m128i __count)
Shifts each 64-bit element of the 256-bit vector of [4 x i64] in __a right by the number of bits give...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cmpgt_epi16(__m256i __a, __m256i __b)
Compares corresponding signed elements in the 256-bit vectors of [16 x i16] in __a and __b for greate...
Definition avx2intrin.h:750
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_hsub_epi32(__m256i __a, __m256i __b)
Horizontally subtracts adjacent pairs of 32-bit integers from two 256-bit vectors of [8 x i32] and re...
Definition avx2intrin.h:969
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srai_epi16(__m256i __a, int __count)
Shifts each 16-bit element of the 256-bit vector of [16 x i16] in __a right by __count bits,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_add_epi8(__m256i __a, __m256i __b)
Adds 8-bit integers from corresponding bytes of two 256-bit integer vectors and returns the lower 8 b...
Definition avx2intrin.h:279
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepi8_epi32(__m128i __V)
Sign-extends bytes from the lower half of the 128-bit integer vector in __V and returns the 32-bit va...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_broadcastq_epi64(__m128i __X)
Broadcasts the low element from the 128-bit vector of [2 x i64] in __X to all elements of the result'...
#define __DEFAULT_FN_ATTRS256_CONSTEXPR
Definition avx2intrin.h:29
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_mul_epi32(__m256i __a, __m256i __b)
Multiplies signed 32-bit integers from even-numbered elements of two 256-bit vectors of [8 x i32] and...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_min_epu16(__m256i __a, __m256i __b)
Compares the corresponding unsigned 16-bit integers in the two 256-bit vectors of [16 x i16] in __a a...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_hadd_epi32(__m256i __a, __m256i __b)
Horizontally adds the adjacent pairs of 32-bit integers from two 256-bit vectors of [8 x i32] and ret...
Definition avx2intrin.h:869
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_mullo_epi32(__m256i __a, __m256i __b)
Multiplies signed 32-bit integer elements of two 256-bit vectors of [8 x i32], and returns the lower ...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_min_epi32(__m256i __a, __m256i __b)
Compares the corresponding signed 32-bit integers in the two 256-bit vectors of [8 x i32] in __a and ...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sll_epi16(__m256i __a, __m128i __count)
Shifts each 16-bit element of the 256-bit vector of [16 x i16] in __a left by the number of bits spec...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cmpgt_epi32(__m256i __a, __m256i __b)
Compares corresponding signed elements in the 256-bit vectors of [8 x i32] in __a and __b for greater...
Definition avx2intrin.h:776
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sub_epi32(__m256i __a, __m256i __b)
Subtracts 32-bit integers from corresponding elements of two 256-bit vectors of [8 x i32].
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_unpackhi_epi64(__m256i __a, __m256i __b)
Unpacks and interleaves 64-bit integers from parts of the 256-bit vectors of [4 x i64] in __a and __b...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_subs_epu8(__m256i __a, __m256i __b)
Subtracts 8-bit integers from corresponding bytes of two 256-bit integer vectors using unsigned satur...
static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_broadcastss_ps(__m128 __X)
Broadcasts the 32-bit floating-point value from the low element of the 128-bit vector of [4 x float] ...
static __inline__ void __DEFAULT_FN_ATTRS128 _mm_maskstore_epi32(int *__X, __m128i __M, __m128i __Y)
Conditionally stores four 32-bit integer elements from the 128-bit vector of [4 x i32] in __Y to memo...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_subs_epi16(__m256i __a, __m256i __b)
Subtracts 16-bit integers from corresponding elements of two 256-bit vectors of [16 x i16] using sign...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cmpeq_epi8(__m256i __a, __m256i __b)
Compares corresponding bytes in the 256-bit integer vectors in __a and __b for equality and returns t...
Definition avx2intrin.h:618
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_srlv_epi64(__m128i __X, __m128i __Y)
Shifts each 64-bit element of the 128-bit vector of [2 x i64] in __X right by the number of bits give...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sign_epi16(__m256i __a, __m256i __b)
Sets each element of the result to the corresponding element of the 256-bit vector of [16 x i16] in _...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srlv_epi32(__m256i __X, __m256i __Y)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __X right by the number of bits give...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_abs_epi8(__m256i __a)
Computes the absolute value of each signed byte in the 256-bit integer vector __a and returns each va...
Definition avx2intrin.h:107
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepu16_epi64(__m128i __V)
Zero-extends 16-bit elements from the lower half of the 128-bit vector of [8 x i16] in __V and return...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_unpacklo_epi32(__m256i __a, __m256i __b)
Unpacks and interleaves 32-bit integers from parts of the 256-bit vectors of [8 x i32] in __a and __b...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_permutevar8x32_epi32(__m256i __a, __m256i __b)
Sets the result's 256-bit vector of [8 x i32] to copies of elements of the 256-bit vector of [8 x i32...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepi8_epi64(__m128i __V)
Sign-extends the first four bytes from the 128-bit integer vector in __V and returns the 64-bit value...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_hadds_epi16(__m256i __a, __m256i __b)
Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit vectors of [16 x i16] using ...
Definition avx2intrin.h:903
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srli_epi32(__m256i __a, int __count)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __a right by __count bits,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_add_epi64(__m256i __a, __m256i __b)
Adds 64-bit integers from corresponding elements of two 256-bit vectors of [4 x i64] and returns the ...
Definition avx2intrin.h:333
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepi16_epi64(__m128i __V)
Sign-extends 16-bit elements from the lower half of the 128-bit vector of [8 x i16] in __V and return...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_unpackhi_epi8(__m256i __a, __m256i __b)
Unpacks and interleaves 8-bit integers from parts of the 256-bit integer vectors in __a and __b to fo...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sub_epi16(__m256i __a, __m256i __b)
Subtracts 16-bit integers from corresponding elements of two 256-bit vectors of [16 x i16].
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_and_si256(__m256i __a, __m256i __b)
Computes the bitwise AND of the 256-bit integer vectors in __a and __b.
Definition avx2intrin.h:448
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_slli_epi32(__m256i __a, int __count)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __a left by __count bits,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_broadcastsi128_si256(__m128i __X)
Broadcasts the 128-bit integer data from __X to both the lower and upper halves of the 256-bit result...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srai_epi32(__m256i __a, int __count)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __a right by __count bits,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_add_epi32(__m256i __a, __m256i __b)
Adds 32-bit integers from corresponding elements of two 256-bit vectors of [8 x i32] and returns the ...
Definition avx2intrin.h:315
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sra_epi16(__m256i __a, __m128i __count)
Shifts each 16-bit element of the 256-bit vector of [16 x i16] in __a right by the number of bits giv...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srl_epi32(__m256i __a, __m128i __count)
Shifts each 32-bit element of the 256-bit vector of [8 x i32] in __a right by the number of bits give...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sad_epu8(__m256i __a, __m256i __b)
Computes four sum of absolute difference (SAD) operations on sets of eight unsigned 8-bit integers fr...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_packus_epi16(__m256i __a, __m256i __b)
Converts elements from two 256-bit vectors of [16 x i16] to 8-bit integers using unsigned saturation,...
Definition avx2intrin.h:230
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_abs_epi16(__m256i __a)
Computes the absolute value of each signed 16-bit element in the 256-bit vector of [16 x i16] in __a ...
Definition avx2intrin.h:123
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_max_epu8(__m256i __a, __m256i __b)
Compares the corresponding unsigned bytes in the two 256-bit integer vectors in __a and __b and retur...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_add_epi16(__m256i __a, __m256i __b)
Adds 16-bit integers from corresponding elements of two 256-bit vectors of [16 x i16] and returns the...
Definition avx2intrin.h:297
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_or_si256(__m256i __a, __m256i __b)
Computes the bitwise OR of the 256-bit integer vectors in __a and __b.
static __inline__ __m256d __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_broadcastsd_pd(__m128d __X)
Broadcasts the 64-bit floating-point value from the low element of the 128-bit vector of [2 x double]...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_min_epu8(__m256i __a, __m256i __b)
Compares the corresponding unsigned bytes in the two 256-bit integer vectors in __a and __b and retur...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepu16_epi32(__m128i __V)
Zero-extends 16-bit elements from the 128-bit vector of [8 x i16] in __V and returns the 32-bit value...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_max_epu32(__m256i __a, __m256i __b)
Compares the corresponding unsigned 32-bit integers in the two 256-bit vectors of [8 x i32] in __a an...
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_sllv_epi64(__m128i __X, __m128i __Y)
Shifts each 64-bit element of the 128-bit vector of [2 x i64] in __X left by the number of bits given...
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_sllv_epi32(__m128i __X, __m128i __Y)
Shifts each 32-bit element of the 128-bit vector of [4 x i32] in __X left by the number of bits given...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sub_epi8(__m256i __a, __m256i __b)
Subtracts 8-bit integers from corresponding bytes of two 256-bit integer vectors.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_hadd_epi16(__m256i __a, __m256i __b)
Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit vectors of [16 x i16] and re...
Definition avx2intrin.h:838
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_min_epi16(__m256i __a, __m256i __b)
Compares the corresponding signed 16-bit integers in the two 256-bit vectors of [16 x i16] in __a and...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_avg_epu16(__m256i __a, __m256i __b)
Computes the averages of the corresponding unsigned 16-bit integers in the two 256-bit vectors of [16...
Definition avx2intrin.h:517
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_xor_si256(__m256i __a, __m256i __b)
Computes the bitwise XOR of the 256-bit integer vectors in __a and __b.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_min_epu32(__m256i __a, __m256i __b)
Compares the corresponding unsigned 32-bit integers in the two 256-bit vectors of [8 x i32] in __a an...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sign_epi8(__m256i __a, __m256i __b)
Sets each byte of the result to the corresponding byte of the 256-bit integer vector in __a,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cvtepi16_epi32(__m128i __V)
Sign-extends 16-bit elements from the 128-bit vector of [8 x i16] in __V and returns the 32-bit value...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_adds_epu16(__m256i __a, __m256i __b)
Adds 16-bit integers from corresponding elements of two 256-bit vectors of [16 x i16] using unsigned ...
Definition avx2intrin.h:403
static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_maskload_epi64(long long const *__X, __m128i __M)
Conditionally loads two 64-bit integer elements from memory __X, if the most significant bit of the c...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sub_epi64(__m256i __a, __m256i __b)
Subtracts 64-bit integers from corresponding elements of two 256-bit vectors of [4 x i64].
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_madd_epi16(__m256i __a, __m256i __b)
Multiplies corresponding 16-bit elements of two 256-bit vectors of [16 x i16], forming 32-bit interme...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_max_epi8(__m256i __a, __m256i __b)
Compares the corresponding signed bytes in the two 256-bit integer vectors in __a and __b and returns...
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_broadcastd_epi32(__m128i __X)
Broadcasts the low element from the 128-bit vector of [4 x i32] in __X to all elements of the result'...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_broadcastd_epi32(__m128i __X)
Broadcasts the low element from the 128-bit vector of [4 x i32] in __X to all elements of the result'...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_unpackhi_epi16(__m256i __a, __m256i __b)
Unpacks and interleaves 16-bit integers from parts of the 256-bit vectors of [16 x i16] in __a and __...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_srlv_epi64(__m256i __X, __m256i __Y)
Shifts each 64-bit element of the 256-bit vector of [4 x i64] in __X right by the number of bits give...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_subs_epi8(__m256i __a, __m256i __b)
Subtracts 8-bit integers from corresponding bytes of two 256-bit integer vectors using signed saturat...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_packs_epi32(__m256i __a, __m256i __b)
Converts the elements of two 256-bit vectors of [8 x i32] to 16-bit integers using signed saturation,...
Definition avx2intrin.h:200
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_mulhrs_epi16(__m256i __a, __m256i __b)
Multiplies signed 16-bit integer elements of two 256-bit vectors of [16 x i16], truncates the 32-bit ...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cmpgt_epi64(__m256i __a, __m256i __b)
Compares corresponding signed elements in the 256-bit vectors of [4 x i64] in __a and __b for greater...
Definition avx2intrin.h:802
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_adds_epi8(__m256i __a, __m256i __b)
Adds 8-bit integers from corresponding bytes of two 256-bit integer vectors using signed saturation,...
Definition avx2intrin.h:351
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_sllv_epi64(__m256i __X, __m256i __Y)
Shifts each 64-bit element of the 256-bit vector of [4 x i64] in __X left by the number of bits given...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_slli_epi16(__m256i __a, int __count)
Shifts each 16-bit element of the 256-bit vector of [16 x i16] in __a left by __count bits,...
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_cmpeq_epi16(__m256i __a, __m256i __b)
Compares corresponding elements in the 256-bit vectors of [16 x i16] in __a and __b for equality and ...
Definition avx2intrin.h:644
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_packs_epi16(__m256i __a, __m256i __b)
Converts the elements of two 256-bit vectors of [16 x i16] to 8-bit integers using signed saturation,...
Definition avx2intrin.h:169
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_avg_epu8(__m256i __a, __m256i __b)
Computes the averages of the corresponding unsigned bytes in the two 256-bit integer vectors in __a a...
Definition avx2intrin.h:492
static __inline__ void int __a
Definition emmintrin.h:4077
__inline unsigned int unsigned int __Y
Definition bmi2intrin.h:19