clang 20.0.0git
tmmintrin.h
Go to the documentation of this file.
1/*===---- tmmintrin.h - SSSE3 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 __TMMINTRIN_H
11#define __TMMINTRIN_H
12
13#if !defined(__i386__) && !defined(__x86_64__)
14#error "This header is only meant to be used on x86 and x64 architecture"
15#endif
16
17#include <pmmintrin.h>
18
19/* Define the default attributes for the functions in this file. */
20#define __DEFAULT_FN_ATTRS \
21 __attribute__((__always_inline__, __nodebug__, \
22 __target__("ssse3,no-evex512"), __min_vector_width__(128)))
23
24#define __trunc64(x) \
25 (__m64) __builtin_shufflevector((__v2di)(x), __extension__(__v2di){}, 0)
26#define __anyext128(x) \
27 (__m128i) __builtin_shufflevector((__v2si)(x), __extension__(__v2si){}, 0, \
28 1, -1, -1)
29
30/// Computes the absolute value of each of the packed 8-bit signed
31/// integers in the source operand and stores the 8-bit unsigned integer
32/// results in the destination.
33///
34/// \headerfile <x86intrin.h>
35///
36/// This intrinsic corresponds to the \c PABSB instruction.
37///
38/// \param __a
39/// A 64-bit vector of [8 x i8].
40/// \returns A 64-bit integer vector containing the absolute values of the
41/// elements in the operand.
42static __inline__ __m64 __DEFAULT_FN_ATTRS
44{
45 return (__m64)__builtin_elementwise_abs((__v8qs)__a);
46}
47
48/// Computes the absolute value of each of the packed 8-bit signed
49/// integers in the source operand and stores the 8-bit unsigned integer
50/// results in the destination.
51///
52/// \headerfile <x86intrin.h>
53///
54/// This intrinsic corresponds to the \c VPABSB instruction.
55///
56/// \param __a
57/// A 128-bit vector of [16 x i8].
58/// \returns A 128-bit integer vector containing the absolute values of the
59/// elements in the operand.
60static __inline__ __m128i __DEFAULT_FN_ATTRS
62{
63 return (__m128i)__builtin_elementwise_abs((__v16qs)__a);
64}
65
66/// Computes the absolute value of each of the packed 16-bit signed
67/// integers in the source operand and stores the 16-bit unsigned integer
68/// results in the destination.
69///
70/// \headerfile <x86intrin.h>
71///
72/// This intrinsic corresponds to the \c PABSW instruction.
73///
74/// \param __a
75/// A 64-bit vector of [4 x i16].
76/// \returns A 64-bit integer vector containing the absolute values of the
77/// elements in the operand.
78static __inline__ __m64 __DEFAULT_FN_ATTRS
80{
81 return (__m64)__builtin_elementwise_abs((__v4hi)__a);
82}
83
84/// Computes the absolute value of each of the packed 16-bit signed
85/// integers in the source operand and stores the 16-bit unsigned integer
86/// results in the destination.
87///
88/// \headerfile <x86intrin.h>
89///
90/// This intrinsic corresponds to the \c VPABSW instruction.
91///
92/// \param __a
93/// A 128-bit vector of [8 x i16].
94/// \returns A 128-bit integer vector containing the absolute values of the
95/// elements in the operand.
96static __inline__ __m128i __DEFAULT_FN_ATTRS
98{
99 return (__m128i)__builtin_elementwise_abs((__v8hi)__a);
100}
101
102/// Computes the absolute value of each of the packed 32-bit signed
103/// integers in the source operand and stores the 32-bit unsigned integer
104/// results in the destination.
105///
106/// \headerfile <x86intrin.h>
107///
108/// This intrinsic corresponds to the \c PABSD instruction.
109///
110/// \param __a
111/// A 64-bit vector of [2 x i32].
112/// \returns A 64-bit integer vector containing the absolute values of the
113/// elements in the operand.
114static __inline__ __m64 __DEFAULT_FN_ATTRS
116{
117 return (__m64)__builtin_elementwise_abs((__v2si)__a);
118}
119
120/// Computes the absolute value of each of the packed 32-bit signed
121/// integers in the source operand and stores the 32-bit unsigned integer
122/// results in the destination.
123///
124/// \headerfile <x86intrin.h>
125///
126/// This intrinsic corresponds to the \c VPABSD instruction.
127///
128/// \param __a
129/// A 128-bit vector of [4 x i32].
130/// \returns A 128-bit integer vector containing the absolute values of the
131/// elements in the operand.
132static __inline__ __m128i __DEFAULT_FN_ATTRS
134{
135 return (__m128i)__builtin_elementwise_abs((__v4si)__a);
136}
137
138/// Concatenates the two 128-bit integer vector operands, and
139/// right-shifts the result by the number of bytes specified in the immediate
140/// operand.
141///
142/// \headerfile <x86intrin.h>
143///
144/// \code
145/// __m128i _mm_alignr_epi8(__m128i a, __m128i b, const int n);
146/// \endcode
147///
148/// This intrinsic corresponds to the \c PALIGNR instruction.
149///
150/// \param a
151/// A 128-bit vector of [16 x i8] containing one of the source operands.
152/// \param b
153/// A 128-bit vector of [16 x i8] containing one of the source operands.
154/// \param n
155/// An immediate operand specifying how many bytes to right-shift the result.
156/// \returns A 128-bit integer vector containing the concatenated right-shifted
157/// value.
158#define _mm_alignr_epi8(a, b, n) \
159 ((__m128i)__builtin_ia32_palignr128((__v16qi)(__m128i)(a), \
160 (__v16qi)(__m128i)(b), (n)))
161
162/// Concatenates the two 64-bit integer vector operands, and right-shifts
163/// the result by the number of bytes specified in the immediate operand.
164///
165/// \headerfile <x86intrin.h>
166///
167/// \code
168/// __m64 _mm_alignr_pi8(__m64 a, __m64 b, const int n);
169/// \endcode
170///
171/// This intrinsic corresponds to the \c PALIGNR instruction.
172///
173/// \param a
174/// A 64-bit vector of [8 x i8] containing one of the source operands.
175/// \param b
176/// A 64-bit vector of [8 x i8] containing one of the source operands.
177/// \param n
178/// An immediate operand specifying how many bytes to right-shift the result.
179/// \returns A 64-bit integer vector containing the concatenated right-shifted
180/// value.
181#define _mm_alignr_pi8(a, b, n) \
182 ((__m64)__builtin_shufflevector( \
183 __builtin_ia32_psrldqi128_byteshift( \
184 __builtin_shufflevector((__v1di)(a), (__v1di)(b), 1, 0), \
185 (n)), __extension__ (__v2di){}, 0))
186
187/// Horizontally adds the adjacent pairs of values contained in 2 packed
188/// 128-bit vectors of [8 x i16].
189///
190/// \headerfile <x86intrin.h>
191///
192/// This intrinsic corresponds to the \c VPHADDW instruction.
193///
194/// \param __a
195/// A 128-bit vector of [8 x i16] containing one of the source operands. The
196/// horizontal sums of the values are stored in the lower bits of the
197/// destination.
198/// \param __b
199/// A 128-bit vector of [8 x i16] containing one of the source operands. The
200/// horizontal sums of the values are stored in the upper bits of the
201/// destination.
202/// \returns A 128-bit vector of [8 x i16] containing the horizontal sums of
203/// both operands.
204static __inline__ __m128i __DEFAULT_FN_ATTRS
205_mm_hadd_epi16(__m128i __a, __m128i __b)
206{
207 return (__m128i)__builtin_ia32_phaddw128((__v8hi)__a, (__v8hi)__b);
208}
209
210/// Horizontally adds the adjacent pairs of values contained in 2 packed
211/// 128-bit vectors of [4 x i32].
212///
213/// \headerfile <x86intrin.h>
214///
215/// This intrinsic corresponds to the \c VPHADDD instruction.
216///
217/// \param __a
218/// A 128-bit vector of [4 x i32] containing one of the source operands. The
219/// horizontal sums of the values are stored in the lower bits of the
220/// destination.
221/// \param __b
222/// A 128-bit vector of [4 x i32] containing one of the source operands. The
223/// horizontal sums of the values are stored in the upper bits of the
224/// destination.
225/// \returns A 128-bit vector of [4 x i32] containing the horizontal sums of
226/// both operands.
227static __inline__ __m128i __DEFAULT_FN_ATTRS
228_mm_hadd_epi32(__m128i __a, __m128i __b)
229{
230 return (__m128i)__builtin_ia32_phaddd128((__v4si)__a, (__v4si)__b);
231}
232
233/// Horizontally adds the adjacent pairs of values contained in 2 packed
234/// 64-bit vectors of [4 x i16].
235///
236/// \headerfile <x86intrin.h>
237///
238/// This intrinsic corresponds to the \c PHADDW instruction.
239///
240/// \param __a
241/// A 64-bit vector of [4 x i16] containing one of the source operands. The
242/// horizontal sums of the values are stored in the lower bits of the
243/// destination.
244/// \param __b
245/// A 64-bit vector of [4 x i16] containing one of the source operands. The
246/// horizontal sums of the values are stored in the upper bits of the
247/// destination.
248/// \returns A 64-bit vector of [4 x i16] containing the horizontal sums of both
249/// operands.
250static __inline__ __m64 __DEFAULT_FN_ATTRS
251_mm_hadd_pi16(__m64 __a, __m64 __b)
252{
253 return __trunc64(__builtin_ia32_phaddw128(
254 (__v8hi)__builtin_shufflevector(__a, __b, 0, 1), (__v8hi){}));
255}
256
257/// Horizontally adds the adjacent pairs of values contained in 2 packed
258/// 64-bit vectors of [2 x i32].
259///
260/// \headerfile <x86intrin.h>
261///
262/// This intrinsic corresponds to the \c PHADDD instruction.
263///
264/// \param __a
265/// A 64-bit vector of [2 x i32] containing one of the source operands. The
266/// horizontal sums of the values are stored in the lower bits of the
267/// destination.
268/// \param __b
269/// A 64-bit vector of [2 x i32] containing one of the source operands. The
270/// horizontal sums of the values are stored in the upper bits of the
271/// destination.
272/// \returns A 64-bit vector of [2 x i32] containing the horizontal sums of both
273/// operands.
274static __inline__ __m64 __DEFAULT_FN_ATTRS
275_mm_hadd_pi32(__m64 __a, __m64 __b)
276{
277 return __trunc64(__builtin_ia32_phaddd128(
278 (__v4si)__builtin_shufflevector(__a, __b, 0, 1), (__v4si){}));
279}
280
281/// Horizontally adds, with saturation, the adjacent pairs of values contained
282/// in two packed 128-bit vectors of [8 x i16].
283///
284/// Positive sums greater than 0x7FFF are saturated to 0x7FFF. Negative sums
285/// less than 0x8000 are saturated to 0x8000.
286///
287/// \headerfile <x86intrin.h>
288///
289/// This intrinsic corresponds to the \c VPHADDSW instruction.
290///
291/// \param __a
292/// A 128-bit vector of [8 x i16] containing one of the source operands. The
293/// horizontal sums of the values are stored in the lower bits of the
294/// destination.
295/// \param __b
296/// A 128-bit vector of [8 x i16] containing one of the source operands. The
297/// horizontal sums of the values are stored in the upper bits of the
298/// destination.
299/// \returns A 128-bit vector of [8 x i16] containing the horizontal saturated
300/// sums of both operands.
301static __inline__ __m128i __DEFAULT_FN_ATTRS
302_mm_hadds_epi16(__m128i __a, __m128i __b)
303{
304 return (__m128i)__builtin_ia32_phaddsw128((__v8hi)__a, (__v8hi)__b);
305}
306
307/// Horizontally adds, with saturation, the adjacent pairs of values contained
308/// in two packed 64-bit vectors of [4 x i16].
309///
310/// Positive sums greater than 0x7FFF are saturated to 0x7FFF. Negative sums
311/// less than 0x8000 are saturated to 0x8000.
312///
313/// \headerfile <x86intrin.h>
314///
315/// This intrinsic corresponds to the \c PHADDSW instruction.
316///
317/// \param __a
318/// A 64-bit vector of [4 x i16] containing one of the source operands. The
319/// horizontal sums of the values are stored in the lower bits of the
320/// destination.
321/// \param __b
322/// A 64-bit vector of [4 x i16] containing one of the source operands. The
323/// horizontal sums of the values are stored in the upper bits of the
324/// destination.
325/// \returns A 64-bit vector of [4 x i16] containing the horizontal saturated
326/// sums of both operands.
327static __inline__ __m64 __DEFAULT_FN_ATTRS
328_mm_hadds_pi16(__m64 __a, __m64 __b)
329{
330 return __trunc64(__builtin_ia32_phaddsw128(
331 (__v8hi)__builtin_shufflevector(__a, __b, 0, 1), (__v8hi){}));
332}
333
334/// Horizontally subtracts the adjacent pairs of values contained in 2
335/// packed 128-bit vectors of [8 x i16].
336///
337/// \headerfile <x86intrin.h>
338///
339/// This intrinsic corresponds to the \c VPHSUBW instruction.
340///
341/// \param __a
342/// A 128-bit vector of [8 x i16] containing one of the source operands. The
343/// horizontal differences between the values are stored in the lower bits of
344/// the destination.
345/// \param __b
346/// A 128-bit vector of [8 x i16] containing one of the source operands. The
347/// horizontal differences between the values are stored in the upper bits of
348/// the destination.
349/// \returns A 128-bit vector of [8 x i16] containing the horizontal differences
350/// of both operands.
351static __inline__ __m128i __DEFAULT_FN_ATTRS
352_mm_hsub_epi16(__m128i __a, __m128i __b)
353{
354 return (__m128i)__builtin_ia32_phsubw128((__v8hi)__a, (__v8hi)__b);
355}
356
357/// Horizontally subtracts the adjacent pairs of values contained in 2
358/// packed 128-bit vectors of [4 x i32].
359///
360/// \headerfile <x86intrin.h>
361///
362/// This intrinsic corresponds to the \c VPHSUBD instruction.
363///
364/// \param __a
365/// A 128-bit vector of [4 x i32] containing one of the source operands. The
366/// horizontal differences between the values are stored in the lower bits of
367/// the destination.
368/// \param __b
369/// A 128-bit vector of [4 x i32] containing one of the source operands. The
370/// horizontal differences between the values are stored in the upper bits of
371/// the destination.
372/// \returns A 128-bit vector of [4 x i32] containing the horizontal differences
373/// of both operands.
374static __inline__ __m128i __DEFAULT_FN_ATTRS
375_mm_hsub_epi32(__m128i __a, __m128i __b)
376{
377 return (__m128i)__builtin_ia32_phsubd128((__v4si)__a, (__v4si)__b);
378}
379
380/// Horizontally subtracts the adjacent pairs of values contained in 2
381/// packed 64-bit vectors of [4 x i16].
382///
383/// \headerfile <x86intrin.h>
384///
385/// This intrinsic corresponds to the \c PHSUBW instruction.
386///
387/// \param __a
388/// A 64-bit vector of [4 x i16] containing one of the source operands. The
389/// horizontal differences between the values are stored in the lower bits of
390/// the destination.
391/// \param __b
392/// A 64-bit vector of [4 x i16] containing one of the source operands. The
393/// horizontal differences between the values are stored in the upper bits of
394/// the destination.
395/// \returns A 64-bit vector of [4 x i16] containing the horizontal differences
396/// of both operands.
397static __inline__ __m64 __DEFAULT_FN_ATTRS
398_mm_hsub_pi16(__m64 __a, __m64 __b)
399{
400 return __trunc64(__builtin_ia32_phsubw128(
401 (__v8hi)__builtin_shufflevector(__a, __b, 0, 1), (__v8hi){}));
402}
403
404/// Horizontally subtracts the adjacent pairs of values contained in 2
405/// packed 64-bit vectors of [2 x i32].
406///
407/// \headerfile <x86intrin.h>
408///
409/// This intrinsic corresponds to the \c PHSUBD instruction.
410///
411/// \param __a
412/// A 64-bit vector of [2 x i32] containing one of the source operands. The
413/// horizontal differences between the values are stored in the lower bits of
414/// the destination.
415/// \param __b
416/// A 64-bit vector of [2 x i32] containing one of the source operands. The
417/// horizontal differences between the values are stored in the upper bits of
418/// the destination.
419/// \returns A 64-bit vector of [2 x i32] containing the horizontal differences
420/// of both operands.
421static __inline__ __m64 __DEFAULT_FN_ATTRS
422_mm_hsub_pi32(__m64 __a, __m64 __b)
423{
424 return __trunc64(__builtin_ia32_phsubd128(
425 (__v4si)__builtin_shufflevector(__a, __b, 0, 1), (__v4si){}));
426}
427
428/// Horizontally subtracts, with saturation, the adjacent pairs of values
429/// contained in two packed 128-bit vectors of [8 x i16].
430///
431/// Positive differences greater than 0x7FFF are saturated to 0x7FFF.
432/// Negative differences less than 0x8000 are saturated to 0x8000.
433///
434/// \headerfile <x86intrin.h>
435///
436/// This intrinsic corresponds to the \c VPHSUBSW instruction.
437///
438/// \param __a
439/// A 128-bit vector of [8 x i16] containing one of the source operands. The
440/// horizontal differences between the values are stored in the lower bits of
441/// the destination.
442/// \param __b
443/// A 128-bit vector of [8 x i16] containing one of the source operands. The
444/// horizontal differences between the values are stored in the upper bits of
445/// the destination.
446/// \returns A 128-bit vector of [8 x i16] containing the horizontal saturated
447/// differences of both operands.
448static __inline__ __m128i __DEFAULT_FN_ATTRS
449_mm_hsubs_epi16(__m128i __a, __m128i __b)
450{
451 return (__m128i)__builtin_ia32_phsubsw128((__v8hi)__a, (__v8hi)__b);
452}
453
454/// Horizontally subtracts, with saturation, the adjacent pairs of values
455/// contained in two packed 64-bit vectors of [4 x i16].
456///
457/// Positive differences greater than 0x7FFF are saturated to 0x7FFF.
458/// Negative differences less than 0x8000 are saturated to 0x8000.
459///
460/// \headerfile <x86intrin.h>
461///
462/// This intrinsic corresponds to the \c PHSUBSW instruction.
463///
464/// \param __a
465/// A 64-bit vector of [4 x i16] containing one of the source operands. The
466/// horizontal differences between the values are stored in the lower bits of
467/// the destination.
468/// \param __b
469/// A 64-bit vector of [4 x i16] containing one of the source operands. The
470/// horizontal differences between the values are stored in the upper bits of
471/// the destination.
472/// \returns A 64-bit vector of [4 x i16] containing the horizontal saturated
473/// differences of both operands.
474static __inline__ __m64 __DEFAULT_FN_ATTRS
475_mm_hsubs_pi16(__m64 __a, __m64 __b)
476{
477 return __trunc64(__builtin_ia32_phsubsw128(
478 (__v8hi)__builtin_shufflevector(__a, __b, 0, 1), (__v8hi){}));
479}
480
481/// Multiplies corresponding pairs of packed 8-bit unsigned integer
482/// values contained in the first source operand and packed 8-bit signed
483/// integer values contained in the second source operand, adds pairs of
484/// contiguous products with signed saturation, and writes the 16-bit sums to
485/// the corresponding bits in the destination.
486///
487/// For example, bits [7:0] of both operands are multiplied, bits [15:8] of
488/// both operands are multiplied, and the sum of both results is written to
489/// bits [15:0] of the destination.
490///
491/// \headerfile <x86intrin.h>
492///
493/// This intrinsic corresponds to the \c VPMADDUBSW instruction.
494///
495/// \param __a
496/// A 128-bit integer vector containing the first source operand.
497/// \param __b
498/// A 128-bit integer vector containing the second source operand.
499/// \returns A 128-bit integer vector containing the sums of products of both
500/// operands: \n
501/// \a R0 := (\a __a0 * \a __b0) + (\a __a1 * \a __b1) \n
502/// \a R1 := (\a __a2 * \a __b2) + (\a __a3 * \a __b3) \n
503/// \a R2 := (\a __a4 * \a __b4) + (\a __a5 * \a __b5) \n
504/// \a R3 := (\a __a6 * \a __b6) + (\a __a7 * \a __b7) \n
505/// \a R4 := (\a __a8 * \a __b8) + (\a __a9 * \a __b9) \n
506/// \a R5 := (\a __a10 * \a __b10) + (\a __a11 * \a __b11) \n
507/// \a R6 := (\a __a12 * \a __b12) + (\a __a13 * \a __b13) \n
508/// \a R7 := (\a __a14 * \a __b14) + (\a __a15 * \a __b15)
509static __inline__ __m128i __DEFAULT_FN_ATTRS
510_mm_maddubs_epi16(__m128i __a, __m128i __b)
511{
512 return (__m128i)__builtin_ia32_pmaddubsw128((__v16qi)__a, (__v16qi)__b);
513}
514
515/// Multiplies corresponding pairs of packed 8-bit unsigned integer
516/// values contained in the first source operand and packed 8-bit signed
517/// integer values contained in the second source operand, adds pairs of
518/// contiguous products with signed saturation, and writes the 16-bit sums to
519/// the corresponding bits in the destination.
520///
521/// For example, bits [7:0] of both operands are multiplied, bits [15:8] of
522/// both operands are multiplied, and the sum of both results is written to
523/// bits [15:0] of the destination.
524///
525/// \headerfile <x86intrin.h>
526///
527/// This intrinsic corresponds to the \c PMADDUBSW instruction.
528///
529/// \param __a
530/// A 64-bit integer vector containing the first source operand.
531/// \param __b
532/// A 64-bit integer vector containing the second source operand.
533/// \returns A 64-bit integer vector containing the sums of products of both
534/// operands: \n
535/// \a R0 := (\a __a0 * \a __b0) + (\a __a1 * \a __b1) \n
536/// \a R1 := (\a __a2 * \a __b2) + (\a __a3 * \a __b3) \n
537/// \a R2 := (\a __a4 * \a __b4) + (\a __a5 * \a __b5) \n
538/// \a R3 := (\a __a6 * \a __b6) + (\a __a7 * \a __b7)
539static __inline__ __m64 __DEFAULT_FN_ATTRS
541{
542 return __trunc64(__builtin_ia32_pmaddubsw128((__v16qi)__anyext128(__a),
543 (__v16qi)__anyext128(__b)));
544}
545
546/// Multiplies packed 16-bit signed integer values, truncates the 32-bit
547/// products to the 18 most significant bits by right-shifting, rounds the
548/// truncated value by adding 1, and writes bits [16:1] to the destination.
549///
550/// \headerfile <x86intrin.h>
551///
552/// This intrinsic corresponds to the \c VPMULHRSW instruction.
553///
554/// \param __a
555/// A 128-bit vector of [8 x i16] containing one of the source operands.
556/// \param __b
557/// A 128-bit vector of [8 x i16] containing one of the source operands.
558/// \returns A 128-bit vector of [8 x i16] containing the rounded and scaled
559/// products of both operands.
560static __inline__ __m128i __DEFAULT_FN_ATTRS
561_mm_mulhrs_epi16(__m128i __a, __m128i __b)
562{
563 return (__m128i)__builtin_ia32_pmulhrsw128((__v8hi)__a, (__v8hi)__b);
564}
565
566/// Multiplies packed 16-bit signed integer values, truncates the 32-bit
567/// products to the 18 most significant bits by right-shifting, rounds the
568/// truncated value by adding 1, and writes bits [16:1] to the destination.
569///
570/// \headerfile <x86intrin.h>
571///
572/// This intrinsic corresponds to the \c PMULHRSW instruction.
573///
574/// \param __a
575/// A 64-bit vector of [4 x i16] containing one of the source operands.
576/// \param __b
577/// A 64-bit vector of [4 x i16] containing one of the source operands.
578/// \returns A 64-bit vector of [4 x i16] containing the rounded and scaled
579/// products of both operands.
580static __inline__ __m64 __DEFAULT_FN_ATTRS
582{
583 return __trunc64(__builtin_ia32_pmulhrsw128((__v8hi)__anyext128(__a),
584 (__v8hi)__anyext128(__b)));
585}
586
587/// Copies the 8-bit integers from a 128-bit integer vector to the
588/// destination or clears 8-bit values in the destination, as specified by
589/// the second source operand.
590///
591/// \headerfile <x86intrin.h>
592///
593/// This intrinsic corresponds to the \c VPSHUFB instruction.
594///
595/// \param __a
596/// A 128-bit integer vector containing the values to be copied.
597/// \param __b
598/// A 128-bit integer vector containing control bytes corresponding to
599/// positions in the destination:
600/// Bit 7: \n
601/// 1: Clear the corresponding byte in the destination. \n
602/// 0: Copy the selected source byte to the corresponding byte in the
603/// destination. \n
604/// Bits [6:4] Reserved. \n
605/// Bits [3:0] select the source byte to be copied.
606/// \returns A 128-bit integer vector containing the copied or cleared values.
607static __inline__ __m128i __DEFAULT_FN_ATTRS
608_mm_shuffle_epi8(__m128i __a, __m128i __b)
609{
610 return (__m128i)__builtin_ia32_pshufb128((__v16qi)__a, (__v16qi)__b);
611}
612
613/// Copies the 8-bit integers from a 64-bit integer vector to the
614/// destination or clears 8-bit values in the destination, as specified by
615/// the second source operand.
616///
617/// \headerfile <x86intrin.h>
618///
619/// This intrinsic corresponds to the \c PSHUFB instruction.
620///
621/// \param __a
622/// A 64-bit integer vector containing the values to be copied.
623/// \param __b
624/// A 64-bit integer vector containing control bytes corresponding to
625/// positions in the destination:
626/// Bit 7: \n
627/// 1: Clear the corresponding byte in the destination. \n
628/// 0: Copy the selected source byte to the corresponding byte in the
629/// destination. \n
630/// Bits [2:0] select the source byte to be copied.
631/// \returns A 64-bit integer vector containing the copied or cleared values.
632static __inline__ __m64 __DEFAULT_FN_ATTRS
634{
635 return __trunc64(__builtin_ia32_pshufb128(
636 (__v16qi)__builtin_shufflevector(
637 (__v2si)(__a), __extension__ (__v2si){}, 0, 1, 0, 1),
638 (__v16qi)__anyext128(__b)));
639}
640
641/// For each 8-bit integer in the first source operand, perform one of
642/// the following actions as specified by the second source operand.
643///
644/// If the byte in the second source is negative, calculate the two's
645/// complement of the corresponding byte in the first source, and write that
646/// value to the destination. If the byte in the second source is positive,
647/// copy the corresponding byte from the first source to the destination. If
648/// the byte in the second source is zero, clear the corresponding byte in
649/// the destination.
650///
651/// \headerfile <x86intrin.h>
652///
653/// This intrinsic corresponds to the \c VPSIGNB instruction.
654///
655/// \param __a
656/// A 128-bit integer vector containing the values to be copied.
657/// \param __b
658/// A 128-bit integer vector containing control bytes corresponding to
659/// positions in the destination.
660/// \returns A 128-bit integer vector containing the resultant values.
661static __inline__ __m128i __DEFAULT_FN_ATTRS
662_mm_sign_epi8(__m128i __a, __m128i __b)
663{
664 return (__m128i)__builtin_ia32_psignb128((__v16qi)__a, (__v16qi)__b);
665}
666
667/// For each 16-bit integer in the first source operand, perform one of
668/// the following actions as specified by the second source operand.
669///
670/// If the word in the second source is negative, calculate the two's
671/// complement of the corresponding word in the first source, and write that
672/// value to the destination. If the word in the second source is positive,
673/// copy the corresponding word from the first source to the destination. If
674/// the word in the second source is zero, clear the corresponding word in
675/// the destination.
676///
677/// \headerfile <x86intrin.h>
678///
679/// This intrinsic corresponds to the \c VPSIGNW instruction.
680///
681/// \param __a
682/// A 128-bit integer vector containing the values to be copied.
683/// \param __b
684/// A 128-bit integer vector containing control words corresponding to
685/// positions in the destination.
686/// \returns A 128-bit integer vector containing the resultant values.
687static __inline__ __m128i __DEFAULT_FN_ATTRS
688_mm_sign_epi16(__m128i __a, __m128i __b)
689{
690 return (__m128i)__builtin_ia32_psignw128((__v8hi)__a, (__v8hi)__b);
691}
692
693/// For each 32-bit integer in the first source operand, perform one of
694/// the following actions as specified by the second source operand.
695///
696/// If the doubleword in the second source is negative, calculate the two's
697/// complement of the corresponding word in the first source, and write that
698/// value to the destination. If the doubleword in the second source is
699/// positive, copy the corresponding word from the first source to the
700/// destination. If the doubleword in the second source is zero, clear the
701/// corresponding word in the destination.
702///
703/// \headerfile <x86intrin.h>
704///
705/// This intrinsic corresponds to the \c VPSIGND instruction.
706///
707/// \param __a
708/// A 128-bit integer vector containing the values to be copied.
709/// \param __b
710/// A 128-bit integer vector containing control doublewords corresponding to
711/// positions in the destination.
712/// \returns A 128-bit integer vector containing the resultant values.
713static __inline__ __m128i __DEFAULT_FN_ATTRS
714_mm_sign_epi32(__m128i __a, __m128i __b)
715{
716 return (__m128i)__builtin_ia32_psignd128((__v4si)__a, (__v4si)__b);
717}
718
719/// For each 8-bit integer in the first source operand, perform one of
720/// the following actions as specified by the second source operand.
721///
722/// If the byte in the second source is negative, calculate the two's
723/// complement of the corresponding byte in the first source, and write that
724/// value to the destination. If the byte in the second source is positive,
725/// copy the corresponding byte from the first source to the destination. If
726/// the byte in the second source is zero, clear the corresponding byte in
727/// the destination.
728///
729/// \headerfile <x86intrin.h>
730///
731/// This intrinsic corresponds to the \c PSIGNB instruction.
732///
733/// \param __a
734/// A 64-bit integer vector containing the values to be copied.
735/// \param __b
736/// A 64-bit integer vector containing control bytes corresponding to
737/// positions in the destination.
738/// \returns A 64-bit integer vector containing the resultant values.
739static __inline__ __m64 __DEFAULT_FN_ATTRS
740_mm_sign_pi8(__m64 __a, __m64 __b)
741{
742 return __trunc64(__builtin_ia32_psignb128((__v16qi)__anyext128(__a),
743 (__v16qi)__anyext128(__b)));
744}
745
746/// For each 16-bit integer in the first source operand, perform one of
747/// the following actions as specified by the second source operand.
748///
749/// If the word in the second source is negative, calculate the two's
750/// complement of the corresponding word in the first source, and write that
751/// value to the destination. If the word in the second source is positive,
752/// copy the corresponding word from the first source to the destination. If
753/// the word in the second source is zero, clear the corresponding word in
754/// the destination.
755///
756/// \headerfile <x86intrin.h>
757///
758/// This intrinsic corresponds to the \c PSIGNW instruction.
759///
760/// \param __a
761/// A 64-bit integer vector containing the values to be copied.
762/// \param __b
763/// A 64-bit integer vector containing control words corresponding to
764/// positions in the destination.
765/// \returns A 64-bit integer vector containing the resultant values.
766static __inline__ __m64 __DEFAULT_FN_ATTRS
767_mm_sign_pi16(__m64 __a, __m64 __b)
768{
769 return __trunc64(__builtin_ia32_psignw128((__v8hi)__anyext128(__a),
770 (__v8hi)__anyext128(__b)));
771}
772
773/// For each 32-bit integer in the first source operand, perform one of
774/// the following actions as specified by the second source operand.
775///
776/// If the doubleword in the second source is negative, calculate the two's
777/// complement of the corresponding doubleword in the first source, and
778/// write that value to the destination. If the doubleword in the second
779/// source is positive, copy the corresponding doubleword from the first
780/// source to the destination. If the doubleword in the second source is
781/// zero, clear the corresponding doubleword in the destination.
782///
783/// \headerfile <x86intrin.h>
784///
785/// This intrinsic corresponds to the \c PSIGND instruction.
786///
787/// \param __a
788/// A 64-bit integer vector containing the values to be copied.
789/// \param __b
790/// A 64-bit integer vector containing two control doublewords corresponding
791/// to positions in the destination.
792/// \returns A 64-bit integer vector containing the resultant values.
793static __inline__ __m64 __DEFAULT_FN_ATTRS
794_mm_sign_pi32(__m64 __a, __m64 __b)
795{
796 return __trunc64(__builtin_ia32_psignd128((__v4si)__anyext128(__a),
797 (__v4si)__anyext128(__b)));
798}
799
800#undef __anyext128
801#undef __trunc64
802#undef __DEFAULT_FN_ATTRS
803
804#endif /* __TMMINTRIN_H */
static __inline__ vector float vector float __b
Definition: altivec.h:578
static __inline__ void int __a
Definition: emmintrin.h:4058
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sign_epi16(__m128i __a, __m128i __b)
For each 16-bit integer in the first source operand, perform one of the following actions as specifie...
Definition: tmmintrin.h:688
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_mulhrs_pi16(__m64 __a, __m64 __b)
Multiplies packed 16-bit signed integer values, truncates the 32-bit products to the 18 most signific...
Definition: tmmintrin.h:581
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_hadd_epi32(__m128i __a, __m128i __b)
Horizontally adds the adjacent pairs of values contained in 2 packed 128-bit vectors of [4 x i32].
Definition: tmmintrin.h:228
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_abs_pi16(__m64 __a)
Computes the absolute value of each of the packed 16-bit signed integers in the source operand and st...
Definition: tmmintrin.h:79
#define __anyext128(x)
Definition: tmmintrin.h:26
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_abs_pi8(__m64 __a)
Computes the absolute value of each of the packed 8-bit signed integers in the source operand and sto...
Definition: tmmintrin.h:43
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_hsub_pi32(__m64 __a, __m64 __b)
Horizontally subtracts the adjacent pairs of values contained in 2 packed 64-bit vectors of [2 x i32]...
Definition: tmmintrin.h:422
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_maddubs_pi16(__m64 __a, __m64 __b)
Multiplies corresponding pairs of packed 8-bit unsigned integer values contained in the first source ...
Definition: tmmintrin.h:540
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_hsubs_pi16(__m64 __a, __m64 __b)
Horizontally subtracts, with saturation, the adjacent pairs of values contained in two packed 64-bit ...
Definition: tmmintrin.h:475
#define __DEFAULT_FN_ATTRS
Definition: tmmintrin.h:20
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_hsub_epi32(__m128i __a, __m128i __b)
Horizontally subtracts the adjacent pairs of values contained in 2 packed 128-bit vectors of [4 x i32...
Definition: tmmintrin.h:375
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_abs_epi8(__m128i __a)
Computes the absolute value of each of the packed 8-bit signed integers in the source operand and sto...
Definition: tmmintrin.h:61
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_hadd_pi32(__m64 __a, __m64 __b)
Horizontally adds the adjacent pairs of values contained in 2 packed 64-bit vectors of [2 x i32].
Definition: tmmintrin.h:275
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_sign_pi16(__m64 __a, __m64 __b)
For each 16-bit integer in the first source operand, perform one of the following actions as specifie...
Definition: tmmintrin.h:767
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_mulhrs_epi16(__m128i __a, __m128i __b)
Multiplies packed 16-bit signed integer values, truncates the 32-bit products to the 18 most signific...
Definition: tmmintrin.h:561
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_abs_epi16(__m128i __a)
Computes the absolute value of each of the packed 16-bit signed integers in the source operand and st...
Definition: tmmintrin.h:97
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_sign_pi8(__m64 __a, __m64 __b)
For each 8-bit integer in the first source operand, perform one of the following actions as specified...
Definition: tmmintrin.h:740
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_maddubs_epi16(__m128i __a, __m128i __b)
Multiplies corresponding pairs of packed 8-bit unsigned integer values contained in the first source ...
Definition: tmmintrin.h:510
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_sign_pi32(__m64 __a, __m64 __b)
For each 32-bit integer in the first source operand, perform one of the following actions as specifie...
Definition: tmmintrin.h:794
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sign_epi8(__m128i __a, __m128i __b)
For each 8-bit integer in the first source operand, perform one of the following actions as specified...
Definition: tmmintrin.h:662
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_hsub_epi16(__m128i __a, __m128i __b)
Horizontally subtracts the adjacent pairs of values contained in 2 packed 128-bit vectors of [8 x i16...
Definition: tmmintrin.h:352
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_hsubs_epi16(__m128i __a, __m128i __b)
Horizontally subtracts, with saturation, the adjacent pairs of values contained in two packed 128-bit...
Definition: tmmintrin.h:449
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_hadd_pi16(__m64 __a, __m64 __b)
Horizontally adds the adjacent pairs of values contained in 2 packed 64-bit vectors of [4 x i16].
Definition: tmmintrin.h:251
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_abs_pi32(__m64 __a)
Computes the absolute value of each of the packed 32-bit signed integers in the source operand and st...
Definition: tmmintrin.h:115
#define __trunc64(x)
Definition: tmmintrin.h:24
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_hsub_pi16(__m64 __a, __m64 __b)
Horizontally subtracts the adjacent pairs of values contained in 2 packed 64-bit vectors of [4 x i16]...
Definition: tmmintrin.h:398
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_hadds_epi16(__m128i __a, __m128i __b)
Horizontally adds, with saturation, the adjacent pairs of values contained in two packed 128-bit vect...
Definition: tmmintrin.h:302
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sign_epi32(__m128i __a, __m128i __b)
For each 32-bit integer in the first source operand, perform one of the following actions as specifie...
Definition: tmmintrin.h:714
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_hadd_epi16(__m128i __a, __m128i __b)
Horizontally adds the adjacent pairs of values contained in 2 packed 128-bit vectors of [8 x i16].
Definition: tmmintrin.h:205
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_shuffle_epi8(__m128i __a, __m128i __b)
Copies the 8-bit integers from a 128-bit integer vector to the destination or clears 8-bit values in ...
Definition: tmmintrin.h:608
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_hadds_pi16(__m64 __a, __m64 __b)
Horizontally adds, with saturation, the adjacent pairs of values contained in two packed 64-bit vecto...
Definition: tmmintrin.h:328
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_abs_epi32(__m128i __a)
Computes the absolute value of each of the packed 32-bit signed integers in the source operand and st...
Definition: tmmintrin.h:133
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_shuffle_pi8(__m64 __a, __m64 __b)
Copies the 8-bit integers from a 64-bit integer vector to the destination or clears 8-bit values in t...
Definition: tmmintrin.h:633