xmmintrin.h (_mm_add_ps, [...]): Use vector extensions instead of builtins.
[official-gcc.git] / gcc / config / i386 / xmmintrin.h
blob69c2cacf473302891842564563a5ced2b1247996
1 /* Copyright (C) 2002-2014 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 /* Internal data types for implementing the intrinsics. */
72 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
74 /* Create a selector for use with the SHUFPS instruction. */
75 #define _MM_SHUFFLE(fp3,fp2,fp1,fp0) \
76 (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | (fp0))
78 /* Bits in the MXCSR. */
79 #define _MM_EXCEPT_MASK 0x003f
80 #define _MM_EXCEPT_INVALID 0x0001
81 #define _MM_EXCEPT_DENORM 0x0002
82 #define _MM_EXCEPT_DIV_ZERO 0x0004
83 #define _MM_EXCEPT_OVERFLOW 0x0008
84 #define _MM_EXCEPT_UNDERFLOW 0x0010
85 #define _MM_EXCEPT_INEXACT 0x0020
87 #define _MM_MASK_MASK 0x1f80
88 #define _MM_MASK_INVALID 0x0080
89 #define _MM_MASK_DENORM 0x0100
90 #define _MM_MASK_DIV_ZERO 0x0200
91 #define _MM_MASK_OVERFLOW 0x0400
92 #define _MM_MASK_UNDERFLOW 0x0800
93 #define _MM_MASK_INEXACT 0x1000
95 #define _MM_ROUND_MASK 0x6000
96 #define _MM_ROUND_NEAREST 0x0000
97 #define _MM_ROUND_DOWN 0x2000
98 #define _MM_ROUND_UP 0x4000
99 #define _MM_ROUND_TOWARD_ZERO 0x6000
101 #define _MM_FLUSH_ZERO_MASK 0x8000
102 #define _MM_FLUSH_ZERO_ON 0x8000
103 #define _MM_FLUSH_ZERO_OFF 0x0000
105 /* Create an undefined vector. */
106 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
107 _mm_undefined_ps (void)
109 __m128 __Y = __Y;
110 return __Y;
113 /* Create a vector of zeros. */
114 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
115 _mm_setzero_ps (void)
117 return __extension__ (__m128){ 0.0f, 0.0f, 0.0f, 0.0f };
120 /* Perform the respective operation on the lower SPFP (single-precision
121 floating-point) values of A and B; the upper three SPFP values are
122 passed through from A. */
124 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
125 _mm_add_ss (__m128 __A, __m128 __B)
127 return (__m128) __builtin_ia32_addss ((__v4sf)__A, (__v4sf)__B);
130 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
131 _mm_sub_ss (__m128 __A, __m128 __B)
133 return (__m128) __builtin_ia32_subss ((__v4sf)__A, (__v4sf)__B);
136 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
137 _mm_mul_ss (__m128 __A, __m128 __B)
139 return (__m128) __builtin_ia32_mulss ((__v4sf)__A, (__v4sf)__B);
142 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
143 _mm_div_ss (__m128 __A, __m128 __B)
145 return (__m128) __builtin_ia32_divss ((__v4sf)__A, (__v4sf)__B);
148 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
149 _mm_sqrt_ss (__m128 __A)
151 return (__m128) __builtin_ia32_sqrtss ((__v4sf)__A);
154 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
155 _mm_rcp_ss (__m128 __A)
157 return (__m128) __builtin_ia32_rcpss ((__v4sf)__A);
160 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
161 _mm_rsqrt_ss (__m128 __A)
163 return (__m128) __builtin_ia32_rsqrtss ((__v4sf)__A);
166 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
167 _mm_min_ss (__m128 __A, __m128 __B)
169 return (__m128) __builtin_ia32_minss ((__v4sf)__A, (__v4sf)__B);
172 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
173 _mm_max_ss (__m128 __A, __m128 __B)
175 return (__m128) __builtin_ia32_maxss ((__v4sf)__A, (__v4sf)__B);
178 /* Perform the respective operation on the four SPFP values in A and B. */
180 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
181 _mm_add_ps (__m128 __A, __m128 __B)
183 return (__m128) ((__v4sf)__A + (__v4sf)__B);
186 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
187 _mm_sub_ps (__m128 __A, __m128 __B)
189 return (__m128) ((__v4sf)__A - (__v4sf)__B);
192 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
193 _mm_mul_ps (__m128 __A, __m128 __B)
195 return (__m128) ((__v4sf)__A * (__v4sf)__B);
198 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
199 _mm_div_ps (__m128 __A, __m128 __B)
201 return (__m128) ((__v4sf)__A / (__v4sf)__B);
204 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
205 _mm_sqrt_ps (__m128 __A)
207 return (__m128) __builtin_ia32_sqrtps ((__v4sf)__A);
210 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
211 _mm_rcp_ps (__m128 __A)
213 return (__m128) __builtin_ia32_rcpps ((__v4sf)__A);
216 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
217 _mm_rsqrt_ps (__m128 __A)
219 return (__m128) __builtin_ia32_rsqrtps ((__v4sf)__A);
222 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
223 _mm_min_ps (__m128 __A, __m128 __B)
225 return (__m128) __builtin_ia32_minps ((__v4sf)__A, (__v4sf)__B);
228 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
229 _mm_max_ps (__m128 __A, __m128 __B)
231 return (__m128) __builtin_ia32_maxps ((__v4sf)__A, (__v4sf)__B);
234 /* Perform logical bit-wise operations on 128-bit values. */
236 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
237 _mm_and_ps (__m128 __A, __m128 __B)
239 return __builtin_ia32_andps (__A, __B);
242 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
243 _mm_andnot_ps (__m128 __A, __m128 __B)
245 return __builtin_ia32_andnps (__A, __B);
248 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
249 _mm_or_ps (__m128 __A, __m128 __B)
251 return __builtin_ia32_orps (__A, __B);
254 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
255 _mm_xor_ps (__m128 __A, __m128 __B)
257 return __builtin_ia32_xorps (__A, __B);
260 /* Perform a comparison on the lower SPFP values of A and B. If the
261 comparison is true, place a mask of all ones in the result, otherwise a
262 mask of zeros. The upper three SPFP values are passed through from A. */
264 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
265 _mm_cmpeq_ss (__m128 __A, __m128 __B)
267 return (__m128) __builtin_ia32_cmpeqss ((__v4sf)__A, (__v4sf)__B);
270 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
271 _mm_cmplt_ss (__m128 __A, __m128 __B)
273 return (__m128) __builtin_ia32_cmpltss ((__v4sf)__A, (__v4sf)__B);
276 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
277 _mm_cmple_ss (__m128 __A, __m128 __B)
279 return (__m128) __builtin_ia32_cmpless ((__v4sf)__A, (__v4sf)__B);
282 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
283 _mm_cmpgt_ss (__m128 __A, __m128 __B)
285 return (__m128) __builtin_ia32_movss ((__v4sf) __A,
286 (__v4sf)
287 __builtin_ia32_cmpltss ((__v4sf) __B,
288 (__v4sf)
289 __A));
292 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
293 _mm_cmpge_ss (__m128 __A, __m128 __B)
295 return (__m128) __builtin_ia32_movss ((__v4sf) __A,
296 (__v4sf)
297 __builtin_ia32_cmpless ((__v4sf) __B,
298 (__v4sf)
299 __A));
302 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
303 _mm_cmpneq_ss (__m128 __A, __m128 __B)
305 return (__m128) __builtin_ia32_cmpneqss ((__v4sf)__A, (__v4sf)__B);
308 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
309 _mm_cmpnlt_ss (__m128 __A, __m128 __B)
311 return (__m128) __builtin_ia32_cmpnltss ((__v4sf)__A, (__v4sf)__B);
314 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
315 _mm_cmpnle_ss (__m128 __A, __m128 __B)
317 return (__m128) __builtin_ia32_cmpnless ((__v4sf)__A, (__v4sf)__B);
320 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
321 _mm_cmpngt_ss (__m128 __A, __m128 __B)
323 return (__m128) __builtin_ia32_movss ((__v4sf) __A,
324 (__v4sf)
325 __builtin_ia32_cmpnltss ((__v4sf) __B,
326 (__v4sf)
327 __A));
330 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
331 _mm_cmpnge_ss (__m128 __A, __m128 __B)
333 return (__m128) __builtin_ia32_movss ((__v4sf) __A,
334 (__v4sf)
335 __builtin_ia32_cmpnless ((__v4sf) __B,
336 (__v4sf)
337 __A));
340 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
341 _mm_cmpord_ss (__m128 __A, __m128 __B)
343 return (__m128) __builtin_ia32_cmpordss ((__v4sf)__A, (__v4sf)__B);
346 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
347 _mm_cmpunord_ss (__m128 __A, __m128 __B)
349 return (__m128) __builtin_ia32_cmpunordss ((__v4sf)__A, (__v4sf)__B);
352 /* Perform a comparison on the four SPFP values of A and B. For each
353 element, if the comparison is true, place a mask of all ones in the
354 result, otherwise a mask of zeros. */
356 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
357 _mm_cmpeq_ps (__m128 __A, __m128 __B)
359 return (__m128) __builtin_ia32_cmpeqps ((__v4sf)__A, (__v4sf)__B);
362 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
363 _mm_cmplt_ps (__m128 __A, __m128 __B)
365 return (__m128) __builtin_ia32_cmpltps ((__v4sf)__A, (__v4sf)__B);
368 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
369 _mm_cmple_ps (__m128 __A, __m128 __B)
371 return (__m128) __builtin_ia32_cmpleps ((__v4sf)__A, (__v4sf)__B);
374 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
375 _mm_cmpgt_ps (__m128 __A, __m128 __B)
377 return (__m128) __builtin_ia32_cmpgtps ((__v4sf)__A, (__v4sf)__B);
380 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
381 _mm_cmpge_ps (__m128 __A, __m128 __B)
383 return (__m128) __builtin_ia32_cmpgeps ((__v4sf)__A, (__v4sf)__B);
386 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
387 _mm_cmpneq_ps (__m128 __A, __m128 __B)
389 return (__m128) __builtin_ia32_cmpneqps ((__v4sf)__A, (__v4sf)__B);
392 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
393 _mm_cmpnlt_ps (__m128 __A, __m128 __B)
395 return (__m128) __builtin_ia32_cmpnltps ((__v4sf)__A, (__v4sf)__B);
398 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
399 _mm_cmpnle_ps (__m128 __A, __m128 __B)
401 return (__m128) __builtin_ia32_cmpnleps ((__v4sf)__A, (__v4sf)__B);
404 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
405 _mm_cmpngt_ps (__m128 __A, __m128 __B)
407 return (__m128) __builtin_ia32_cmpngtps ((__v4sf)__A, (__v4sf)__B);
410 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
411 _mm_cmpnge_ps (__m128 __A, __m128 __B)
413 return (__m128) __builtin_ia32_cmpngeps ((__v4sf)__A, (__v4sf)__B);
416 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
417 _mm_cmpord_ps (__m128 __A, __m128 __B)
419 return (__m128) __builtin_ia32_cmpordps ((__v4sf)__A, (__v4sf)__B);
422 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
423 _mm_cmpunord_ps (__m128 __A, __m128 __B)
425 return (__m128) __builtin_ia32_cmpunordps ((__v4sf)__A, (__v4sf)__B);
428 /* Compare the lower SPFP values of A and B and return 1 if true
429 and 0 if false. */
431 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
432 _mm_comieq_ss (__m128 __A, __m128 __B)
434 return __builtin_ia32_comieq ((__v4sf)__A, (__v4sf)__B);
437 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
438 _mm_comilt_ss (__m128 __A, __m128 __B)
440 return __builtin_ia32_comilt ((__v4sf)__A, (__v4sf)__B);
443 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
444 _mm_comile_ss (__m128 __A, __m128 __B)
446 return __builtin_ia32_comile ((__v4sf)__A, (__v4sf)__B);
449 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
450 _mm_comigt_ss (__m128 __A, __m128 __B)
452 return __builtin_ia32_comigt ((__v4sf)__A, (__v4sf)__B);
455 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
456 _mm_comige_ss (__m128 __A, __m128 __B)
458 return __builtin_ia32_comige ((__v4sf)__A, (__v4sf)__B);
461 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
462 _mm_comineq_ss (__m128 __A, __m128 __B)
464 return __builtin_ia32_comineq ((__v4sf)__A, (__v4sf)__B);
467 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
468 _mm_ucomieq_ss (__m128 __A, __m128 __B)
470 return __builtin_ia32_ucomieq ((__v4sf)__A, (__v4sf)__B);
473 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
474 _mm_ucomilt_ss (__m128 __A, __m128 __B)
476 return __builtin_ia32_ucomilt ((__v4sf)__A, (__v4sf)__B);
479 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
480 _mm_ucomile_ss (__m128 __A, __m128 __B)
482 return __builtin_ia32_ucomile ((__v4sf)__A, (__v4sf)__B);
485 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
486 _mm_ucomigt_ss (__m128 __A, __m128 __B)
488 return __builtin_ia32_ucomigt ((__v4sf)__A, (__v4sf)__B);
491 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
492 _mm_ucomige_ss (__m128 __A, __m128 __B)
494 return __builtin_ia32_ucomige ((__v4sf)__A, (__v4sf)__B);
497 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
498 _mm_ucomineq_ss (__m128 __A, __m128 __B)
500 return __builtin_ia32_ucomineq ((__v4sf)__A, (__v4sf)__B);
503 /* Convert the lower SPFP value to a 32-bit integer according to the current
504 rounding mode. */
505 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
506 _mm_cvtss_si32 (__m128 __A)
508 return __builtin_ia32_cvtss2si ((__v4sf) __A);
511 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
512 _mm_cvt_ss2si (__m128 __A)
514 return _mm_cvtss_si32 (__A);
517 #ifdef __x86_64__
518 /* Convert the lower SPFP value to a 32-bit integer according to the
519 current rounding mode. */
521 /* Intel intrinsic. */
522 extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
523 _mm_cvtss_si64 (__m128 __A)
525 return __builtin_ia32_cvtss2si64 ((__v4sf) __A);
528 /* Microsoft intrinsic. */
529 extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
530 _mm_cvtss_si64x (__m128 __A)
532 return __builtin_ia32_cvtss2si64 ((__v4sf) __A);
534 #endif
536 /* Convert the two lower SPFP values to 32-bit integers according to the
537 current rounding mode. Return the integers in packed form. */
538 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
539 _mm_cvtps_pi32 (__m128 __A)
541 return (__m64) __builtin_ia32_cvtps2pi ((__v4sf) __A);
544 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
545 _mm_cvt_ps2pi (__m128 __A)
547 return _mm_cvtps_pi32 (__A);
550 /* Truncate the lower SPFP value to a 32-bit integer. */
551 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
552 _mm_cvttss_si32 (__m128 __A)
554 return __builtin_ia32_cvttss2si ((__v4sf) __A);
557 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
558 _mm_cvtt_ss2si (__m128 __A)
560 return _mm_cvttss_si32 (__A);
563 #ifdef __x86_64__
564 /* Truncate the lower SPFP value to a 32-bit integer. */
566 /* Intel intrinsic. */
567 extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
568 _mm_cvttss_si64 (__m128 __A)
570 return __builtin_ia32_cvttss2si64 ((__v4sf) __A);
573 /* Microsoft intrinsic. */
574 extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
575 _mm_cvttss_si64x (__m128 __A)
577 return __builtin_ia32_cvttss2si64 ((__v4sf) __A);
579 #endif
581 /* Truncate the two lower SPFP values to 32-bit integers. Return the
582 integers in packed form. */
583 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
584 _mm_cvttps_pi32 (__m128 __A)
586 return (__m64) __builtin_ia32_cvttps2pi ((__v4sf) __A);
589 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
590 _mm_cvtt_ps2pi (__m128 __A)
592 return _mm_cvttps_pi32 (__A);
595 /* Convert B to a SPFP value and insert it as element zero in A. */
596 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
597 _mm_cvtsi32_ss (__m128 __A, int __B)
599 return (__m128) __builtin_ia32_cvtsi2ss ((__v4sf) __A, __B);
602 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
603 _mm_cvt_si2ss (__m128 __A, int __B)
605 return _mm_cvtsi32_ss (__A, __B);
608 #ifdef __x86_64__
609 /* Convert B to a SPFP value and insert it as element zero in A. */
611 /* Intel intrinsic. */
612 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
613 _mm_cvtsi64_ss (__m128 __A, long long __B)
615 return (__m128) __builtin_ia32_cvtsi642ss ((__v4sf) __A, __B);
618 /* Microsoft intrinsic. */
619 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
620 _mm_cvtsi64x_ss (__m128 __A, long long __B)
622 return (__m128) __builtin_ia32_cvtsi642ss ((__v4sf) __A, __B);
624 #endif
626 /* Convert the two 32-bit values in B to SPFP form and insert them
627 as the two lower elements in A. */
628 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
629 _mm_cvtpi32_ps (__m128 __A, __m64 __B)
631 return (__m128) __builtin_ia32_cvtpi2ps ((__v4sf) __A, (__v2si)__B);
634 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
635 _mm_cvt_pi2ps (__m128 __A, __m64 __B)
637 return _mm_cvtpi32_ps (__A, __B);
640 /* Convert the four signed 16-bit values in A to SPFP form. */
641 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
642 _mm_cvtpi16_ps (__m64 __A)
644 __v4hi __sign;
645 __v2si __hisi, __losi;
646 __v4sf __zero, __ra, __rb;
648 /* This comparison against zero gives us a mask that can be used to
649 fill in the missing sign bits in the unpack operations below, so
650 that we get signed values after unpacking. */
651 __sign = __builtin_ia32_pcmpgtw ((__v4hi)0LL, (__v4hi)__A);
653 /* Convert the four words to doublewords. */
654 __losi = (__v2si) __builtin_ia32_punpcklwd ((__v4hi)__A, __sign);
655 __hisi = (__v2si) __builtin_ia32_punpckhwd ((__v4hi)__A, __sign);
657 /* Convert the doublewords to floating point two at a time. */
658 __zero = (__v4sf) _mm_setzero_ps ();
659 __ra = __builtin_ia32_cvtpi2ps (__zero, __losi);
660 __rb = __builtin_ia32_cvtpi2ps (__ra, __hisi);
662 return (__m128) __builtin_ia32_movlhps (__ra, __rb);
665 /* Convert the four unsigned 16-bit values in A to SPFP form. */
666 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
667 _mm_cvtpu16_ps (__m64 __A)
669 __v2si __hisi, __losi;
670 __v4sf __zero, __ra, __rb;
672 /* Convert the four words to doublewords. */
673 __losi = (__v2si) __builtin_ia32_punpcklwd ((__v4hi)__A, (__v4hi)0LL);
674 __hisi = (__v2si) __builtin_ia32_punpckhwd ((__v4hi)__A, (__v4hi)0LL);
676 /* Convert the doublewords to floating point two at a time. */
677 __zero = (__v4sf) _mm_setzero_ps ();
678 __ra = __builtin_ia32_cvtpi2ps (__zero, __losi);
679 __rb = __builtin_ia32_cvtpi2ps (__ra, __hisi);
681 return (__m128) __builtin_ia32_movlhps (__ra, __rb);
684 /* Convert the low four signed 8-bit values in A to SPFP form. */
685 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
686 _mm_cvtpi8_ps (__m64 __A)
688 __v8qi __sign;
690 /* This comparison against zero gives us a mask that can be used to
691 fill in the missing sign bits in the unpack operations below, so
692 that we get signed values after unpacking. */
693 __sign = __builtin_ia32_pcmpgtb ((__v8qi)0LL, (__v8qi)__A);
695 /* Convert the four low bytes to words. */
696 __A = (__m64) __builtin_ia32_punpcklbw ((__v8qi)__A, __sign);
698 return _mm_cvtpi16_ps(__A);
701 /* Convert the low four unsigned 8-bit values in A to SPFP form. */
702 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
703 _mm_cvtpu8_ps(__m64 __A)
705 __A = (__m64) __builtin_ia32_punpcklbw ((__v8qi)__A, (__v8qi)0LL);
706 return _mm_cvtpu16_ps(__A);
709 /* Convert the four signed 32-bit values in A and B to SPFP form. */
710 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
711 _mm_cvtpi32x2_ps(__m64 __A, __m64 __B)
713 __v4sf __zero = (__v4sf) _mm_setzero_ps ();
714 __v4sf __sfa = __builtin_ia32_cvtpi2ps (__zero, (__v2si)__A);
715 __v4sf __sfb = __builtin_ia32_cvtpi2ps (__sfa, (__v2si)__B);
716 return (__m128) __builtin_ia32_movlhps (__sfa, __sfb);
719 /* Convert the four SPFP values in A to four signed 16-bit integers. */
720 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
721 _mm_cvtps_pi16(__m128 __A)
723 __v4sf __hisf = (__v4sf)__A;
724 __v4sf __losf = __builtin_ia32_movhlps (__hisf, __hisf);
725 __v2si __hisi = __builtin_ia32_cvtps2pi (__hisf);
726 __v2si __losi = __builtin_ia32_cvtps2pi (__losf);
727 return (__m64) __builtin_ia32_packssdw (__hisi, __losi);
730 /* Convert the four SPFP values in A to four signed 8-bit integers. */
731 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
732 _mm_cvtps_pi8(__m128 __A)
734 __v4hi __tmp = (__v4hi) _mm_cvtps_pi16 (__A);
735 return (__m64) __builtin_ia32_packsswb (__tmp, (__v4hi)0LL);
738 /* Selects four specific SPFP values from A and B based on MASK. */
739 #ifdef __OPTIMIZE__
740 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
741 _mm_shuffle_ps (__m128 __A, __m128 __B, int const __mask)
743 return (__m128) __builtin_ia32_shufps ((__v4sf)__A, (__v4sf)__B, __mask);
745 #else
746 #define _mm_shuffle_ps(A, B, MASK) \
747 ((__m128) __builtin_ia32_shufps ((__v4sf)(__m128)(A), \
748 (__v4sf)(__m128)(B), (int)(MASK)))
749 #endif
751 /* Selects and interleaves the upper two SPFP values from A and B. */
752 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
753 _mm_unpackhi_ps (__m128 __A, __m128 __B)
755 return (__m128) __builtin_ia32_unpckhps ((__v4sf)__A, (__v4sf)__B);
758 /* Selects and interleaves the lower two SPFP values from A and B. */
759 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
760 _mm_unpacklo_ps (__m128 __A, __m128 __B)
762 return (__m128) __builtin_ia32_unpcklps ((__v4sf)__A, (__v4sf)__B);
765 /* Sets the upper two SPFP values with 64-bits of data loaded from P;
766 the lower two values are passed through from A. */
767 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
768 _mm_loadh_pi (__m128 __A, __m64 const *__P)
770 return (__m128) __builtin_ia32_loadhps ((__v4sf)__A, (const __v2sf *)__P);
773 /* Stores the upper two SPFP values of A into P. */
774 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
775 _mm_storeh_pi (__m64 *__P, __m128 __A)
777 __builtin_ia32_storehps ((__v2sf *)__P, (__v4sf)__A);
780 /* Moves the upper two values of B into the lower two values of A. */
781 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
782 _mm_movehl_ps (__m128 __A, __m128 __B)
784 return (__m128) __builtin_ia32_movhlps ((__v4sf)__A, (__v4sf)__B);
787 /* Moves the lower two values of B into the upper two values of A. */
788 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
789 _mm_movelh_ps (__m128 __A, __m128 __B)
791 return (__m128) __builtin_ia32_movlhps ((__v4sf)__A, (__v4sf)__B);
794 /* Sets the lower two SPFP values with 64-bits of data loaded from P;
795 the upper two values are passed through from A. */
796 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
797 _mm_loadl_pi (__m128 __A, __m64 const *__P)
799 return (__m128) __builtin_ia32_loadlps ((__v4sf)__A, (const __v2sf *)__P);
802 /* Stores the lower two SPFP values of A into P. */
803 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
804 _mm_storel_pi (__m64 *__P, __m128 __A)
806 __builtin_ia32_storelps ((__v2sf *)__P, (__v4sf)__A);
809 /* Creates a 4-bit mask from the most significant bits of the SPFP values. */
810 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
811 _mm_movemask_ps (__m128 __A)
813 return __builtin_ia32_movmskps ((__v4sf)__A);
816 /* Return the contents of the control register. */
817 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
818 _mm_getcsr (void)
820 return __builtin_ia32_stmxcsr ();
823 /* Read exception bits from the control register. */
824 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
825 _MM_GET_EXCEPTION_STATE (void)
827 return _mm_getcsr() & _MM_EXCEPT_MASK;
830 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
831 _MM_GET_EXCEPTION_MASK (void)
833 return _mm_getcsr() & _MM_MASK_MASK;
836 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
837 _MM_GET_ROUNDING_MODE (void)
839 return _mm_getcsr() & _MM_ROUND_MASK;
842 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
843 _MM_GET_FLUSH_ZERO_MODE (void)
845 return _mm_getcsr() & _MM_FLUSH_ZERO_MASK;
848 /* Set the control register to I. */
849 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
850 _mm_setcsr (unsigned int __I)
852 __builtin_ia32_ldmxcsr (__I);
855 /* Set exception bits in the control register. */
856 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
857 _MM_SET_EXCEPTION_STATE(unsigned int __mask)
859 _mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | __mask);
862 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
863 _MM_SET_EXCEPTION_MASK (unsigned int __mask)
865 _mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | __mask);
868 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
869 _MM_SET_ROUNDING_MODE (unsigned int __mode)
871 _mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | __mode);
874 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
875 _MM_SET_FLUSH_ZERO_MODE (unsigned int __mode)
877 _mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | __mode);
880 /* Create a vector with element 0 as F and the rest zero. */
881 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
882 _mm_set_ss (float __F)
884 return __extension__ (__m128)(__v4sf){ __F, 0.0f, 0.0f, 0.0f };
887 /* Create a vector with all four elements equal to F. */
888 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
889 _mm_set1_ps (float __F)
891 return __extension__ (__m128)(__v4sf){ __F, __F, __F, __F };
894 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
895 _mm_set_ps1 (float __F)
897 return _mm_set1_ps (__F);
900 /* Create a vector with element 0 as *P and the rest zero. */
901 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
902 _mm_load_ss (float const *__P)
904 return _mm_set_ss (*__P);
907 /* Create a vector with all four elements equal to *P. */
908 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
909 _mm_load1_ps (float const *__P)
911 return _mm_set1_ps (*__P);
914 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
915 _mm_load_ps1 (float const *__P)
917 return _mm_load1_ps (__P);
920 /* Load four SPFP values from P. The address must be 16-byte aligned. */
921 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
922 _mm_load_ps (float const *__P)
924 return (__m128) *(__v4sf *)__P;
927 /* Load four SPFP values from P. The address need not be 16-byte aligned. */
928 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
929 _mm_loadu_ps (float const *__P)
931 return (__m128) __builtin_ia32_loadups (__P);
934 /* Load four SPFP values in reverse order. The address must be aligned. */
935 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
936 _mm_loadr_ps (float const *__P)
938 __v4sf __tmp = *(__v4sf *)__P;
939 return (__m128) __builtin_ia32_shufps (__tmp, __tmp, _MM_SHUFFLE (0,1,2,3));
942 /* Create the vector [Z Y X W]. */
943 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
944 _mm_set_ps (const float __Z, const float __Y, const float __X, const float __W)
946 return __extension__ (__m128)(__v4sf){ __W, __X, __Y, __Z };
949 /* Create the vector [W X Y Z]. */
950 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
951 _mm_setr_ps (float __Z, float __Y, float __X, float __W)
953 return __extension__ (__m128)(__v4sf){ __Z, __Y, __X, __W };
956 /* Stores the lower SPFP value. */
957 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
958 _mm_store_ss (float *__P, __m128 __A)
960 *__P = ((__v4sf)__A)[0];
963 extern __inline float __attribute__((__gnu_inline__, __always_inline__, __artificial__))
964 _mm_cvtss_f32 (__m128 __A)
966 return ((__v4sf)__A)[0];
969 /* Store four SPFP values. The address must be 16-byte aligned. */
970 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
971 _mm_store_ps (float *__P, __m128 __A)
973 *(__v4sf *)__P = (__v4sf)__A;
976 /* Store four SPFP values. The address need not be 16-byte aligned. */
977 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
978 _mm_storeu_ps (float *__P, __m128 __A)
980 __builtin_ia32_storeups (__P, (__v4sf)__A);
983 /* Store the lower SPFP value across four words. */
984 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
985 _mm_store1_ps (float *__P, __m128 __A)
987 __v4sf __va = (__v4sf)__A;
988 __v4sf __tmp = __builtin_ia32_shufps (__va, __va, _MM_SHUFFLE (0,0,0,0));
989 _mm_storeu_ps (__P, __tmp);
992 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
993 _mm_store_ps1 (float *__P, __m128 __A)
995 _mm_store1_ps (__P, __A);
998 /* Store four SPFP values in reverse order. The address must be aligned. */
999 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1000 _mm_storer_ps (float *__P, __m128 __A)
1002 __v4sf __va = (__v4sf)__A;
1003 __v4sf __tmp = __builtin_ia32_shufps (__va, __va, _MM_SHUFFLE (0,1,2,3));
1004 _mm_store_ps (__P, __tmp);
1007 /* Sets the low SPFP value of A from the low value of B. */
1008 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1009 _mm_move_ss (__m128 __A, __m128 __B)
1011 return (__m128) __builtin_ia32_movss ((__v4sf)__A, (__v4sf)__B);
1014 /* Extracts one of the four words of A. The selector N must be immediate. */
1015 #ifdef __OPTIMIZE__
1016 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1017 _mm_extract_pi16 (__m64 const __A, int const __N)
1019 return __builtin_ia32_vec_ext_v4hi ((__v4hi)__A, __N);
1022 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1023 _m_pextrw (__m64 const __A, int const __N)
1025 return _mm_extract_pi16 (__A, __N);
1027 #else
1028 #define _mm_extract_pi16(A, N) \
1029 ((int) __builtin_ia32_vec_ext_v4hi ((__v4hi)(__m64)(A), (int)(N)))
1031 #define _m_pextrw(A, N) _mm_extract_pi16(A, N)
1032 #endif
1034 /* Inserts word D into one of four words of A. The selector N must be
1035 immediate. */
1036 #ifdef __OPTIMIZE__
1037 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1038 _mm_insert_pi16 (__m64 const __A, int const __D, int const __N)
1040 return (__m64) __builtin_ia32_vec_set_v4hi ((__v4hi)__A, __D, __N);
1043 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1044 _m_pinsrw (__m64 const __A, int const __D, int const __N)
1046 return _mm_insert_pi16 (__A, __D, __N);
1048 #else
1049 #define _mm_insert_pi16(A, D, N) \
1050 ((__m64) __builtin_ia32_vec_set_v4hi ((__v4hi)(__m64)(A), \
1051 (int)(D), (int)(N)))
1053 #define _m_pinsrw(A, D, N) _mm_insert_pi16(A, D, N)
1054 #endif
1056 /* Compute the element-wise maximum of signed 16-bit values. */
1057 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1058 _mm_max_pi16 (__m64 __A, __m64 __B)
1060 return (__m64) __builtin_ia32_pmaxsw ((__v4hi)__A, (__v4hi)__B);
1063 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1064 _m_pmaxsw (__m64 __A, __m64 __B)
1066 return _mm_max_pi16 (__A, __B);
1069 /* Compute the element-wise maximum of unsigned 8-bit values. */
1070 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1071 _mm_max_pu8 (__m64 __A, __m64 __B)
1073 return (__m64) __builtin_ia32_pmaxub ((__v8qi)__A, (__v8qi)__B);
1076 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1077 _m_pmaxub (__m64 __A, __m64 __B)
1079 return _mm_max_pu8 (__A, __B);
1082 /* Compute the element-wise minimum of signed 16-bit values. */
1083 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1084 _mm_min_pi16 (__m64 __A, __m64 __B)
1086 return (__m64) __builtin_ia32_pminsw ((__v4hi)__A, (__v4hi)__B);
1089 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1090 _m_pminsw (__m64 __A, __m64 __B)
1092 return _mm_min_pi16 (__A, __B);
1095 /* Compute the element-wise minimum of unsigned 8-bit values. */
1096 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1097 _mm_min_pu8 (__m64 __A, __m64 __B)
1099 return (__m64) __builtin_ia32_pminub ((__v8qi)__A, (__v8qi)__B);
1102 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1103 _m_pminub (__m64 __A, __m64 __B)
1105 return _mm_min_pu8 (__A, __B);
1108 /* Create an 8-bit mask of the signs of 8-bit values. */
1109 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1110 _mm_movemask_pi8 (__m64 __A)
1112 return __builtin_ia32_pmovmskb ((__v8qi)__A);
1115 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1116 _m_pmovmskb (__m64 __A)
1118 return _mm_movemask_pi8 (__A);
1121 /* Multiply four unsigned 16-bit values in A by four unsigned 16-bit values
1122 in B and produce the high 16 bits of the 32-bit results. */
1123 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1124 _mm_mulhi_pu16 (__m64 __A, __m64 __B)
1126 return (__m64) __builtin_ia32_pmulhuw ((__v4hi)__A, (__v4hi)__B);
1129 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1130 _m_pmulhuw (__m64 __A, __m64 __B)
1132 return _mm_mulhi_pu16 (__A, __B);
1135 /* Return a combination of the four 16-bit values in A. The selector
1136 must be an immediate. */
1137 #ifdef __OPTIMIZE__
1138 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1139 _mm_shuffle_pi16 (__m64 __A, int const __N)
1141 return (__m64) __builtin_ia32_pshufw ((__v4hi)__A, __N);
1144 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1145 _m_pshufw (__m64 __A, int const __N)
1147 return _mm_shuffle_pi16 (__A, __N);
1149 #else
1150 #define _mm_shuffle_pi16(A, N) \
1151 ((__m64) __builtin_ia32_pshufw ((__v4hi)(__m64)(A), (int)(N)))
1153 #define _m_pshufw(A, N) _mm_shuffle_pi16 (A, N)
1154 #endif
1156 /* Conditionally store byte elements of A into P. The high bit of each
1157 byte in the selector N determines whether the corresponding byte from
1158 A is stored. */
1159 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1160 _mm_maskmove_si64 (__m64 __A, __m64 __N, char *__P)
1162 __builtin_ia32_maskmovq ((__v8qi)__A, (__v8qi)__N, __P);
1165 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1166 _m_maskmovq (__m64 __A, __m64 __N, char *__P)
1168 _mm_maskmove_si64 (__A, __N, __P);
1171 /* Compute the rounded averages of the unsigned 8-bit values in A and B. */
1172 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1173 _mm_avg_pu8 (__m64 __A, __m64 __B)
1175 return (__m64) __builtin_ia32_pavgb ((__v8qi)__A, (__v8qi)__B);
1178 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1179 _m_pavgb (__m64 __A, __m64 __B)
1181 return _mm_avg_pu8 (__A, __B);
1184 /* Compute the rounded averages of the unsigned 16-bit values in A and B. */
1185 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1186 _mm_avg_pu16 (__m64 __A, __m64 __B)
1188 return (__m64) __builtin_ia32_pavgw ((__v4hi)__A, (__v4hi)__B);
1191 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1192 _m_pavgw (__m64 __A, __m64 __B)
1194 return _mm_avg_pu16 (__A, __B);
1197 /* Compute the sum of the absolute differences of the unsigned 8-bit
1198 values in A and B. Return the value in the lower 16-bit word; the
1199 upper words are cleared. */
1200 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1201 _mm_sad_pu8 (__m64 __A, __m64 __B)
1203 return (__m64) __builtin_ia32_psadbw ((__v8qi)__A, (__v8qi)__B);
1206 extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1207 _m_psadbw (__m64 __A, __m64 __B)
1209 return _mm_sad_pu8 (__A, __B);
1212 /* Stores the data in A to the address P without polluting the caches. */
1213 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1214 _mm_stream_pi (__m64 *__P, __m64 __A)
1216 __builtin_ia32_movntq ((unsigned long long *)__P, (unsigned long long)__A);
1219 /* Likewise. The address must be 16-byte aligned. */
1220 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1221 _mm_stream_ps (float *__P, __m128 __A)
1223 __builtin_ia32_movntps (__P, (__v4sf)__A);
1226 /* Guarantees that every preceding store is globally visible before
1227 any subsequent store. */
1228 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1229 _mm_sfence (void)
1231 __builtin_ia32_sfence ();
1234 /* Transpose the 4x4 matrix composed of row[0-3]. */
1235 #define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) \
1236 do { \
1237 __v4sf __r0 = (row0), __r1 = (row1), __r2 = (row2), __r3 = (row3); \
1238 __v4sf __t0 = __builtin_ia32_unpcklps (__r0, __r1); \
1239 __v4sf __t1 = __builtin_ia32_unpcklps (__r2, __r3); \
1240 __v4sf __t2 = __builtin_ia32_unpckhps (__r0, __r1); \
1241 __v4sf __t3 = __builtin_ia32_unpckhps (__r2, __r3); \
1242 (row0) = __builtin_ia32_movlhps (__t0, __t1); \
1243 (row1) = __builtin_ia32_movhlps (__t1, __t0); \
1244 (row2) = __builtin_ia32_movlhps (__t2, __t3); \
1245 (row3) = __builtin_ia32_movhlps (__t3, __t2); \
1246 } while (0)
1248 /* For backward source compatibility. */
1249 # include <emmintrin.h>
1251 #ifdef __DISABLE_SSE__
1252 #undef __DISABLE_SSE__
1253 #pragma GCC pop_options
1254 #endif /* __DISABLE_SSE__ */
1256 /* The execution of the next instruction is delayed by an implementation
1257 specific amount of time. The instruction does not modify the
1258 architectural state. This is after the pop_options pragma because
1259 it does not require SSE support in the processor--the encoding is a
1260 nop on processors that do not support it. */
1261 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
1262 _mm_pause (void)
1264 __builtin_ia32_pause ();
1267 #endif /* _XMMINTRIN_H_INCLUDED */