Import GCC-8 to a new vendor branch
[dragonfly.git] / contrib / gcc-8.0 / gcc / config / i386 / xmmintrin.h
blobf64f3f74a0b23c5a34b7dd9f169350d477ad28ca
1 /* Copyright (C) 2002-2018 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 /* Implemented from the specification included in the Intel C++ Compiler
25 User Guide and Reference, version 9.0. */
27 #ifndef _XMMINTRIN_H_INCLUDED
28 #define _XMMINTRIN_H_INCLUDED
30 /* We need type definitions from the MMX header file. */
31 #include <mmintrin.h>
33 /* Get _mm_malloc () and _mm_free (). */
34 #include <mm_malloc.h>
36 /* Constants for use with _mm_prefetch. */
37 enum _mm_hint
39 /* _MM_HINT_ET is _MM_HINT_T with set 3rd bit. */
40 _MM_HINT_ET0 = 7,
41 _MM_HINT_ET1 = 6,
42 _MM_HINT_T0 = 3,
43 _MM_HINT_T1 = 2,
44 _MM_HINT_T2 = 1,
45 _MM_HINT_NTA = 0
48 /* Loads one cache line from address P to a location "closer" to the
49 processor. The selector I specifies the type of prefetch operation. */
50 #ifdef __OPTIMIZE__
51 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
52 _mm_prefetch (const void *__P, enum _mm_hint __I)
54 __builtin_prefetch (__P, (__I & 0x4) >> 2, __I & 0x3);
56 #else
57 #define _mm_prefetch(P, I) \
58 __builtin_prefetch ((P), ((I & 0x4) >> 2), (I & 0x3))
59 #endif
61 #ifndef __SSE__
62 #pragma GCC push_options
63 #pragma GCC target("sse")
64 #define __DISABLE_SSE__
65 #endif /* __SSE__ */
67 /* The Intel API is flexible enough that we must allow aliasing with other
68 vector types, and their scalar components. */
69 typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
71 /* Unaligned version of the same type. */
72 typedef float __m128_u __attribute__ ((__vector_size__ (16), __may_alias__, __aligned__ (1)));
74 /* Internal data types for implementing the intrinsics. */
75 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
77 /* Create a selector for use with the SHUFPS instruction. */
78 #define _MM_SHUFFLE(fp3,fp2,fp1,fp0) \
79 (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | (fp0))
81 /* Bits in the MXCSR. */
82 #define _MM_EXCEPT_MASK 0x003f
83 #define _MM_EXCEPT_INVALID 0x0001
84 #define _MM_EXCEPT_DENORM 0x0002
85 #define _MM_EXCEPT_DIV_ZERO 0x0004
86 #define _MM_EXCEPT_OVERFLOW 0x0008
87 #define _MM_EXCEPT_UNDERFLOW 0x0010
88 #define _MM_EXCEPT_INEXACT 0x0020
90 #define _MM_MASK_MASK 0x1f80
91 #define _MM_MASK_INVALID 0x0080
92 #define _MM_MASK_DENORM 0x0100
93 #define _MM_MASK_DIV_ZERO 0x0200
94 #define _MM_MASK_OVERFLOW 0x0400
95 #define _MM_MASK_UNDERFLOW 0x0800
96 #define _MM_MASK_INEXACT 0x1000
98 #define _MM_ROUND_MASK 0x6000
99 #define _MM_ROUND_NEAREST 0x0000
100 #define _MM_ROUND_DOWN 0x2000
101 #define _MM_ROUND_UP 0x4000
102 #define _MM_ROUND_TOWARD_ZERO 0x6000
104 #define _MM_FLUSH_ZERO_MASK 0x8000
105 #define _MM_FLUSH_ZERO_ON 0x8000
106 #define _MM_FLUSH_ZERO_OFF 0x0000
108 /* Create an undefined vector. */
109 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
110 _mm_undefined_ps (void)
112 __m128 __Y = __Y;
113 return __Y;
116 /* Create a vector of zeros. */
117 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
118 _mm_setzero_ps (void)
120 return __extension__ (__m128){ 0.0f, 0.0f, 0.0f, 0.0f };
123 /* Perform the respective operation on the lower SPFP (single-precision
124 floating-point) values of A and B; the upper three SPFP values are
125 passed through from A. */
127 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
128 _mm_add_ss (__m128 __A, __m128 __B)
130 return (__m128) __builtin_ia32_addss ((__v4sf)__A, (__v4sf)__B);
133 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
134 _mm_sub_ss (__m128 __A, __m128 __B)
136 return (__m128) __builtin_ia32_subss ((__v4sf)__A, (__v4sf)__B);
139 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
140 _mm_mul_ss (__m128 __A, __m128 __B)
142 return (__m128) __builtin_ia32_mulss ((__v4sf)__A, (__v4sf)__B);
145 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
146 _mm_div_ss (__m128 __A, __m128 __B)
148 return (__m128) __builtin_ia32_divss ((__v4sf)__A, (__v4sf)__B);
151 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
152 _mm_sqrt_ss (__m128 __A)
154 return (__m128) __builtin_ia32_sqrtss ((__v4sf)__A);
157 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
158 _mm_rcp_ss (__m128 __A)
160 return (__m128) __builtin_ia32_rcpss ((__v4sf)__A);
163 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
164 _mm_rsqrt_ss (__m128 __A)
166 return (__m128) __builtin_ia32_rsqrtss ((__v4sf)__A);
169 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
170 _mm_min_ss (__m128 __A, __m128 __B)
172 return (__m128) __builtin_ia32_minss ((__v4sf)__A, (__v4sf)__B);
175 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
176 _mm_max_ss (__m128 __A, __m128 __B)
178 return (__m128) __builtin_ia32_maxss ((__v4sf)__A, (__v4sf)__B);
181 /* Perform the respective operation on the four SPFP values in A and B. */
183 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
184 _mm_add_ps (__m128 __A, __m128 __B)
186 return (__m128) ((__v4sf)__A + (__v4sf)__B);
189 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
190 _mm_sub_ps (__m128 __A, __m128 __B)
192 return (__m128) ((__v4sf)__A - (__v4sf)__B);
195 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
196 _mm_mul_ps (__m128 __A, __m128 __B)
198 return (__m128) ((__v4sf)__A * (__v4sf)__B);
201 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
202 _mm_div_ps (__m128 __A, __m128 __B)
204 return (__m128) ((__v4sf)__A / (__v4sf)__B);
207 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
208 _mm_sqrt_ps (__m128 __A)
210 return (__m128) __builtin_ia32_sqrtps ((__v4sf)__A);
213 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
214 _mm_rcp_ps (__m128 __A)
216 return (__m128) __builtin_ia32_rcpps ((__v4sf)__A);
219 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
220 _mm_rsqrt_ps (__m128 __A)
222 return (__m128) __builtin_ia32_rsqrtps ((__v4sf)__A);
225 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
226 _mm_min_ps (__m128 __A, __m128 __B)
228 return (__m128) __builtin_ia32_minps ((__v4sf)__A, (__v4sf)__B);
231 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
232 _mm_max_ps (__m128 __A, __m128 __B)
234 return (__m128) __builtin_ia32_maxps ((__v4sf)__A, (__v4sf)__B);
237 /* Perform logical bit-wise operations on 128-bit values. */
239 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
240 _mm_and_ps (__m128 __A, __m128 __B)
242 return __builtin_ia32_andps (__A, __B);
245 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
246 _mm_andnot_ps (__m128 __A, __m128 __B)
248 return __builtin_ia32_andnps (__A, __B);
251 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
252 _mm_or_ps (__m128 __A, __m128 __B)
254 return __builtin_ia32_orps (__A, __B);
257 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
258 _mm_xor_ps (__m128 __A, __m128 __B)
260 return __builtin_ia32_xorps (__A, __B);
263 /* Perform a comparison on the lower SPFP values of A and B. If the
264 comparison is true, place a mask of all ones in the result, otherwise a
265 mask of zeros. The upper three SPFP values are passed through from A. */
267 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
268 _mm_cmpeq_ss (__m128 __A, __m128 __B)
270 return (__m128) __builtin_ia32_cmpeqss ((__v4sf)__A, (__v4sf)__B);
273 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
274 _mm_cmplt_ss (__m128 __A, __m128 __B)
276 return (__m128) __builtin_ia32_cmpltss ((__v4sf)__A, (__v4sf)__B);
279 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
280 _mm_cmple_ss (__m128 __A, __m128 __B)
282 return (__m128) __builtin_ia32_cmpless ((__v4sf)__A, (__v4sf)__B);
285 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
286 _mm_cmpgt_ss (__m128 __A, __m128 __B)
288 return (__m128) __builtin_ia32_movss ((__v4sf) __A,
289 (__v4sf)
290 __builtin_ia32_cmpltss ((__v4sf) __B,
291 (__v4sf)
292 __A));
295 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
296 _mm_cmpge_ss (__m128 __A, __m128 __B)
298 return (__m128) __builtin_ia32_movss ((__v4sf) __A,
299 (__v4sf)
300 __builtin_ia32_cmpless ((__v4sf) __B,
301 (__v4sf)
302 __A));
305 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
306 _mm_cmpneq_ss (__m128 __A, __m128 __B)
308 return (__m128) __builtin_ia32_cmpneqss ((__v4sf)__A, (__v4sf)__B);
311 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
312 _mm_cmpnlt_ss (__m128 __A, __m128 __B)
314 return (__m128) __builtin_ia32_cmpnltss ((__v4sf)__A, (__v4sf)__B);
317 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
318 _mm_cmpnle_ss (__m128 __A, __m128 __B)
320 return (__m128) __builtin_ia32_cmpnless ((__v4sf)__A, (__v4sf)__B);
323 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
324 _mm_cmpngt_ss (__m128 __A, __m128 __B)
326 return (__m128) __builtin_ia32_movss ((__v4sf) __A,
327 (__v4sf)
328 __builtin_ia32_cmpnltss ((__v4sf) __B,
329 (__v4sf)
330 __A));
333 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
334 _mm_cmpnge_ss (__m128 __A, __m128 __B)
336 return (__m128) __builtin_ia32_movss ((__v4sf) __A,
337 (__v4sf)
338 __builtin_ia32_cmpnless ((__v4sf) __B,
339 (__v4sf)
340 __A));
343 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
344 _mm_cmpord_ss (__m128 __A, __m128 __B)
346 return (__m128) __builtin_ia32_cmpordss ((__v4sf)__A, (__v4sf)__B);
349 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
350 _mm_cmpunord_ss (__m128 __A, __m128 __B)
352 return (__m128) __builtin_ia32_cmpunordss ((__v4sf)__A, (__v4sf)__B);
355 /* Perform a comparison on the four SPFP values of A and B. For each
356 element, if the comparison is true, place a mask of all ones in the
357 result, otherwise a mask of zeros. */
359 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
360 _mm_cmpeq_ps (__m128 __A, __m128 __B)
362 return (__m128) __builtin_ia32_cmpeqps ((__v4sf)__A, (__v4sf)__B);
365 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
366 _mm_cmplt_ps (__m128 __A, __m128 __B)
368 return (__m128) __builtin_ia32_cmpltps ((__v4sf)__A, (__v4sf)__B);
371 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
372 _mm_cmple_ps (__m128 __A, __m128 __B)
374 return (__m128) __builtin_ia32_cmpleps ((__v4sf)__A, (__v4sf)__B);
377 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
378 _mm_cmpgt_ps (__m128 __A, __m128 __B)
380 return (__m128) __builtin_ia32_cmpgtps ((__v4sf)__A, (__v4sf)__B);
383 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
384 _mm_cmpge_ps (__m128 __A, __m128 __B)
386 return (__m128) __builtin_ia32_cmpgeps ((__v4sf)__A, (__v4sf)__B);
389 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
390 _mm_cmpneq_ps (__m128 __A, __m128 __B)
392 return (__m128) __builtin_ia32_cmpneqps ((__v4sf)__A, (__v4sf)__B);
395 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
396 _mm_cmpnlt_ps (__m128 __A, __m128 __B)
398 return (__m128) __builtin_ia32_cmpnltps ((__v4sf)__A, (__v4sf)__B);
401 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
402 _mm_cmpnle_ps (__m128 __A, __m128 __B)
404 return (__m128) __builtin_ia32_cmpnleps ((__v4sf)__A, (__v4sf)__B);
407 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
408 _mm_cmpngt_ps (__m128 __A, __m128 __B)
410 return (__m128) __builtin_ia32_cmpngtps ((__v4sf)__A, (__v4sf)__B);
413 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
414 _mm_cmpnge_ps (__m128 __A, __m128 __B)
416 return (__m128) __builtin_ia32_cmpngeps ((__v4sf)__A, (__v4sf)__B);
419 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
420 _mm_cmpord_ps (__m128 __A, __m128 __B)
422 return (__m128) __builtin_ia32_cmpordps ((__v4sf)__A, (__v4sf)__B);
425 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
426 _mm_cmpunord_ps (__m128 __A, __m128 __B)
428 return (__m128) __builtin_ia32_cmpunordps ((__v4sf)__A, (__v4sf)__B);
431 /* Compare the lower SPFP values of A and B and return 1 if true
432 and 0 if false. */
434 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
435 _mm_comieq_ss (__m128 __A, __m128 __B)
437 return __builtin_ia32_comieq ((__v4sf)__A, (__v4sf)__B);
440 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
441 _mm_comilt_ss (__m128 __A, __m128 __B)
443 return __builtin_ia32_comilt ((__v4sf)__A, (__v4sf)__B);
446 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
447 _mm_comile_ss (__m128 __A, __m128 __B)
449 return __builtin_ia32_comile ((__v4sf)__A, (__v4sf)__B);
452 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
453 _mm_comigt_ss (__m128 __A, __m128 __B)
455 return __builtin_ia32_comigt ((__v4sf)__A, (__v4sf)__B);
458 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
459 _mm_comige_ss (__m128 __A, __m128 __B)
461 return __builtin_ia32_comige ((__v4sf)__A, (__v4sf)__B);
464 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
465 _mm_comineq_ss (__m128 __A, __m128 __B)
467 return __builtin_ia32_comineq ((__v4sf)__A, (__v4sf)__B);
470 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
471 _mm_ucomieq_ss (__m128 __A, __m128 __B)
473 return __builtin_ia32_ucomieq ((__v4sf)__A, (__v4sf)__B);
476 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
477 _mm_ucomilt_ss (__m128 __A, __m128 __B)
479 return __builtin_ia32_ucomilt ((__v4sf)__A, (__v4sf)__B);
482 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
483 _mm_ucomile_ss (__m128 __A, __m128 __B)
485 return __builtin_ia32_ucomile ((__v4sf)__A, (__v4sf)__B);
488 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
489 _mm_ucomigt_ss (__m128 __A, __m128 __B)
491 return __builtin_ia32_ucomigt ((__v4sf)__A, (__v4sf)__B);
494 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
495 _mm_ucomige_ss (__m128 __A, __m128 __B)
497 return __builtin_ia32_ucomige ((__v4sf)__A, (__v4sf)__B);
500 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
501 _mm_ucomineq_ss (__m128 __A, __m128 __B)
503 return __builtin_ia32_ucomineq ((__v4sf)__A, (__v4sf)__B);
506 /* Convert the lower SPFP value to a 32-bit integer according to the current
507 rounding mode. */
508 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
509 _mm_cvtss_si32 (__m128 __A)
511 return __builtin_ia32_cvtss2si ((__v4sf) __A);
514 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
515 _mm_cvt_ss2si (__m128 __A)
517 return _mm_cvtss_si32 (__A);
520 #ifdef __x86_64__
521 /* Convert the lower SPFP value to a 32-bit integer according to the
522 current rounding mode. */
524 /* Intel intrinsic. */
525 extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
526 _mm_cvtss_si64 (__m128 __A)
528 return __builtin_ia32_cvtss2si64 ((__v4sf) __A);
531 /* Microsoft intrinsic. */
532 extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
533 _mm_cvtss_si64x (__m128 __A)
535 return __builtin_ia32_cvtss2si64 ((__v4sf) __A);
537 #endif
539 /* Convert the two lower SPFP values to 32-bit integers according to the
540 current rounding mode. Return the integers in packed form. */
541 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
542 _mm_cvtps_pi32 (__m128 __A)
544 return (__m64) __builtin_ia32_cvtps2pi ((__v4sf) __A);
547 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
548 _mm_cvt_ps2pi (__m128 __A)
550 return _mm_cvtps_pi32 (__A);
553 /* Truncate the lower SPFP value to a 32-bit integer. */
554 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
555 _mm_cvttss_si32 (__m128 __A)
557 return __builtin_ia32_cvttss2si ((__v4sf) __A);
560 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
561 _mm_cvtt_ss2si (__m128 __A)
563 return _mm_cvttss_si32 (__A);
566 #ifdef __x86_64__
567 /* Truncate the lower SPFP value to a 32-bit integer. */
569 /* Intel intrinsic. */
570 extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
571 _mm_cvttss_si64 (__m128 __A)
573 return __builtin_ia32_cvttss2si64 ((__v4sf) __A);
576 /* Microsoft intrinsic. */
577 extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
578 _mm_cvttss_si64x (__m128 __A)
580 return __builtin_ia32_cvttss2si64 ((__v4sf) __A);
582 #endif
584 /* Truncate the two lower SPFP values to 32-bit integers. Return the
585 integers in packed form. */
586 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
587 _mm_cvttps_pi32 (__m128 __A)
589 return (__m64) __builtin_ia32_cvttps2pi ((__v4sf) __A);
592 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
593 _mm_cvtt_ps2pi (__m128 __A)
595 return _mm_cvttps_pi32 (__A);
598 /* Convert B to a SPFP value and insert it as element zero in A. */
599 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
600 _mm_cvtsi32_ss (__m128 __A, int __B)
602 return (__m128) __builtin_ia32_cvtsi2ss ((__v4sf) __A, __B);
605 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
606 _mm_cvt_si2ss (__m128 __A, int __B)
608 return _mm_cvtsi32_ss (__A, __B);
611 #ifdef __x86_64__
612 /* Convert B to a SPFP value and insert it as element zero in A. */
614 /* Intel intrinsic. */
615 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
616 _mm_cvtsi64_ss (__m128 __A, long long __B)
618 return (__m128) __builtin_ia32_cvtsi642ss ((__v4sf) __A, __B);
621 /* Microsoft intrinsic. */
622 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
623 _mm_cvtsi64x_ss (__m128 __A, long long __B)
625 return (__m128) __builtin_ia32_cvtsi642ss ((__v4sf) __A, __B);
627 #endif
629 /* Convert the two 32-bit values in B to SPFP form and insert them
630 as the two lower elements in A. */
631 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
632 _mm_cvtpi32_ps (__m128 __A, __m64 __B)
634 return (__m128) __builtin_ia32_cvtpi2ps ((__v4sf) __A, (__v2si)__B);
637 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
638 _mm_cvt_pi2ps (__m128 __A, __m64 __B)
640 return _mm_cvtpi32_ps (__A, __B);
643 /* Convert the four signed 16-bit values in A to SPFP form. */
644 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
645 _mm_cvtpi16_ps (__m64 __A)
647 __v4hi __sign;
648 __v2si __hisi, __losi;
649 __v4sf __zero, __ra, __rb;
651 /* This comparison against zero gives us a mask that can be used to
652 fill in the missing sign bits in the unpack operations below, so
653 that we get signed values after unpacking. */
654 __sign = __builtin_ia32_pcmpgtw ((__v4hi)0LL, (__v4hi)__A);
656 /* Convert the four words to doublewords. */
657 __losi = (__v2si) __builtin_ia32_punpcklwd ((__v4hi)__A, __sign);
658 __hisi = (__v2si) __builtin_ia32_punpckhwd ((__v4hi)__A, __sign);
660 /* Convert the doublewords to floating point two at a time. */
661 __zero = (__v4sf) _mm_setzero_ps ();
662 __ra = __builtin_ia32_cvtpi2ps (__zero, __losi);
663 __rb = __builtin_ia32_cvtpi2ps (__ra, __hisi);
665 return (__m128) __builtin_ia32_movlhps (__ra, __rb);
668 /* Convert the four unsigned 16-bit values in A to SPFP form. */
669 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
670 _mm_cvtpu16_ps (__m64 __A)
672 __v2si __hisi, __losi;
673 __v4sf __zero, __ra, __rb;
675 /* Convert the four words to doublewords. */
676 __losi = (__v2si) __builtin_ia32_punpcklwd ((__v4hi)__A, (__v4hi)0LL);
677 __hisi = (__v2si) __builtin_ia32_punpckhwd ((__v4hi)__A, (__v4hi)0LL);
679 /* Convert the doublewords to floating point two at a time. */
680 __zero = (__v4sf) _mm_setzero_ps ();
681 __ra = __builtin_ia32_cvtpi2ps (__zero, __losi);
682 __rb = __builtin_ia32_cvtpi2ps (__ra, __hisi);
684 return (__m128) __builtin_ia32_movlhps (__ra, __rb);
687 /* Convert the low four signed 8-bit values in A to SPFP form. */
688 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
689 _mm_cvtpi8_ps (__m64 __A)
691 __v8qi __sign;
693 /* This comparison against zero gives us a mask that can be used to
694 fill in the missing sign bits in the unpack operations below, so
695 that we get signed values after unpacking. */
696 __sign = __builtin_ia32_pcmpgtb ((__v8qi)0LL, (__v8qi)__A);
698 /* Convert the four low bytes to words. */
699 __A = (__m64) __builtin_ia32_punpcklbw ((__v8qi)__A, __sign);
701 return _mm_cvtpi16_ps(__A);
704 /* Convert the low four unsigned 8-bit values in A to SPFP form. */
705 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
706 _mm_cvtpu8_ps(__m64 __A)
708 __A = (__m64) __builtin_ia32_punpcklbw ((__v8qi)__A, (__v8qi)0LL);
709 return _mm_cvtpu16_ps(__A);
712 /* Convert the four signed 32-bit values in A and B to SPFP form. */
713 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
714 _mm_cvtpi32x2_ps(__m64 __A, __m64 __B)
716 __v4sf __zero = (__v4sf) _mm_setzero_ps ();
717 __v4sf __sfa = __builtin_ia32_cvtpi2ps (__zero, (__v2si)__A);
718 __v4sf __sfb = __builtin_ia32_cvtpi2ps (__sfa, (__v2si)__B);
719 return (__m128) __builtin_ia32_movlhps (__sfa, __sfb);
722 /* Convert the four SPFP values in A to four signed 16-bit integers. */
723 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
724 _mm_cvtps_pi16(__m128 __A)
726 __v4sf __hisf = (__v4sf)__A;
727 __v4sf __losf = __builtin_ia32_movhlps (__hisf, __hisf);
728 __v2si __hisi = __builtin_ia32_cvtps2pi (__hisf);
729 __v2si __losi = __builtin_ia32_cvtps2pi (__losf);
730 return (__m64) __builtin_ia32_packssdw (__hisi, __losi);
733 /* Convert the four SPFP values in A to four signed 8-bit integers. */
734 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
735 _mm_cvtps_pi8(__m128 __A)
737 __v4hi __tmp = (__v4hi) _mm_cvtps_pi16 (__A);
738 return (__m64) __builtin_ia32_packsswb (__tmp, (__v4hi)0LL);
741 /* Selects four specific SPFP values from A and B based on MASK. */
742 #ifdef __OPTIMIZE__
743 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
744 _mm_shuffle_ps (__m128 __A, __m128 __B, int const __mask)
746 return (__m128) __builtin_ia32_shufps ((__v4sf)__A, (__v4sf)__B, __mask);
748 #else
749 #define _mm_shuffle_ps(A, B, MASK) \
750 ((__m128) __builtin_ia32_shufps ((__v4sf)(__m128)(A), \
751 (__v4sf)(__m128)(B), (int)(MASK)))
752 #endif
754 /* Selects and interleaves the upper two SPFP values from A and B. */
755 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
756 _mm_unpackhi_ps (__m128 __A, __m128 __B)
758 return (__m128) __builtin_ia32_unpckhps ((__v4sf)__A, (__v4sf)__B);
761 /* Selects and interleaves the lower two SPFP values from A and B. */
762 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
763 _mm_unpacklo_ps (__m128 __A, __m128 __B)
765 return (__m128) __builtin_ia32_unpcklps ((__v4sf)__A, (__v4sf)__B);
768 /* Sets the upper two SPFP values with 64-bits of data loaded from P;
769 the lower two values are passed through from A. */
770 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
771 _mm_loadh_pi (__m128 __A, __m64 const *__P)
773 return (__m128) __builtin_ia32_loadhps ((__v4sf)__A, (const __v2sf *)__P);
776 /* Stores the upper two SPFP values of A into P. */
777 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
778 _mm_storeh_pi (__m64 *__P, __m128 __A)
780 __builtin_ia32_storehps ((__v2sf *)__P, (__v4sf)__A);
783 /* Moves the upper two values of B into the lower two values of A. */
784 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
785 _mm_movehl_ps (__m128 __A, __m128 __B)
787 return (__m128) __builtin_ia32_movhlps ((__v4sf)__A, (__v4sf)__B);
790 /* Moves the lower two values of B into the upper two values of A. */
791 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
792 _mm_movelh_ps (__m128 __A, __m128 __B)
794 return (__m128) __builtin_ia32_movlhps ((__v4sf)__A, (__v4sf)__B);
797 /* Sets the lower two SPFP values with 64-bits of data loaded from P;
798 the upper two values are passed through from A. */
799 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
800 _mm_loadl_pi (__m128 __A, __m64 const *__P)
802 return (__m128) __builtin_ia32_loadlps ((__v4sf)__A, (const __v2sf *)__P);
805 /* Stores the lower two SPFP values of A into P. */
806 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
807 _mm_storel_pi (__m64 *__P, __m128 __A)
809 __builtin_ia32_storelps ((__v2sf *)__P, (__v4sf)__A);
812 /* Creates a 4-bit mask from the most significant bits of the SPFP values. */
813 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
814 _mm_movemask_ps (__m128 __A)
816 return __builtin_ia32_movmskps ((__v4sf)__A);
819 /* Return the contents of the control register. */
820 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
821 _mm_getcsr (void)
823 return __builtin_ia32_stmxcsr ();
826 /* Read exception bits from the control register. */
827 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
828 _MM_GET_EXCEPTION_STATE (void)
830 return _mm_getcsr() & _MM_EXCEPT_MASK;
833 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
834 _MM_GET_EXCEPTION_MASK (void)
836 return _mm_getcsr() & _MM_MASK_MASK;
839 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
840 _MM_GET_ROUNDING_MODE (void)
842 return _mm_getcsr() & _MM_ROUND_MASK;
845 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
846 _MM_GET_FLUSH_ZERO_MODE (void)
848 return _mm_getcsr() & _MM_FLUSH_ZERO_MASK;
851 /* Set the control register to I. */
852 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
853 _mm_setcsr (unsigned int __I)
855 __builtin_ia32_ldmxcsr (__I);
858 /* Set exception bits in the control register. */
859 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
860 _MM_SET_EXCEPTION_STATE(unsigned int __mask)
862 _mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | __mask);
865 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
866 _MM_SET_EXCEPTION_MASK (unsigned int __mask)
868 _mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | __mask);
871 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
872 _MM_SET_ROUNDING_MODE (unsigned int __mode)
874 _mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | __mode);
877 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
878 _MM_SET_FLUSH_ZERO_MODE (unsigned int __mode)
880 _mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | __mode);
883 /* Create a vector with element 0 as F and the rest zero. */
884 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
885 _mm_set_ss (float __F)
887 return __extension__ (__m128)(__v4sf){ __F, 0.0f, 0.0f, 0.0f };
890 /* Create a vector with all four elements equal to F. */
891 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
892 _mm_set1_ps (float __F)
894 return __extension__ (__m128)(__v4sf){ __F, __F, __F, __F };
897 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
898 _mm_set_ps1 (float __F)
900 return _mm_set1_ps (__F);
903 /* Create a vector with element 0 as *P and the rest zero. */
904 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
905 _mm_load_ss (float const *__P)
907 return _mm_set_ss (*__P);
910 /* Create a vector with all four elements equal to *P. */
911 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
912 _mm_load1_ps (float const *__P)
914 return _mm_set1_ps (*__P);
917 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
918 _mm_load_ps1 (float const *__P)
920 return _mm_load1_ps (__P);
923 /* Load four SPFP values from P. The address must be 16-byte aligned. */
924 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
925 _mm_load_ps (float const *__P)
927 return *(__m128 *)__P;
930 /* Load four SPFP values from P. The address need not be 16-byte aligned. */
931 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
932 _mm_loadu_ps (float const *__P)
934 return *(__m128_u *)__P;
937 /* Load four SPFP values in reverse order. The address must be aligned. */
938 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
939 _mm_loadr_ps (float const *__P)
941 __v4sf __tmp = *(__v4sf *)__P;
942 return (__m128) __builtin_ia32_shufps (__tmp, __tmp, _MM_SHUFFLE (0,1,2,3));
945 /* Create the vector [Z Y X W]. */
946 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
947 _mm_set_ps (const float __Z, const float __Y, const float __X, const float __W)
949 return __extension__ (__m128)(__v4sf){ __W, __X, __Y, __Z };
952 /* Create the vector [W X Y Z]. */
953 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
954 _mm_setr_ps (float __Z, float __Y, float __X, float __W)
956 return __extension__ (__m128)(__v4sf){ __Z, __Y, __X, __W };
959 /* Stores the lower SPFP value. */
960 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
961 _mm_store_ss (float *__P, __m128 __A)
963 *__P = ((__v4sf)__A)[0];
966 extern __inline float __attribute__((__gnu_inline__, __always_inline__, __artificial__))
967 _mm_cvtss_f32 (__m128 __A)
969 return ((__v4sf)__A)[0];
972 /* Store four SPFP values. The address must be 16-byte aligned. */
973 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
974 _mm_store_ps (float *__P, __m128 __A)
976 *(__m128 *)__P = __A;
979 /* Store four SPFP values. The address need not be 16-byte aligned. */
980 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
981 _mm_storeu_ps (float *__P, __m128 __A)
983 *(__m128_u *)__P = __A;
986 /* Store the lower SPFP value across four words. */
987 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
988 _mm_store1_ps (float *__P, __m128 __A)
990 __v4sf __va = (__v4sf)__A;
991 __v4sf __tmp = __builtin_ia32_shufps (__va, __va, _MM_SHUFFLE (0,0,0,0));
992 _mm_storeu_ps (__P, __tmp);
995 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
996 _mm_store_ps1 (float *__P, __m128 __A)
998 _mm_store1_ps (__P, __A);
1001 /* Store four SPFP values in reverse order. The address must be aligned. */
1002 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1003 _mm_storer_ps (float *__P, __m128 __A)
1005 __v4sf __va = (__v4sf)__A;
1006 __v4sf __tmp = __builtin_ia32_shufps (__va, __va, _MM_SHUFFLE (0,1,2,3));
1007 _mm_store_ps (__P, __tmp);
1010 /* Sets the low SPFP value of A from the low value of B. */
1011 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1012 _mm_move_ss (__m128 __A, __m128 __B)
1014 return (__m128) __builtin_ia32_movss ((__v4sf)__A, (__v4sf)__B);
1017 /* Extracts one of the four words of A. The selector N must be immediate. */
1018 #ifdef __OPTIMIZE__
1019 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1020 _mm_extract_pi16 (__m64 const __A, int const __N)
1022 return __builtin_ia32_vec_ext_v4hi ((__v4hi)__A, __N);
1025 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1026 _m_pextrw (__m64 const __A, int const __N)
1028 return _mm_extract_pi16 (__A, __N);
1030 #else
1031 #define _mm_extract_pi16(A, N) \
1032 ((int) __builtin_ia32_vec_ext_v4hi ((__v4hi)(__m64)(A), (int)(N)))
1034 #define _m_pextrw(A, N) _mm_extract_pi16(A, N)
1035 #endif
1037 /* Inserts word D into one of four words of A. The selector N must be
1038 immediate. */
1039 #ifdef __OPTIMIZE__
1040 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1041 _mm_insert_pi16 (__m64 const __A, int const __D, int const __N)
1043 return (__m64) __builtin_ia32_vec_set_v4hi ((__v4hi)__A, __D, __N);
1046 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1047 _m_pinsrw (__m64 const __A, int const __D, int const __N)
1049 return _mm_insert_pi16 (__A, __D, __N);
1051 #else
1052 #define _mm_insert_pi16(A, D, N) \
1053 ((__m64) __builtin_ia32_vec_set_v4hi ((__v4hi)(__m64)(A), \
1054 (int)(D), (int)(N)))
1056 #define _m_pinsrw(A, D, N) _mm_insert_pi16(A, D, N)
1057 #endif
1059 /* Compute the element-wise maximum of signed 16-bit values. */
1060 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1061 _mm_max_pi16 (__m64 __A, __m64 __B)
1063 return (__m64) __builtin_ia32_pmaxsw ((__v4hi)__A, (__v4hi)__B);
1066 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1067 _m_pmaxsw (__m64 __A, __m64 __B)
1069 return _mm_max_pi16 (__A, __B);
1072 /* Compute the element-wise maximum of unsigned 8-bit values. */
1073 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1074 _mm_max_pu8 (__m64 __A, __m64 __B)
1076 return (__m64) __builtin_ia32_pmaxub ((__v8qi)__A, (__v8qi)__B);
1079 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1080 _m_pmaxub (__m64 __A, __m64 __B)
1082 return _mm_max_pu8 (__A, __B);
1085 /* Compute the element-wise minimum of signed 16-bit values. */
1086 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1087 _mm_min_pi16 (__m64 __A, __m64 __B)
1089 return (__m64) __builtin_ia32_pminsw ((__v4hi)__A, (__v4hi)__B);
1092 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1093 _m_pminsw (__m64 __A, __m64 __B)
1095 return _mm_min_pi16 (__A, __B);
1098 /* Compute the element-wise minimum of unsigned 8-bit values. */
1099 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1100 _mm_min_pu8 (__m64 __A, __m64 __B)
1102 return (__m64) __builtin_ia32_pminub ((__v8qi)__A, (__v8qi)__B);
1105 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1106 _m_pminub (__m64 __A, __m64 __B)
1108 return _mm_min_pu8 (__A, __B);
1111 /* Create an 8-bit mask of the signs of 8-bit values. */
1112 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1113 _mm_movemask_pi8 (__m64 __A)
1115 return __builtin_ia32_pmovmskb ((__v8qi)__A);
1118 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1119 _m_pmovmskb (__m64 __A)
1121 return _mm_movemask_pi8 (__A);
1124 /* Multiply four unsigned 16-bit values in A by four unsigned 16-bit values
1125 in B and produce the high 16 bits of the 32-bit results. */
1126 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1127 _mm_mulhi_pu16 (__m64 __A, __m64 __B)
1129 return (__m64) __builtin_ia32_pmulhuw ((__v4hi)__A, (__v4hi)__B);
1132 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1133 _m_pmulhuw (__m64 __A, __m64 __B)
1135 return _mm_mulhi_pu16 (__A, __B);
1138 /* Return a combination of the four 16-bit values in A. The selector
1139 must be an immediate. */
1140 #ifdef __OPTIMIZE__
1141 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1142 _mm_shuffle_pi16 (__m64 __A, int const __N)
1144 return (__m64) __builtin_ia32_pshufw ((__v4hi)__A, __N);
1147 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1148 _m_pshufw (__m64 __A, int const __N)
1150 return _mm_shuffle_pi16 (__A, __N);
1152 #else
1153 #define _mm_shuffle_pi16(A, N) \
1154 ((__m64) __builtin_ia32_pshufw ((__v4hi)(__m64)(A), (int)(N)))
1156 #define _m_pshufw(A, N) _mm_shuffle_pi16 (A, N)
1157 #endif
1159 /* Conditionally store byte elements of A into P. The high bit of each
1160 byte in the selector N determines whether the corresponding byte from
1161 A is stored. */
1162 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1163 _mm_maskmove_si64 (__m64 __A, __m64 __N, char *__P)
1165 __builtin_ia32_maskmovq ((__v8qi)__A, (__v8qi)__N, __P);
1168 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1169 _m_maskmovq (__m64 __A, __m64 __N, char *__P)
1171 _mm_maskmove_si64 (__A, __N, __P);
1174 /* Compute the rounded averages of the unsigned 8-bit values in A and B. */
1175 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1176 _mm_avg_pu8 (__m64 __A, __m64 __B)
1178 return (__m64) __builtin_ia32_pavgb ((__v8qi)__A, (__v8qi)__B);
1181 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1182 _m_pavgb (__m64 __A, __m64 __B)
1184 return _mm_avg_pu8 (__A, __B);
1187 /* Compute the rounded averages of the unsigned 16-bit values in A and B. */
1188 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1189 _mm_avg_pu16 (__m64 __A, __m64 __B)
1191 return (__m64) __builtin_ia32_pavgw ((__v4hi)__A, (__v4hi)__B);
1194 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1195 _m_pavgw (__m64 __A, __m64 __B)
1197 return _mm_avg_pu16 (__A, __B);
1200 /* Compute the sum of the absolute differences of the unsigned 8-bit
1201 values in A and B. Return the value in the lower 16-bit word; the
1202 upper words are cleared. */
1203 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1204 _mm_sad_pu8 (__m64 __A, __m64 __B)
1206 return (__m64) __builtin_ia32_psadbw ((__v8qi)__A, (__v8qi)__B);
1209 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1210 _m_psadbw (__m64 __A, __m64 __B)
1212 return _mm_sad_pu8 (__A, __B);
1215 /* Stores the data in A to the address P without polluting the caches. */
1216 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1217 _mm_stream_pi (__m64 *__P, __m64 __A)
1219 __builtin_ia32_movntq ((unsigned long long *)__P, (unsigned long long)__A);
1222 /* Likewise. The address must be 16-byte aligned. */
1223 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1224 _mm_stream_ps (float *__P, __m128 __A)
1226 __builtin_ia32_movntps (__P, (__v4sf)__A);
1229 /* Guarantees that every preceding store is globally visible before
1230 any subsequent store. */
1231 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1232 _mm_sfence (void)
1234 __builtin_ia32_sfence ();
1237 /* Transpose the 4x4 matrix composed of row[0-3]. */
1238 #define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) \
1239 do { \
1240 __v4sf __r0 = (row0), __r1 = (row1), __r2 = (row2), __r3 = (row3); \
1241 __v4sf __t0 = __builtin_ia32_unpcklps (__r0, __r1); \
1242 __v4sf __t1 = __builtin_ia32_unpcklps (__r2, __r3); \
1243 __v4sf __t2 = __builtin_ia32_unpckhps (__r0, __r1); \
1244 __v4sf __t3 = __builtin_ia32_unpckhps (__r2, __r3); \
1245 (row0) = __builtin_ia32_movlhps (__t0, __t1); \
1246 (row1) = __builtin_ia32_movhlps (__t1, __t0); \
1247 (row2) = __builtin_ia32_movlhps (__t2, __t3); \
1248 (row3) = __builtin_ia32_movhlps (__t3, __t2); \
1249 } while (0)
1251 /* For backward source compatibility. */
1252 # include <emmintrin.h>
1254 #ifdef __DISABLE_SSE__
1255 #undef __DISABLE_SSE__
1256 #pragma GCC pop_options
1257 #endif /* __DISABLE_SSE__ */
1259 /* The execution of the next instruction is delayed by an implementation
1260 specific amount of time. The instruction does not modify the
1261 architectural state. This is after the pop_options pragma because
1262 it does not require SSE support in the processor--the encoding is a
1263 nop on processors that do not support it. */
1264 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1265 _mm_pause (void)
1267 __builtin_ia32_pause ();
1270 #endif /* _XMMINTRIN_H_INCLUDED */