1 /*===---- tmmintrin.h - SSSE3 intrinsics -----------------------------------===
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 *===-----------------------------------------------------------------------===
27 #include <pmmintrin.h>
29 /* Define the default attributes for the functions in this file. */
30 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("ssse3"), __min_vector_width__(64)))
31 #define __DEFAULT_FN_ATTRS_MMX __attribute__((__always_inline__, __nodebug__, __target__("mmx,ssse3"), __min_vector_width__(64)))
33 /// Computes the absolute value of each of the packed 8-bit signed
34 /// integers in the source operand and stores the 8-bit unsigned integer
35 /// results in the destination.
37 /// \headerfile <x86intrin.h>
39 /// This intrinsic corresponds to the \c PABSB instruction.
42 /// A 64-bit vector of [8 x i8].
43 /// \returns A 64-bit integer vector containing the absolute values of the
44 /// elements in the operand.
45 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
46 _mm_abs_pi8(__m64 __a)
48 return (__m64)__builtin_ia32_pabsb((__v8qi)__a);
51 /// Computes the absolute value of each of the packed 8-bit signed
52 /// integers in the source operand and stores the 8-bit unsigned integer
53 /// results in the destination.
55 /// \headerfile <x86intrin.h>
57 /// This intrinsic corresponds to the \c VPABSB instruction.
60 /// A 128-bit vector of [16 x i8].
61 /// \returns A 128-bit integer vector containing the absolute values of the
62 /// elements in the operand.
63 static __inline__ __m128i __DEFAULT_FN_ATTRS
64 _mm_abs_epi8(__m128i __a)
66 return (__m128i)__builtin_ia32_pabsb128((__v16qi)__a);
69 /// Computes the absolute value of each of the packed 16-bit signed
70 /// integers in the source operand and stores the 16-bit unsigned integer
71 /// results in the destination.
73 /// \headerfile <x86intrin.h>
75 /// This intrinsic corresponds to the \c PABSW instruction.
78 /// A 64-bit vector of [4 x i16].
79 /// \returns A 64-bit integer vector containing the absolute values of the
80 /// elements in the operand.
81 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
82 _mm_abs_pi16(__m64 __a)
84 return (__m64)__builtin_ia32_pabsw((__v4hi)__a);
87 /// Computes the absolute value of each of the packed 16-bit signed
88 /// integers in the source operand and stores the 16-bit unsigned integer
89 /// results in the destination.
91 /// \headerfile <x86intrin.h>
93 /// This intrinsic corresponds to the \c VPABSW instruction.
96 /// A 128-bit vector of [8 x i16].
97 /// \returns A 128-bit integer vector containing the absolute values of the
98 /// elements in the operand.
99 static __inline__ __m128i __DEFAULT_FN_ATTRS
100 _mm_abs_epi16(__m128i __a)
102 return (__m128i)__builtin_ia32_pabsw128((__v8hi)__a);
105 /// Computes the absolute value of each of the packed 32-bit signed
106 /// integers in the source operand and stores the 32-bit unsigned integer
107 /// results in the destination.
109 /// \headerfile <x86intrin.h>
111 /// This intrinsic corresponds to the \c PABSD instruction.
114 /// A 64-bit vector of [2 x i32].
115 /// \returns A 64-bit integer vector containing the absolute values of the
116 /// elements in the operand.
117 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
118 _mm_abs_pi32(__m64 __a)
120 return (__m64)__builtin_ia32_pabsd((__v2si)__a);
123 /// Computes the absolute value of each of the packed 32-bit signed
124 /// integers in the source operand and stores the 32-bit unsigned integer
125 /// results in the destination.
127 /// \headerfile <x86intrin.h>
129 /// This intrinsic corresponds to the \c VPABSD instruction.
132 /// A 128-bit vector of [4 x i32].
133 /// \returns A 128-bit integer vector containing the absolute values of the
134 /// elements in the operand.
135 static __inline__ __m128i __DEFAULT_FN_ATTRS
136 _mm_abs_epi32(__m128i __a)
138 return (__m128i)__builtin_ia32_pabsd128((__v4si)__a);
141 /// Concatenates the two 128-bit integer vector operands, and
142 /// right-shifts the result by the number of bytes specified in the immediate
145 /// \headerfile <x86intrin.h>
148 /// __m128i _mm_alignr_epi8(__m128i a, __m128i b, const int n);
151 /// This intrinsic corresponds to the \c PALIGNR instruction.
154 /// A 128-bit vector of [16 x i8] containing one of the source operands.
156 /// A 128-bit vector of [16 x i8] containing one of the source operands.
158 /// An immediate operand specifying how many bytes to right-shift the result.
159 /// \returns A 128-bit integer vector containing the concatenated right-shifted
161 #define _mm_alignr_epi8(a, b, n) \
162 (__m128i)__builtin_ia32_palignr128((__v16qi)(__m128i)(a), \
163 (__v16qi)(__m128i)(b), (n))
165 /// Concatenates the two 64-bit integer vector operands, and right-shifts
166 /// the result by the number of bytes specified in the immediate operand.
168 /// \headerfile <x86intrin.h>
171 /// __m64 _mm_alignr_pi8(__m64 a, __m64 b, const int n);
174 /// This intrinsic corresponds to the \c PALIGNR instruction.
177 /// A 64-bit vector of [8 x i8] containing one of the source operands.
179 /// A 64-bit vector of [8 x i8] containing one of the source operands.
181 /// An immediate operand specifying how many bytes to right-shift the result.
182 /// \returns A 64-bit integer vector containing the concatenated right-shifted
184 #define _mm_alignr_pi8(a, b, n) \
185 (__m64)__builtin_ia32_palignr((__v8qi)(__m64)(a), (__v8qi)(__m64)(b), (n))
187 /// Horizontally adds the adjacent pairs of values contained in 2 packed
188 /// 128-bit vectors of [8 x i16].
190 /// \headerfile <x86intrin.h>
192 /// This intrinsic corresponds to the \c VPHADDW instruction.
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
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
202 /// \returns A 128-bit vector of [8 x i16] containing the horizontal sums of
204 static __inline__ __m128i __DEFAULT_FN_ATTRS
205 _mm_hadd_epi16(__m128i __a, __m128i __b)
207 return (__m128i)__builtin_ia32_phaddw128((__v8hi)__a, (__v8hi)__b);
210 /// Horizontally adds the adjacent pairs of values contained in 2 packed
211 /// 128-bit vectors of [4 x i32].
213 /// \headerfile <x86intrin.h>
215 /// This intrinsic corresponds to the \c VPHADDD instruction.
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
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
225 /// \returns A 128-bit vector of [4 x i32] containing the horizontal sums of
227 static __inline__ __m128i __DEFAULT_FN_ATTRS
228 _mm_hadd_epi32(__m128i __a, __m128i __b)
230 return (__m128i)__builtin_ia32_phaddd128((__v4si)__a, (__v4si)__b);
233 /// Horizontally adds the adjacent pairs of values contained in 2 packed
234 /// 64-bit vectors of [4 x i16].
236 /// \headerfile <x86intrin.h>
238 /// This intrinsic corresponds to the \c PHADDW instruction.
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
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
248 /// \returns A 64-bit vector of [4 x i16] containing the horizontal sums of both
250 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
251 _mm_hadd_pi16(__m64 __a, __m64 __b)
253 return (__m64)__builtin_ia32_phaddw((__v4hi)__a, (__v4hi)__b);
256 /// Horizontally adds the adjacent pairs of values contained in 2 packed
257 /// 64-bit vectors of [2 x i32].
259 /// \headerfile <x86intrin.h>
261 /// This intrinsic corresponds to the \c PHADDD instruction.
264 /// A 64-bit vector of [2 x i32] containing one of the source operands. The
265 /// horizontal sums of the values are stored in the lower bits of the
268 /// A 64-bit vector of [2 x i32] containing one of the source operands. The
269 /// horizontal sums of the values are stored in the upper bits of the
271 /// \returns A 64-bit vector of [2 x i32] containing the horizontal sums of both
273 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
274 _mm_hadd_pi32(__m64 __a, __m64 __b)
276 return (__m64)__builtin_ia32_phaddd((__v2si)__a, (__v2si)__b);
279 /// Horizontally adds the adjacent pairs of values contained in 2 packed
280 /// 128-bit vectors of [8 x i16]. Positive sums greater than 0x7FFF are
281 /// saturated to 0x7FFF. Negative sums less than 0x8000 are saturated to
284 /// \headerfile <x86intrin.h>
286 /// This intrinsic corresponds to the \c VPHADDSW instruction.
289 /// A 128-bit vector of [8 x i16] containing one of the source operands. The
290 /// horizontal sums of the values are stored in the lower bits of the
293 /// A 128-bit vector of [8 x i16] containing one of the source operands. The
294 /// horizontal sums of the values are stored in the upper bits of the
296 /// \returns A 128-bit vector of [8 x i16] containing the horizontal saturated
297 /// sums of both operands.
298 static __inline__ __m128i __DEFAULT_FN_ATTRS
299 _mm_hadds_epi16(__m128i __a, __m128i __b)
301 return (__m128i)__builtin_ia32_phaddsw128((__v8hi)__a, (__v8hi)__b);
304 /// Horizontally adds the adjacent pairs of values contained in 2 packed
305 /// 64-bit vectors of [4 x i16]. Positive sums greater than 0x7FFF are
306 /// saturated to 0x7FFF. Negative sums less than 0x8000 are saturated to
309 /// \headerfile <x86intrin.h>
311 /// This intrinsic corresponds to the \c PHADDSW instruction.
314 /// A 64-bit vector of [4 x i16] containing one of the source operands. The
315 /// horizontal sums of the values are stored in the lower bits of the
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 upper bits of the
321 /// \returns A 64-bit vector of [4 x i16] containing the horizontal saturated
322 /// sums of both operands.
323 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
324 _mm_hadds_pi16(__m64 __a, __m64 __b)
326 return (__m64)__builtin_ia32_phaddsw((__v4hi)__a, (__v4hi)__b);
329 /// Horizontally subtracts the adjacent pairs of values contained in 2
330 /// packed 128-bit vectors of [8 x i16].
332 /// \headerfile <x86intrin.h>
334 /// This intrinsic corresponds to the \c VPHSUBW instruction.
337 /// A 128-bit vector of [8 x i16] containing one of the source operands. The
338 /// horizontal differences between the values are stored in the lower bits of
341 /// A 128-bit vector of [8 x i16] containing one of the source operands. The
342 /// horizontal differences between the values are stored in the upper bits of
344 /// \returns A 128-bit vector of [8 x i16] containing the horizontal differences
345 /// of both operands.
346 static __inline__ __m128i __DEFAULT_FN_ATTRS
347 _mm_hsub_epi16(__m128i __a, __m128i __b)
349 return (__m128i)__builtin_ia32_phsubw128((__v8hi)__a, (__v8hi)__b);
352 /// Horizontally subtracts the adjacent pairs of values contained in 2
353 /// packed 128-bit vectors of [4 x i32].
355 /// \headerfile <x86intrin.h>
357 /// This intrinsic corresponds to the \c VPHSUBD instruction.
360 /// A 128-bit vector of [4 x i32] containing one of the source operands. The
361 /// horizontal differences between the values are stored in the lower bits of
364 /// A 128-bit vector of [4 x i32] containing one of the source operands. The
365 /// horizontal differences between the values are stored in the upper bits of
367 /// \returns A 128-bit vector of [4 x i32] containing the horizontal differences
368 /// of both operands.
369 static __inline__ __m128i __DEFAULT_FN_ATTRS
370 _mm_hsub_epi32(__m128i __a, __m128i __b)
372 return (__m128i)__builtin_ia32_phsubd128((__v4si)__a, (__v4si)__b);
375 /// Horizontally subtracts the adjacent pairs of values contained in 2
376 /// packed 64-bit vectors of [4 x i16].
378 /// \headerfile <x86intrin.h>
380 /// This intrinsic corresponds to the \c PHSUBW instruction.
383 /// A 64-bit vector of [4 x i16] containing one of the source operands. The
384 /// horizontal differences between the values are stored in the lower bits of
387 /// A 64-bit vector of [4 x i16] containing one of the source operands. The
388 /// horizontal differences between the values are stored in the upper bits of
390 /// \returns A 64-bit vector of [4 x i16] containing the horizontal differences
391 /// of both operands.
392 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
393 _mm_hsub_pi16(__m64 __a, __m64 __b)
395 return (__m64)__builtin_ia32_phsubw((__v4hi)__a, (__v4hi)__b);
398 /// Horizontally subtracts the adjacent pairs of values contained in 2
399 /// packed 64-bit vectors of [2 x i32].
401 /// \headerfile <x86intrin.h>
403 /// This intrinsic corresponds to the \c PHSUBD instruction.
406 /// A 64-bit vector of [2 x i32] containing one of the source operands. The
407 /// horizontal differences between the values are stored in the lower bits of
410 /// A 64-bit vector of [2 x i32] containing one of the source operands. The
411 /// horizontal differences between the values are stored in the upper bits of
413 /// \returns A 64-bit vector of [2 x i32] containing the horizontal differences
414 /// of both operands.
415 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
416 _mm_hsub_pi32(__m64 __a, __m64 __b)
418 return (__m64)__builtin_ia32_phsubd((__v2si)__a, (__v2si)__b);
421 /// Horizontally subtracts the adjacent pairs of values contained in 2
422 /// packed 128-bit vectors of [8 x i16]. Positive differences greater than
423 /// 0x7FFF are saturated to 0x7FFF. Negative differences less than 0x8000 are
424 /// saturated to 0x8000.
426 /// \headerfile <x86intrin.h>
428 /// This intrinsic corresponds to the \c VPHSUBSW instruction.
431 /// A 128-bit vector of [8 x i16] containing one of the source operands. The
432 /// horizontal differences between the values are stored in the lower bits of
435 /// A 128-bit vector of [8 x i16] containing one of the source operands. The
436 /// horizontal differences between the values are stored in the upper bits of
438 /// \returns A 128-bit vector of [8 x i16] containing the horizontal saturated
439 /// differences of both operands.
440 static __inline__ __m128i __DEFAULT_FN_ATTRS
441 _mm_hsubs_epi16(__m128i __a, __m128i __b)
443 return (__m128i)__builtin_ia32_phsubsw128((__v8hi)__a, (__v8hi)__b);
446 /// Horizontally subtracts the adjacent pairs of values contained in 2
447 /// packed 64-bit vectors of [4 x i16]. Positive differences greater than
448 /// 0x7FFF are saturated to 0x7FFF. Negative differences less than 0x8000 are
449 /// saturated to 0x8000.
451 /// \headerfile <x86intrin.h>
453 /// This intrinsic corresponds to the \c PHSUBSW instruction.
456 /// A 64-bit vector of [4 x i16] containing one of the source operands. The
457 /// horizontal differences between the values are stored in the lower bits of
460 /// A 64-bit vector of [4 x i16] containing one of the source operands. The
461 /// horizontal differences between the values are stored in the upper bits of
463 /// \returns A 64-bit vector of [4 x i16] containing the horizontal saturated
464 /// differences of both operands.
465 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
466 _mm_hsubs_pi16(__m64 __a, __m64 __b)
468 return (__m64)__builtin_ia32_phsubsw((__v4hi)__a, (__v4hi)__b);
471 /// Multiplies corresponding pairs of packed 8-bit unsigned integer
472 /// values contained in the first source operand and packed 8-bit signed
473 /// integer values contained in the second source operand, adds pairs of
474 /// contiguous products with signed saturation, and writes the 16-bit sums to
475 /// the corresponding bits in the destination.
477 /// For example, bits [7:0] of both operands are multiplied, bits [15:8] of
478 /// both operands are multiplied, and the sum of both results is written to
479 /// bits [15:0] of the destination.
481 /// \headerfile <x86intrin.h>
483 /// This intrinsic corresponds to the \c VPMADDUBSW instruction.
486 /// A 128-bit integer vector containing the first source operand.
488 /// A 128-bit integer vector containing the second source operand.
489 /// \returns A 128-bit integer vector containing the sums of products of both
491 /// \a R0 := (\a __a0 * \a __b0) + (\a __a1 * \a __b1) \n
492 /// \a R1 := (\a __a2 * \a __b2) + (\a __a3 * \a __b3) \n
493 /// \a R2 := (\a __a4 * \a __b4) + (\a __a5 * \a __b5) \n
494 /// \a R3 := (\a __a6 * \a __b6) + (\a __a7 * \a __b7) \n
495 /// \a R4 := (\a __a8 * \a __b8) + (\a __a9 * \a __b9) \n
496 /// \a R5 := (\a __a10 * \a __b10) + (\a __a11 * \a __b11) \n
497 /// \a R6 := (\a __a12 * \a __b12) + (\a __a13 * \a __b13) \n
498 /// \a R7 := (\a __a14 * \a __b14) + (\a __a15 * \a __b15)
499 static __inline__ __m128i __DEFAULT_FN_ATTRS
500 _mm_maddubs_epi16(__m128i __a, __m128i __b)
502 return (__m128i)__builtin_ia32_pmaddubsw128((__v16qi)__a, (__v16qi)__b);
505 /// Multiplies corresponding pairs of packed 8-bit unsigned integer
506 /// values contained in the first source operand and packed 8-bit signed
507 /// integer values contained in the second source operand, adds pairs of
508 /// contiguous products with signed saturation, and writes the 16-bit sums to
509 /// the corresponding bits in the destination.
511 /// For example, bits [7:0] of both operands are multiplied, bits [15:8] of
512 /// both operands are multiplied, and the sum of both results is written to
513 /// bits [15:0] of the destination.
515 /// \headerfile <x86intrin.h>
517 /// This intrinsic corresponds to the \c PMADDUBSW instruction.
520 /// A 64-bit integer vector containing the first source operand.
522 /// A 64-bit integer vector containing the second source operand.
523 /// \returns A 64-bit integer vector containing the sums of products of both
525 /// \a R0 := (\a __a0 * \a __b0) + (\a __a1 * \a __b1) \n
526 /// \a R1 := (\a __a2 * \a __b2) + (\a __a3 * \a __b3) \n
527 /// \a R2 := (\a __a4 * \a __b4) + (\a __a5 * \a __b5) \n
528 /// \a R3 := (\a __a6 * \a __b6) + (\a __a7 * \a __b7)
529 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
530 _mm_maddubs_pi16(__m64 __a, __m64 __b)
532 return (__m64)__builtin_ia32_pmaddubsw((__v8qi)__a, (__v8qi)__b);
535 /// Multiplies packed 16-bit signed integer values, truncates the 32-bit
536 /// products to the 18 most significant bits by right-shifting, rounds the
537 /// truncated value by adding 1, and writes bits [16:1] to the destination.
539 /// \headerfile <x86intrin.h>
541 /// This intrinsic corresponds to the \c VPMULHRSW instruction.
544 /// A 128-bit vector of [8 x i16] containing one of the source operands.
546 /// A 128-bit vector of [8 x i16] containing one of the source operands.
547 /// \returns A 128-bit vector of [8 x i16] containing the rounded and scaled
548 /// products of both operands.
549 static __inline__ __m128i __DEFAULT_FN_ATTRS
550 _mm_mulhrs_epi16(__m128i __a, __m128i __b)
552 return (__m128i)__builtin_ia32_pmulhrsw128((__v8hi)__a, (__v8hi)__b);
555 /// Multiplies packed 16-bit signed integer values, truncates the 32-bit
556 /// products to the 18 most significant bits by right-shifting, rounds the
557 /// truncated value by adding 1, and writes bits [16:1] to the destination.
559 /// \headerfile <x86intrin.h>
561 /// This intrinsic corresponds to the \c PMULHRSW instruction.
564 /// A 64-bit vector of [4 x i16] containing one of the source operands.
566 /// A 64-bit vector of [4 x i16] containing one of the source operands.
567 /// \returns A 64-bit vector of [4 x i16] containing the rounded and scaled
568 /// products of both operands.
569 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
570 _mm_mulhrs_pi16(__m64 __a, __m64 __b)
572 return (__m64)__builtin_ia32_pmulhrsw((__v4hi)__a, (__v4hi)__b);
575 /// Copies the 8-bit integers from a 128-bit integer vector to the
576 /// destination or clears 8-bit values in the destination, as specified by
577 /// the second source operand.
579 /// \headerfile <x86intrin.h>
581 /// This intrinsic corresponds to the \c VPSHUFB instruction.
584 /// A 128-bit integer vector containing the values to be copied.
586 /// A 128-bit integer vector containing control bytes corresponding to
587 /// positions in the destination:
589 /// 1: Clear the corresponding byte in the destination. \n
590 /// 0: Copy the selected source byte to the corresponding byte in the
592 /// Bits [6:4] Reserved. \n
593 /// Bits [3:0] select the source byte to be copied.
594 /// \returns A 128-bit integer vector containing the copied or cleared values.
595 static __inline__ __m128i __DEFAULT_FN_ATTRS
596 _mm_shuffle_epi8(__m128i __a, __m128i __b)
598 return (__m128i)__builtin_ia32_pshufb128((__v16qi)__a, (__v16qi)__b);
601 /// Copies the 8-bit integers from a 64-bit integer vector to the
602 /// destination or clears 8-bit values in the destination, as specified by
603 /// the second source operand.
605 /// \headerfile <x86intrin.h>
607 /// This intrinsic corresponds to the \c PSHUFB instruction.
610 /// A 64-bit integer vector containing the values to be copied.
612 /// A 64-bit integer vector containing control bytes corresponding to
613 /// positions in the destination:
615 /// 1: Clear the corresponding byte in the destination. \n
616 /// 0: Copy the selected source byte to the corresponding byte in the
618 /// Bits [3:0] select the source byte to be copied.
619 /// \returns A 64-bit integer vector containing the copied or cleared values.
620 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
621 _mm_shuffle_pi8(__m64 __a, __m64 __b)
623 return (__m64)__builtin_ia32_pshufb((__v8qi)__a, (__v8qi)__b);
626 /// For each 8-bit integer in the first source operand, perform one of
627 /// the following actions as specified by the second source operand.
629 /// If the byte in the second source is negative, calculate the two's
630 /// complement of the corresponding byte in the first source, and write that
631 /// value to the destination. If the byte in the second source is positive,
632 /// copy the corresponding byte from the first source to the destination. If
633 /// the byte in the second source is zero, clear the corresponding byte in
636 /// \headerfile <x86intrin.h>
638 /// This intrinsic corresponds to the \c VPSIGNB instruction.
641 /// A 128-bit integer vector containing the values to be copied.
643 /// A 128-bit integer vector containing control bytes corresponding to
644 /// positions in the destination.
645 /// \returns A 128-bit integer vector containing the resultant values.
646 static __inline__ __m128i __DEFAULT_FN_ATTRS
647 _mm_sign_epi8(__m128i __a, __m128i __b)
649 return (__m128i)__builtin_ia32_psignb128((__v16qi)__a, (__v16qi)__b);
652 /// For each 16-bit integer in the first source operand, perform one of
653 /// the following actions as specified by the second source operand.
655 /// If the word in the second source is negative, calculate the two's
656 /// complement of the corresponding word in the first source, and write that
657 /// value to the destination. If the word in the second source is positive,
658 /// copy the corresponding word from the first source to the destination. If
659 /// the word in the second source is zero, clear the corresponding word in
662 /// \headerfile <x86intrin.h>
664 /// This intrinsic corresponds to the \c VPSIGNW instruction.
667 /// A 128-bit integer vector containing the values to be copied.
669 /// A 128-bit integer vector containing control words corresponding to
670 /// positions in the destination.
671 /// \returns A 128-bit integer vector containing the resultant values.
672 static __inline__ __m128i __DEFAULT_FN_ATTRS
673 _mm_sign_epi16(__m128i __a, __m128i __b)
675 return (__m128i)__builtin_ia32_psignw128((__v8hi)__a, (__v8hi)__b);
678 /// For each 32-bit integer in the first source operand, perform one of
679 /// the following actions as specified by the second source operand.
681 /// If the doubleword in the second source is negative, calculate the two's
682 /// complement of the corresponding word in the first source, and write that
683 /// value to the destination. If the doubleword in the second source is
684 /// positive, copy the corresponding word from the first source to the
685 /// destination. If the doubleword in the second source is zero, clear the
686 /// corresponding word in the destination.
688 /// \headerfile <x86intrin.h>
690 /// This intrinsic corresponds to the \c VPSIGND instruction.
693 /// A 128-bit integer vector containing the values to be copied.
695 /// A 128-bit integer vector containing control doublewords corresponding to
696 /// positions in the destination.
697 /// \returns A 128-bit integer vector containing the resultant values.
698 static __inline__ __m128i __DEFAULT_FN_ATTRS
699 _mm_sign_epi32(__m128i __a, __m128i __b)
701 return (__m128i)__builtin_ia32_psignd128((__v4si)__a, (__v4si)__b);
704 /// For each 8-bit integer in the first source operand, perform one of
705 /// the following actions as specified by the second source operand.
707 /// If the byte in the second source is negative, calculate the two's
708 /// complement of the corresponding byte in the first source, and write that
709 /// value to the destination. If the byte in the second source is positive,
710 /// copy the corresponding byte from the first source to the destination. If
711 /// the byte in the second source is zero, clear the corresponding byte in
714 /// \headerfile <x86intrin.h>
716 /// This intrinsic corresponds to the \c PSIGNB instruction.
719 /// A 64-bit integer vector containing the values to be copied.
721 /// A 64-bit integer vector containing control bytes corresponding to
722 /// positions in the destination.
723 /// \returns A 64-bit integer vector containing the resultant values.
724 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
725 _mm_sign_pi8(__m64 __a, __m64 __b)
727 return (__m64)__builtin_ia32_psignb((__v8qi)__a, (__v8qi)__b);
730 /// For each 16-bit integer in the first source operand, perform one of
731 /// the following actions as specified by the second source operand.
733 /// If the word in the second source is negative, calculate the two's
734 /// complement of the corresponding word in the first source, and write that
735 /// value to the destination. If the word in the second source is positive,
736 /// copy the corresponding word from the first source to the destination. If
737 /// the word in the second source is zero, clear the corresponding word in
740 /// \headerfile <x86intrin.h>
742 /// This intrinsic corresponds to the \c PSIGNW instruction.
745 /// A 64-bit integer vector containing the values to be copied.
747 /// A 64-bit integer vector containing control words corresponding to
748 /// positions in the destination.
749 /// \returns A 64-bit integer vector containing the resultant values.
750 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
751 _mm_sign_pi16(__m64 __a, __m64 __b)
753 return (__m64)__builtin_ia32_psignw((__v4hi)__a, (__v4hi)__b);
756 /// For each 32-bit integer in the first source operand, perform one of
757 /// the following actions as specified by the second source operand.
759 /// If the doubleword in the second source is negative, calculate the two's
760 /// complement of the corresponding doubleword in the first source, and
761 /// write that value to the destination. If the doubleword in the second
762 /// source is positive, copy the corresponding doubleword from the first
763 /// source to the destination. If the doubleword in the second source is
764 /// zero, clear the corresponding doubleword in the destination.
766 /// \headerfile <x86intrin.h>
768 /// This intrinsic corresponds to the \c PSIGND instruction.
771 /// A 64-bit integer vector containing the values to be copied.
773 /// A 64-bit integer vector containing two control doublewords corresponding
774 /// to positions in the destination.
775 /// \returns A 64-bit integer vector containing the resultant values.
776 static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
777 _mm_sign_pi32(__m64 __a, __m64 __b)
779 return (__m64)__builtin_ia32_psignd((__v2si)__a, (__v2si)__b);
782 #undef __DEFAULT_FN_ATTRS
783 #undef __DEFAULT_FN_ATTRS_MMX
785 #endif /* __TMMINTRIN_H */