OSDN Git Service

2006-04-27 Dirk Mueller <dmueller@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / xmmintrin.h
1 /* Copyright (C) 2002, 2003, 2004, 2005, 2006
2    Free Software Foundation, Inc.
3
4    This file is part of GCC.
5
6    GCC is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    GCC is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with GCC; see the file COPYING.  If not, write to
18    the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19    Boston, MA 02110-1301, USA.  */
20
21 /* As a special exception, if you include this header file into source
22    files compiled by GCC, this header file does not by itself cause
23    the resulting executable to be covered by the GNU General Public
24    License.  This exception does not however invalidate any other
25    reasons why the executable file might be covered by the GNU General
26    Public License.  */
27
28 /* Implemented from the specification included in the Intel C++ Compiler
29    User Guide and Reference, version 9.0.  */
30
31 #ifndef _XMMINTRIN_H_INCLUDED
32 #define _XMMINTRIN_H_INCLUDED
33
34 #ifndef __SSE__
35 # error "SSE instruction set not enabled"
36 #else
37
38 /* We need type definitions from the MMX header file.  */
39 #include <mmintrin.h>
40
41 /* Get _mm_malloc () and _mm_free ().  */
42 #include <mm_malloc.h>
43
44 /* The data type intended for user use.  */
45 typedef float __m128 __attribute__ ((__vector_size__ (16)));
46
47 /* Internal data types for implementing the intrinsics.  */
48 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
49
50 /* Create a selector for use with the SHUFPS instruction.  */
51 #define _MM_SHUFFLE(fp3,fp2,fp1,fp0) \
52  (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | (fp0))
53
54 /* Constants for use with _mm_prefetch.  */
55 enum _mm_hint
56 {
57   _MM_HINT_T0 = 3,
58   _MM_HINT_T1 = 2,
59   _MM_HINT_T2 = 1,
60   _MM_HINT_NTA = 0
61 };
62
63 /* Bits in the MXCSR.  */
64 #define _MM_EXCEPT_MASK       0x003f
65 #define _MM_EXCEPT_INVALID    0x0001
66 #define _MM_EXCEPT_DENORM     0x0002
67 #define _MM_EXCEPT_DIV_ZERO   0x0004
68 #define _MM_EXCEPT_OVERFLOW   0x0008
69 #define _MM_EXCEPT_UNDERFLOW  0x0010
70 #define _MM_EXCEPT_INEXACT    0x0020
71
72 #define _MM_MASK_MASK         0x1f80
73 #define _MM_MASK_INVALID      0x0080
74 #define _MM_MASK_DENORM       0x0100
75 #define _MM_MASK_DIV_ZERO     0x0200
76 #define _MM_MASK_OVERFLOW     0x0400
77 #define _MM_MASK_UNDERFLOW    0x0800
78 #define _MM_MASK_INEXACT      0x1000
79
80 #define _MM_ROUND_MASK        0x6000
81 #define _MM_ROUND_NEAREST     0x0000
82 #define _MM_ROUND_DOWN        0x2000
83 #define _MM_ROUND_UP          0x4000
84 #define _MM_ROUND_TOWARD_ZERO 0x6000
85
86 #define _MM_FLUSH_ZERO_MASK   0x8000
87 #define _MM_FLUSH_ZERO_ON     0x8000
88 #define _MM_FLUSH_ZERO_OFF    0x0000
89
90 /* Create a vector of zeros.  */
91 static __inline __m128 __attribute__((__always_inline__))
92 _mm_setzero_ps (void)
93 {
94   return __extension__ (__m128){ 0.0f, 0.0f, 0.0f, 0.0f };
95 }
96
97 /* Perform the respective operation on the lower SPFP (single-precision
98    floating-point) values of A and B; the upper three SPFP values are
99    passed through from A.  */
100
101 static __inline __m128 __attribute__((__always_inline__))
102 _mm_add_ss (__m128 __A, __m128 __B)
103 {
104   return (__m128) __builtin_ia32_addss ((__v4sf)__A, (__v4sf)__B);
105 }
106
107 static __inline __m128 __attribute__((__always_inline__))
108 _mm_sub_ss (__m128 __A, __m128 __B)
109 {
110   return (__m128) __builtin_ia32_subss ((__v4sf)__A, (__v4sf)__B);
111 }
112
113 static __inline __m128 __attribute__((__always_inline__))
114 _mm_mul_ss (__m128 __A, __m128 __B)
115 {
116   return (__m128) __builtin_ia32_mulss ((__v4sf)__A, (__v4sf)__B);
117 }
118
119 static __inline __m128 __attribute__((__always_inline__))
120 _mm_div_ss (__m128 __A, __m128 __B)
121 {
122   return (__m128) __builtin_ia32_divss ((__v4sf)__A, (__v4sf)__B);
123 }
124
125 static __inline __m128 __attribute__((__always_inline__))
126 _mm_sqrt_ss (__m128 __A)
127 {
128   return (__m128) __builtin_ia32_sqrtss ((__v4sf)__A);
129 }
130
131 static __inline __m128 __attribute__((__always_inline__))
132 _mm_rcp_ss (__m128 __A)
133 {
134   return (__m128) __builtin_ia32_rcpss ((__v4sf)__A);
135 }
136
137 static __inline __m128 __attribute__((__always_inline__))
138 _mm_rsqrt_ss (__m128 __A)
139 {
140   return (__m128) __builtin_ia32_rsqrtss ((__v4sf)__A);
141 }
142
143 static __inline __m128 __attribute__((__always_inline__))
144 _mm_min_ss (__m128 __A, __m128 __B)
145 {
146   return (__m128) __builtin_ia32_minss ((__v4sf)__A, (__v4sf)__B);
147 }
148
149 static __inline __m128 __attribute__((__always_inline__))
150 _mm_max_ss (__m128 __A, __m128 __B)
151 {
152   return (__m128) __builtin_ia32_maxss ((__v4sf)__A, (__v4sf)__B);
153 }
154
155 /* Perform the respective operation on the four SPFP values in A and B.  */
156
157 static __inline __m128 __attribute__((__always_inline__))
158 _mm_add_ps (__m128 __A, __m128 __B)
159 {
160   return (__m128) __builtin_ia32_addps ((__v4sf)__A, (__v4sf)__B);
161 }
162
163 static __inline __m128 __attribute__((__always_inline__))
164 _mm_sub_ps (__m128 __A, __m128 __B)
165 {
166   return (__m128) __builtin_ia32_subps ((__v4sf)__A, (__v4sf)__B);
167 }
168
169 static __inline __m128 __attribute__((__always_inline__))
170 _mm_mul_ps (__m128 __A, __m128 __B)
171 {
172   return (__m128) __builtin_ia32_mulps ((__v4sf)__A, (__v4sf)__B);
173 }
174
175 static __inline __m128 __attribute__((__always_inline__))
176 _mm_div_ps (__m128 __A, __m128 __B)
177 {
178   return (__m128) __builtin_ia32_divps ((__v4sf)__A, (__v4sf)__B);
179 }
180
181 static __inline __m128 __attribute__((__always_inline__))
182 _mm_sqrt_ps (__m128 __A)
183 {
184   return (__m128) __builtin_ia32_sqrtps ((__v4sf)__A);
185 }
186
187 static __inline __m128 __attribute__((__always_inline__))
188 _mm_rcp_ps (__m128 __A)
189 {
190   return (__m128) __builtin_ia32_rcpps ((__v4sf)__A);
191 }
192
193 static __inline __m128 __attribute__((__always_inline__))
194 _mm_rsqrt_ps (__m128 __A)
195 {
196   return (__m128) __builtin_ia32_rsqrtps ((__v4sf)__A);
197 }
198
199 static __inline __m128 __attribute__((__always_inline__))
200 _mm_min_ps (__m128 __A, __m128 __B)
201 {
202   return (__m128) __builtin_ia32_minps ((__v4sf)__A, (__v4sf)__B);
203 }
204
205 static __inline __m128 __attribute__((__always_inline__))
206 _mm_max_ps (__m128 __A, __m128 __B)
207 {
208   return (__m128) __builtin_ia32_maxps ((__v4sf)__A, (__v4sf)__B);
209 }
210
211 /* Perform logical bit-wise operations on 128-bit values.  */
212
213 static __inline __m128 __attribute__((__always_inline__))
214 _mm_and_ps (__m128 __A, __m128 __B)
215 {
216   return __builtin_ia32_andps (__A, __B);
217 }
218
219 static __inline __m128 __attribute__((__always_inline__))
220 _mm_andnot_ps (__m128 __A, __m128 __B)
221 {
222   return __builtin_ia32_andnps (__A, __B);
223 }
224
225 static __inline __m128 __attribute__((__always_inline__))
226 _mm_or_ps (__m128 __A, __m128 __B)
227 {
228   return __builtin_ia32_orps (__A, __B);
229 }
230
231 static __inline __m128 __attribute__((__always_inline__))
232 _mm_xor_ps (__m128 __A, __m128 __B)
233 {
234   return __builtin_ia32_xorps (__A, __B);
235 }
236
237 /* Perform a comparison on the lower SPFP values of A and B.  If the
238    comparison is true, place a mask of all ones in the result, otherwise a
239    mask of zeros.  The upper three SPFP values are passed through from A.  */
240
241 static __inline __m128 __attribute__((__always_inline__))
242 _mm_cmpeq_ss (__m128 __A, __m128 __B)
243 {
244   return (__m128) __builtin_ia32_cmpeqss ((__v4sf)__A, (__v4sf)__B);
245 }
246
247 static __inline __m128 __attribute__((__always_inline__))
248 _mm_cmplt_ss (__m128 __A, __m128 __B)
249 {
250   return (__m128) __builtin_ia32_cmpltss ((__v4sf)__A, (__v4sf)__B);
251 }
252
253 static __inline __m128 __attribute__((__always_inline__))
254 _mm_cmple_ss (__m128 __A, __m128 __B)
255 {
256   return (__m128) __builtin_ia32_cmpless ((__v4sf)__A, (__v4sf)__B);
257 }
258
259 static __inline __m128 __attribute__((__always_inline__))
260 _mm_cmpgt_ss (__m128 __A, __m128 __B)
261 {
262   return (__m128) __builtin_ia32_movss ((__v4sf) __A,
263                                         (__v4sf)
264                                         __builtin_ia32_cmpltss ((__v4sf) __B,
265                                                                 (__v4sf)
266                                                                 __A));
267 }
268
269 static __inline __m128 __attribute__((__always_inline__))
270 _mm_cmpge_ss (__m128 __A, __m128 __B)
271 {
272   return (__m128) __builtin_ia32_movss ((__v4sf) __A,
273                                         (__v4sf)
274                                         __builtin_ia32_cmpless ((__v4sf) __B,
275                                                                 (__v4sf)
276                                                                 __A));
277 }
278
279 static __inline __m128 __attribute__((__always_inline__))
280 _mm_cmpneq_ss (__m128 __A, __m128 __B)
281 {
282   return (__m128) __builtin_ia32_cmpneqss ((__v4sf)__A, (__v4sf)__B);
283 }
284
285 static __inline __m128 __attribute__((__always_inline__))
286 _mm_cmpnlt_ss (__m128 __A, __m128 __B)
287 {
288   return (__m128) __builtin_ia32_cmpnltss ((__v4sf)__A, (__v4sf)__B);
289 }
290
291 static __inline __m128 __attribute__((__always_inline__))
292 _mm_cmpnle_ss (__m128 __A, __m128 __B)
293 {
294   return (__m128) __builtin_ia32_cmpnless ((__v4sf)__A, (__v4sf)__B);
295 }
296
297 static __inline __m128 __attribute__((__always_inline__))
298 _mm_cmpngt_ss (__m128 __A, __m128 __B)
299 {
300   return (__m128) __builtin_ia32_movss ((__v4sf) __A,
301                                         (__v4sf)
302                                         __builtin_ia32_cmpnltss ((__v4sf) __B,
303                                                                  (__v4sf)
304                                                                  __A));
305 }
306
307 static __inline __m128 __attribute__((__always_inline__))
308 _mm_cmpnge_ss (__m128 __A, __m128 __B)
309 {
310   return (__m128) __builtin_ia32_movss ((__v4sf) __A,
311                                         (__v4sf)
312                                         __builtin_ia32_cmpnless ((__v4sf) __B,
313                                                                  (__v4sf)
314                                                                  __A));
315 }
316
317 static __inline __m128 __attribute__((__always_inline__))
318 _mm_cmpord_ss (__m128 __A, __m128 __B)
319 {
320   return (__m128) __builtin_ia32_cmpordss ((__v4sf)__A, (__v4sf)__B);
321 }
322
323 static __inline __m128 __attribute__((__always_inline__))
324 _mm_cmpunord_ss (__m128 __A, __m128 __B)
325 {
326   return (__m128) __builtin_ia32_cmpunordss ((__v4sf)__A, (__v4sf)__B);
327 }
328
329 /* Perform a comparison on the four SPFP values of A and B.  For each
330    element, if the comparison is true, place a mask of all ones in the
331    result, otherwise a mask of zeros.  */
332
333 static __inline __m128 __attribute__((__always_inline__))
334 _mm_cmpeq_ps (__m128 __A, __m128 __B)
335 {
336   return (__m128) __builtin_ia32_cmpeqps ((__v4sf)__A, (__v4sf)__B);
337 }
338
339 static __inline __m128 __attribute__((__always_inline__))
340 _mm_cmplt_ps (__m128 __A, __m128 __B)
341 {
342   return (__m128) __builtin_ia32_cmpltps ((__v4sf)__A, (__v4sf)__B);
343 }
344
345 static __inline __m128 __attribute__((__always_inline__))
346 _mm_cmple_ps (__m128 __A, __m128 __B)
347 {
348   return (__m128) __builtin_ia32_cmpleps ((__v4sf)__A, (__v4sf)__B);
349 }
350
351 static __inline __m128 __attribute__((__always_inline__))
352 _mm_cmpgt_ps (__m128 __A, __m128 __B)
353 {
354   return (__m128) __builtin_ia32_cmpgtps ((__v4sf)__A, (__v4sf)__B);
355 }
356
357 static __inline __m128 __attribute__((__always_inline__))
358 _mm_cmpge_ps (__m128 __A, __m128 __B)
359 {
360   return (__m128) __builtin_ia32_cmpgeps ((__v4sf)__A, (__v4sf)__B);
361 }
362
363 static __inline __m128 __attribute__((__always_inline__))
364 _mm_cmpneq_ps (__m128 __A, __m128 __B)
365 {
366   return (__m128) __builtin_ia32_cmpneqps ((__v4sf)__A, (__v4sf)__B);
367 }
368
369 static __inline __m128 __attribute__((__always_inline__))
370 _mm_cmpnlt_ps (__m128 __A, __m128 __B)
371 {
372   return (__m128) __builtin_ia32_cmpnltps ((__v4sf)__A, (__v4sf)__B);
373 }
374
375 static __inline __m128 __attribute__((__always_inline__))
376 _mm_cmpnle_ps (__m128 __A, __m128 __B)
377 {
378   return (__m128) __builtin_ia32_cmpnleps ((__v4sf)__A, (__v4sf)__B);
379 }
380
381 static __inline __m128 __attribute__((__always_inline__))
382 _mm_cmpngt_ps (__m128 __A, __m128 __B)
383 {
384   return (__m128) __builtin_ia32_cmpngtps ((__v4sf)__A, (__v4sf)__B);
385 }
386
387 static __inline __m128 __attribute__((__always_inline__))
388 _mm_cmpnge_ps (__m128 __A, __m128 __B)
389 {
390   return (__m128) __builtin_ia32_cmpngeps ((__v4sf)__A, (__v4sf)__B);
391 }
392
393 static __inline __m128 __attribute__((__always_inline__))
394 _mm_cmpord_ps (__m128 __A, __m128 __B)
395 {
396   return (__m128) __builtin_ia32_cmpordps ((__v4sf)__A, (__v4sf)__B);
397 }
398
399 static __inline __m128 __attribute__((__always_inline__))
400 _mm_cmpunord_ps (__m128 __A, __m128 __B)
401 {
402   return (__m128) __builtin_ia32_cmpunordps ((__v4sf)__A, (__v4sf)__B);
403 }
404
405 /* Compare the lower SPFP values of A and B and return 1 if true
406    and 0 if false.  */
407
408 static __inline int __attribute__((__always_inline__))
409 _mm_comieq_ss (__m128 __A, __m128 __B)
410 {
411   return __builtin_ia32_comieq ((__v4sf)__A, (__v4sf)__B);
412 }
413
414 static __inline int __attribute__((__always_inline__))
415 _mm_comilt_ss (__m128 __A, __m128 __B)
416 {
417   return __builtin_ia32_comilt ((__v4sf)__A, (__v4sf)__B);
418 }
419
420 static __inline int __attribute__((__always_inline__))
421 _mm_comile_ss (__m128 __A, __m128 __B)
422 {
423   return __builtin_ia32_comile ((__v4sf)__A, (__v4sf)__B);
424 }
425
426 static __inline int __attribute__((__always_inline__))
427 _mm_comigt_ss (__m128 __A, __m128 __B)
428 {
429   return __builtin_ia32_comigt ((__v4sf)__A, (__v4sf)__B);
430 }
431
432 static __inline int __attribute__((__always_inline__))
433 _mm_comige_ss (__m128 __A, __m128 __B)
434 {
435   return __builtin_ia32_comige ((__v4sf)__A, (__v4sf)__B);
436 }
437
438 static __inline int __attribute__((__always_inline__))
439 _mm_comineq_ss (__m128 __A, __m128 __B)
440 {
441   return __builtin_ia32_comineq ((__v4sf)__A, (__v4sf)__B);
442 }
443
444 static __inline int __attribute__((__always_inline__))
445 _mm_ucomieq_ss (__m128 __A, __m128 __B)
446 {
447   return __builtin_ia32_ucomieq ((__v4sf)__A, (__v4sf)__B);
448 }
449
450 static __inline int __attribute__((__always_inline__))
451 _mm_ucomilt_ss (__m128 __A, __m128 __B)
452 {
453   return __builtin_ia32_ucomilt ((__v4sf)__A, (__v4sf)__B);
454 }
455
456 static __inline int __attribute__((__always_inline__))
457 _mm_ucomile_ss (__m128 __A, __m128 __B)
458 {
459   return __builtin_ia32_ucomile ((__v4sf)__A, (__v4sf)__B);
460 }
461
462 static __inline int __attribute__((__always_inline__))
463 _mm_ucomigt_ss (__m128 __A, __m128 __B)
464 {
465   return __builtin_ia32_ucomigt ((__v4sf)__A, (__v4sf)__B);
466 }
467
468 static __inline int __attribute__((__always_inline__))
469 _mm_ucomige_ss (__m128 __A, __m128 __B)
470 {
471   return __builtin_ia32_ucomige ((__v4sf)__A, (__v4sf)__B);
472 }
473
474 static __inline int __attribute__((__always_inline__))
475 _mm_ucomineq_ss (__m128 __A, __m128 __B)
476 {
477   return __builtin_ia32_ucomineq ((__v4sf)__A, (__v4sf)__B);
478 }
479
480 /* Convert the lower SPFP value to a 32-bit integer according to the current
481    rounding mode.  */
482 static __inline int __attribute__((__always_inline__))
483 _mm_cvtss_si32 (__m128 __A)
484 {
485   return __builtin_ia32_cvtss2si ((__v4sf) __A);
486 }
487
488 static __inline int __attribute__((__always_inline__))
489 _mm_cvt_ss2si (__m128 __A)
490 {
491   return _mm_cvtss_si32 (__A);
492 }
493
494 #ifdef __x86_64__
495 /* Convert the lower SPFP value to a 32-bit integer according to the
496    current rounding mode.  */
497
498 /* Intel intrinsic.  */
499 static __inline long long __attribute__((__always_inline__))
500 _mm_cvtss_si64 (__m128 __A)
501 {
502   return __builtin_ia32_cvtss2si64 ((__v4sf) __A);
503 }
504
505 /* Microsoft intrinsic.  */
506 static __inline long long __attribute__((__always_inline__))
507 _mm_cvtss_si64x (__m128 __A)
508 {
509   return __builtin_ia32_cvtss2si64 ((__v4sf) __A);
510 }
511 #endif
512
513 /* Convert the two lower SPFP values to 32-bit integers according to the
514    current rounding mode.  Return the integers in packed form.  */
515 static __inline __m64 __attribute__((__always_inline__))
516 _mm_cvtps_pi32 (__m128 __A)
517 {
518   return (__m64) __builtin_ia32_cvtps2pi ((__v4sf) __A);
519 }
520
521 static __inline __m64 __attribute__((__always_inline__))
522 _mm_cvt_ps2pi (__m128 __A)
523 {
524   return _mm_cvtps_pi32 (__A);
525 }
526
527 /* Truncate the lower SPFP value to a 32-bit integer.  */
528 static __inline int __attribute__((__always_inline__))
529 _mm_cvttss_si32 (__m128 __A)
530 {
531   return __builtin_ia32_cvttss2si ((__v4sf) __A);
532 }
533
534 static __inline int __attribute__((__always_inline__))
535 _mm_cvtt_ss2si (__m128 __A)
536 {
537   return _mm_cvttss_si32 (__A);
538 }
539
540 #ifdef __x86_64__
541 /* Truncate the lower SPFP value to a 32-bit integer.  */
542
543 /* Intel intrinsic.  */
544 static __inline long long __attribute__((__always_inline__))
545 _mm_cvttss_si64 (__m128 __A)
546 {
547   return __builtin_ia32_cvttss2si64 ((__v4sf) __A);
548 }
549
550 /* Microsoft intrinsic.  */
551 static __inline long long __attribute__((__always_inline__))
552 _mm_cvttss_si64x (__m128 __A)
553 {
554   return __builtin_ia32_cvttss2si64 ((__v4sf) __A);
555 }
556 #endif
557
558 /* Truncate the two lower SPFP values to 32-bit integers.  Return the
559    integers in packed form.  */
560 static __inline __m64 __attribute__((__always_inline__))
561 _mm_cvttps_pi32 (__m128 __A)
562 {
563   return (__m64) __builtin_ia32_cvttps2pi ((__v4sf) __A);
564 }
565
566 static __inline __m64 __attribute__((__always_inline__))
567 _mm_cvtt_ps2pi (__m128 __A)
568 {
569   return _mm_cvttps_pi32 (__A);
570 }
571
572 /* Convert B to a SPFP value and insert it as element zero in A.  */
573 static __inline __m128 __attribute__((__always_inline__))
574 _mm_cvtsi32_ss (__m128 __A, int __B)
575 {
576   return (__m128) __builtin_ia32_cvtsi2ss ((__v4sf) __A, __B);
577 }
578
579 static __inline __m128 __attribute__((__always_inline__))
580 _mm_cvt_si2ss (__m128 __A, int __B)
581 {
582   return _mm_cvtsi32_ss (__A, __B);
583 }
584
585 #ifdef __x86_64__
586 /* Convert B to a SPFP value and insert it as element zero in A.  */
587
588 /* Intel intrinsic.  */
589 static __inline __m128 __attribute__((__always_inline__))
590 _mm_cvtsi64_ss (__m128 __A, long long __B)
591 {
592   return (__m128) __builtin_ia32_cvtsi642ss ((__v4sf) __A, __B);
593 }
594
595 /* Microsoft intrinsic.  */
596 static __inline __m128 __attribute__((__always_inline__))
597 _mm_cvtsi64x_ss (__m128 __A, long long __B)
598 {
599   return (__m128) __builtin_ia32_cvtsi642ss ((__v4sf) __A, __B);
600 }
601 #endif
602
603 /* Convert the two 32-bit values in B to SPFP form and insert them
604    as the two lower elements in A.  */
605 static __inline __m128 __attribute__((__always_inline__))
606 _mm_cvtpi32_ps (__m128 __A, __m64 __B)
607 {
608   return (__m128) __builtin_ia32_cvtpi2ps ((__v4sf) __A, (__v2si)__B);
609 }
610
611 static __inline __m128 __attribute__((__always_inline__))
612 _mm_cvt_pi2ps (__m128 __A, __m64 __B)
613 {
614   return _mm_cvtpi32_ps (__A, __B);
615 }
616
617 /* Convert the four signed 16-bit values in A to SPFP form.  */
618 static __inline __m128 __attribute__((__always_inline__))
619 _mm_cvtpi16_ps (__m64 __A)
620 {
621   __v4hi __sign;
622   __v2si __hisi, __losi;
623   __v4sf __r;
624
625   /* This comparison against zero gives us a mask that can be used to
626      fill in the missing sign bits in the unpack operations below, so
627      that we get signed values after unpacking.  */
628   __sign = __builtin_ia32_pcmpgtw ((__v4hi)0LL, (__v4hi)__A);
629
630   /* Convert the four words to doublewords.  */
631   __hisi = (__v2si) __builtin_ia32_punpckhwd ((__v4hi)__A, __sign);
632   __losi = (__v2si) __builtin_ia32_punpcklwd ((__v4hi)__A, __sign);
633
634   /* Convert the doublewords to floating point two at a time.  */
635   __r = (__v4sf) _mm_setzero_ps ();
636   __r = __builtin_ia32_cvtpi2ps (__r, __hisi);
637   __r = __builtin_ia32_movlhps (__r, __r);
638   __r = __builtin_ia32_cvtpi2ps (__r, __losi);
639
640   return (__m128) __r;
641 }
642
643 /* Convert the four unsigned 16-bit values in A to SPFP form.  */
644 static __inline __m128 __attribute__((__always_inline__))
645 _mm_cvtpu16_ps (__m64 __A)
646 {
647   __v2si __hisi, __losi;
648   __v4sf __r;
649
650   /* Convert the four words to doublewords.  */
651   __hisi = (__v2si) __builtin_ia32_punpckhwd ((__v4hi)__A, (__v4hi)0LL);
652   __losi = (__v2si) __builtin_ia32_punpcklwd ((__v4hi)__A, (__v4hi)0LL);
653
654   /* Convert the doublewords to floating point two at a time.  */
655   __r = (__v4sf) _mm_setzero_ps ();
656   __r = __builtin_ia32_cvtpi2ps (__r, __hisi);
657   __r = __builtin_ia32_movlhps (__r, __r);
658   __r = __builtin_ia32_cvtpi2ps (__r, __losi);
659
660   return (__m128) __r;
661 }
662
663 /* Convert the low four signed 8-bit values in A to SPFP form.  */
664 static __inline __m128 __attribute__((__always_inline__))
665 _mm_cvtpi8_ps (__m64 __A)
666 {
667   __v8qi __sign;
668
669   /* This comparison against zero gives us a mask that can be used to
670      fill in the missing sign bits in the unpack operations below, so
671      that we get signed values after unpacking.  */
672   __sign = __builtin_ia32_pcmpgtb ((__v8qi)0LL, (__v8qi)__A);
673
674   /* Convert the four low bytes to words.  */
675   __A = (__m64) __builtin_ia32_punpcklbw ((__v8qi)__A, __sign);
676
677   return _mm_cvtpi16_ps(__A);
678 }
679
680 /* Convert the low four unsigned 8-bit values in A to SPFP form.  */
681 static __inline __m128 __attribute__((__always_inline__))
682 _mm_cvtpu8_ps(__m64 __A)
683 {
684   __A = (__m64) __builtin_ia32_punpcklbw ((__v8qi)__A, (__v8qi)0LL);
685   return _mm_cvtpu16_ps(__A);
686 }
687
688 /* Convert the four signed 32-bit values in A and B to SPFP form.  */
689 static __inline __m128 __attribute__((__always_inline__))
690 _mm_cvtpi32x2_ps(__m64 __A, __m64 __B)
691 {
692   __v4sf __zero = (__v4sf) _mm_setzero_ps ();
693   __v4sf __sfa = __builtin_ia32_cvtpi2ps (__zero, (__v2si)__A);
694   __v4sf __sfb = __builtin_ia32_cvtpi2ps (__zero, (__v2si)__B);
695   return (__m128) __builtin_ia32_movlhps (__sfa, __sfb);
696 }
697
698 /* Convert the four SPFP values in A to four signed 16-bit integers.  */
699 static __inline __m64 __attribute__((__always_inline__))
700 _mm_cvtps_pi16(__m128 __A)
701 {
702   __v4sf __hisf = (__v4sf)__A;
703   __v4sf __losf = __builtin_ia32_movhlps (__hisf, __hisf);
704   __v2si __hisi = __builtin_ia32_cvtps2pi (__hisf);
705   __v2si __losi = __builtin_ia32_cvtps2pi (__losf);
706   return (__m64) __builtin_ia32_packssdw (__hisi, __losi);
707 }
708
709 /* Convert the four SPFP values in A to four signed 8-bit integers.  */
710 static __inline __m64 __attribute__((__always_inline__))
711 _mm_cvtps_pi8(__m128 __A)
712 {
713   __v4hi __tmp = (__v4hi) _mm_cvtps_pi16 (__A);
714   return (__m64) __builtin_ia32_packsswb (__tmp, (__v4hi)0LL);
715 }
716
717 /* Selects four specific SPFP values from A and B based on MASK.  */
718 #if 0
719 static __inline __m128 __attribute__((__always_inline__))
720 _mm_shuffle_ps (__m128 __A, __m128 __B, int __mask)
721 {
722   return (__m128) __builtin_ia32_shufps ((__v4sf)__A, (__v4sf)__B, __mask);
723 }
724 #else
725 #define _mm_shuffle_ps(A, B, MASK) \
726  ((__m128) __builtin_ia32_shufps ((__v4sf)(A), (__v4sf)(B), (MASK)))
727 #endif
728
729
730 /* Selects and interleaves the upper two SPFP values from A and B.  */
731 static __inline __m128 __attribute__((__always_inline__))
732 _mm_unpackhi_ps (__m128 __A, __m128 __B)
733 {
734   return (__m128) __builtin_ia32_unpckhps ((__v4sf)__A, (__v4sf)__B);
735 }
736
737 /* Selects and interleaves the lower two SPFP values from A and B.  */
738 static __inline __m128 __attribute__((__always_inline__))
739 _mm_unpacklo_ps (__m128 __A, __m128 __B)
740 {
741   return (__m128) __builtin_ia32_unpcklps ((__v4sf)__A, (__v4sf)__B);
742 }
743
744 /* Sets the upper two SPFP values with 64-bits of data loaded from P;
745    the lower two values are passed through from A.  */
746 static __inline __m128 __attribute__((__always_inline__))
747 _mm_loadh_pi (__m128 __A, __m64 const *__P)
748 {
749   return (__m128) __builtin_ia32_loadhps ((__v4sf)__A, (__v2si *)__P);
750 }
751
752 /* Stores the upper two SPFP values of A into P.  */
753 static __inline void __attribute__((__always_inline__))
754 _mm_storeh_pi (__m64 *__P, __m128 __A)
755 {
756   __builtin_ia32_storehps ((__v2si *)__P, (__v4sf)__A);
757 }
758
759 /* Moves the upper two values of B into the lower two values of A.  */
760 static __inline __m128 __attribute__((__always_inline__))
761 _mm_movehl_ps (__m128 __A, __m128 __B)
762 {
763   return (__m128) __builtin_ia32_movhlps ((__v4sf)__A, (__v4sf)__B);
764 }
765
766 /* Moves the lower two values of B into the upper two values of A.  */
767 static __inline __m128 __attribute__((__always_inline__))
768 _mm_movelh_ps (__m128 __A, __m128 __B)
769 {
770   return (__m128) __builtin_ia32_movlhps ((__v4sf)__A, (__v4sf)__B);
771 }
772
773 /* Sets the lower two SPFP values with 64-bits of data loaded from P;
774    the upper two values are passed through from A.  */
775 static __inline __m128 __attribute__((__always_inline__))
776 _mm_loadl_pi (__m128 __A, __m64 const *__P)
777 {
778   return (__m128) __builtin_ia32_loadlps ((__v4sf)__A, (__v2si *)__P);
779 }
780
781 /* Stores the lower two SPFP values of A into P.  */
782 static __inline void __attribute__((__always_inline__))
783 _mm_storel_pi (__m64 *__P, __m128 __A)
784 {
785   __builtin_ia32_storelps ((__v2si *)__P, (__v4sf)__A);
786 }
787
788 /* Creates a 4-bit mask from the most significant bits of the SPFP values.  */
789 static __inline int __attribute__((__always_inline__))
790 _mm_movemask_ps (__m128 __A)
791 {
792   return __builtin_ia32_movmskps ((__v4sf)__A);
793 }
794
795 /* Return the contents of the control register.  */
796 static __inline unsigned int __attribute__((__always_inline__))
797 _mm_getcsr (void)
798 {
799   return __builtin_ia32_stmxcsr ();
800 }
801
802 /* Read exception bits from the control register.  */
803 static __inline unsigned int __attribute__((__always_inline__))
804 _MM_GET_EXCEPTION_STATE (void)
805 {
806   return _mm_getcsr() & _MM_EXCEPT_MASK;
807 }
808
809 static __inline unsigned int __attribute__((__always_inline__))
810 _MM_GET_EXCEPTION_MASK (void)
811 {
812   return _mm_getcsr() & _MM_MASK_MASK;
813 }
814
815 static __inline unsigned int __attribute__((__always_inline__))
816 _MM_GET_ROUNDING_MODE (void)
817 {
818   return _mm_getcsr() & _MM_ROUND_MASK;
819 }
820
821 static __inline unsigned int __attribute__((__always_inline__))
822 _MM_GET_FLUSH_ZERO_MODE (void)
823 {
824   return _mm_getcsr() & _MM_FLUSH_ZERO_MASK;
825 }
826
827 /* Set the control register to I.  */
828 static __inline void __attribute__((__always_inline__))
829 _mm_setcsr (unsigned int __I)
830 {
831   __builtin_ia32_ldmxcsr (__I);
832 }
833
834 /* Set exception bits in the control register.  */
835 static __inline void __attribute__((__always_inline__))
836 _MM_SET_EXCEPTION_STATE(unsigned int __mask)
837 {
838   _mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | __mask);
839 }
840
841 static __inline void __attribute__((__always_inline__))
842 _MM_SET_EXCEPTION_MASK (unsigned int __mask)
843 {
844   _mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | __mask);
845 }
846
847 static __inline void __attribute__((__always_inline__))
848 _MM_SET_ROUNDING_MODE (unsigned int __mode)
849 {
850   _mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | __mode);
851 }
852
853 static __inline void __attribute__((__always_inline__))
854 _MM_SET_FLUSH_ZERO_MODE (unsigned int __mode)
855 {
856   _mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | __mode);
857 }
858
859 /* Create a vector with element 0 as F and the rest zero.  */
860 static __inline __m128 __attribute__((__always_inline__))
861 _mm_set_ss (float __F)
862 {
863   return __extension__ (__m128)(__v4sf){ __F, 0, 0, 0 };
864 }
865
866 /* Create a vector with all four elements equal to F.  */
867 static __inline __m128 __attribute__((__always_inline__))
868 _mm_set1_ps (float __F)
869 {
870   return __extension__ (__m128)(__v4sf){ __F, __F, __F, __F };
871 }
872
873 static __inline __m128 __attribute__((__always_inline__))
874 _mm_set_ps1 (float __F)
875 {
876   return _mm_set1_ps (__F);
877 }
878
879 /* Create a vector with element 0 as *P and the rest zero.  */
880 static __inline __m128 __attribute__((__always_inline__))
881 _mm_load_ss (float const *__P)
882 {
883   return _mm_set_ss (*__P);
884 }
885
886 /* Create a vector with all four elements equal to *P.  */
887 static __inline __m128 __attribute__((__always_inline__))
888 _mm_load1_ps (float const *__P)
889 {
890   return _mm_set1_ps (*__P);
891 }
892
893 static __inline __m128 __attribute__((__always_inline__))
894 _mm_load_ps1 (float const *__P)
895 {
896   return _mm_load1_ps (__P);
897 }
898
899 /* Load four SPFP values from P.  The address must be 16-byte aligned.  */
900 static __inline __m128 __attribute__((__always_inline__))
901 _mm_load_ps (float const *__P)
902 {
903   return (__m128) *(__v4sf *)__P;
904 }
905
906 /* Load four SPFP values from P.  The address need not be 16-byte aligned.  */
907 static __inline __m128 __attribute__((__always_inline__))
908 _mm_loadu_ps (float const *__P)
909 {
910   return (__m128) __builtin_ia32_loadups (__P);
911 }
912
913 /* Load four SPFP values in reverse order.  The address must be aligned.  */
914 static __inline __m128 __attribute__((__always_inline__))
915 _mm_loadr_ps (float const *__P)
916 {
917   __v4sf __tmp = *(__v4sf *)__P;
918   return (__m128) __builtin_ia32_shufps (__tmp, __tmp, _MM_SHUFFLE (0,1,2,3));
919 }
920
921 /* Create the vector [Z Y X W].  */
922 static __inline __m128 __attribute__((__always_inline__))
923 _mm_set_ps (const float __Z, const float __Y, const float __X, const float __W)
924 {
925   return __extension__ (__m128)(__v4sf){ __W, __X, __Y, __Z };
926 }
927
928 /* Create the vector [W X Y Z].  */
929 static __inline __m128 __attribute__((__always_inline__))
930 _mm_setr_ps (float __Z, float __Y, float __X, float __W)
931 {
932   return __extension__ (__m128)(__v4sf){ __Z, __Y, __X, __W };
933 }
934
935 /* Stores the lower SPFP value.  */
936 static __inline void __attribute__((__always_inline__))
937 _mm_store_ss (float *__P, __m128 __A)
938 {
939   *__P = __builtin_ia32_vec_ext_v4sf ((__v4sf)__A, 0);
940 }
941
942 static __inline float __attribute__((__always_inline__))
943 _mm_cvtss_f32 (__m128 __A)
944 {
945   return __builtin_ia32_vec_ext_v4sf ((__v4sf)__A, 0);
946 }
947
948 /* Store four SPFP values.  The address must be 16-byte aligned.  */
949 static __inline void __attribute__((__always_inline__))
950 _mm_store_ps (float *__P, __m128 __A)
951 {
952   *(__v4sf *)__P = (__v4sf)__A;
953 }
954
955 /* Store four SPFP values.  The address need not be 16-byte aligned.  */
956 static __inline void __attribute__((__always_inline__))
957 _mm_storeu_ps (float *__P, __m128 __A)
958 {
959   __builtin_ia32_storeups (__P, (__v4sf)__A);
960 }
961
962 /* Store the lower SPFP value across four words.  */
963 static __inline void __attribute__((__always_inline__))
964 _mm_store1_ps (float *__P, __m128 __A)
965 {
966   __v4sf __va = (__v4sf)__A;
967   __v4sf __tmp = __builtin_ia32_shufps (__va, __va, _MM_SHUFFLE (0,0,0,0));
968   _mm_storeu_ps (__P, __tmp);
969 }
970
971 static __inline void __attribute__((__always_inline__))
972 _mm_store_ps1 (float *__P, __m128 __A)
973 {
974   _mm_store1_ps (__P, __A);
975 }
976
977 /* Store four SPFP values in reverse order.  The address must be aligned.  */
978 static __inline void __attribute__((__always_inline__))
979 _mm_storer_ps (float *__P, __m128 __A)
980 {
981   __v4sf __va = (__v4sf)__A;
982   __v4sf __tmp = __builtin_ia32_shufps (__va, __va, _MM_SHUFFLE (0,1,2,3));
983   _mm_store_ps (__P, __tmp);
984 }
985
986 /* Sets the low SPFP value of A from the low value of B.  */
987 static __inline __m128 __attribute__((__always_inline__))
988 _mm_move_ss (__m128 __A, __m128 __B)
989 {
990   return (__m128) __builtin_ia32_movss ((__v4sf)__A, (__v4sf)__B);
991 }
992
993 /* Extracts one of the four words of A.  The selector N must be immediate.  */
994 #if 0
995 static __inline int __attribute__((__always_inline__))
996 _mm_extract_pi16 (__m64 const __A, int const __N)
997 {
998   return __builtin_ia32_vec_ext_v4hi ((__v4hi)__A, __N);
999 }
1000
1001 static __inline int __attribute__((__always_inline__))
1002 _m_pextrw (__m64 const __A, int const __N)
1003 {
1004   return _mm_extract_pi16 (__A, __N);
1005 }
1006 #else
1007 #define _mm_extract_pi16(A, N)  __builtin_ia32_vec_ext_v4hi ((__v4hi)(A), (N))
1008 #define _m_pextrw(A, N)         _mm_extract_pi16((A), (N))
1009 #endif
1010
1011 /* Inserts word D into one of four words of A.  The selector N must be
1012    immediate.  */
1013 #if 0
1014 static __inline __m64 __attribute__((__always_inline__))
1015 _mm_insert_pi16 (__m64 const __A, int const __D, int const __N)
1016 {
1017   return (__m64) __builtin_ia32_vec_set_v4hi ((__v4hi)__A, __D, __N);
1018 }
1019
1020 static __inline __m64 __attribute__((__always_inline__))
1021 _m_pinsrw (__m64 const __A, int const __D, int const __N)
1022 {
1023   return _mm_insert_pi16 (__A, __D, __N);
1024 }
1025 #else
1026 #define _mm_insert_pi16(A, D, N) \
1027   ((__m64) __builtin_ia32_vec_set_v4hi ((__v4hi)(A), (D), (N)))
1028 #define _m_pinsrw(A, D, N)       _mm_insert_pi16((A), (D), (N))
1029 #endif
1030
1031 /* Compute the element-wise maximum of signed 16-bit values.  */
1032 static __inline __m64 __attribute__((__always_inline__))
1033 _mm_max_pi16 (__m64 __A, __m64 __B)
1034 {
1035   return (__m64) __builtin_ia32_pmaxsw ((__v4hi)__A, (__v4hi)__B);
1036 }
1037
1038 static __inline __m64 __attribute__((__always_inline__))
1039 _m_pmaxsw (__m64 __A, __m64 __B)
1040 {
1041   return _mm_max_pi16 (__A, __B);
1042 }
1043
1044 /* Compute the element-wise maximum of unsigned 8-bit values.  */
1045 static __inline __m64 __attribute__((__always_inline__))
1046 _mm_max_pu8 (__m64 __A, __m64 __B)
1047 {
1048   return (__m64) __builtin_ia32_pmaxub ((__v8qi)__A, (__v8qi)__B);
1049 }
1050
1051 static __inline __m64 __attribute__((__always_inline__))
1052 _m_pmaxub (__m64 __A, __m64 __B)
1053 {
1054   return _mm_max_pu8 (__A, __B);
1055 }
1056
1057 /* Compute the element-wise minimum of signed 16-bit values.  */
1058 static __inline __m64 __attribute__((__always_inline__))
1059 _mm_min_pi16 (__m64 __A, __m64 __B)
1060 {
1061   return (__m64) __builtin_ia32_pminsw ((__v4hi)__A, (__v4hi)__B);
1062 }
1063
1064 static __inline __m64 __attribute__((__always_inline__))
1065 _m_pminsw (__m64 __A, __m64 __B)
1066 {
1067   return _mm_min_pi16 (__A, __B);
1068 }
1069
1070 /* Compute the element-wise minimum of unsigned 8-bit values.  */
1071 static __inline __m64 __attribute__((__always_inline__))
1072 _mm_min_pu8 (__m64 __A, __m64 __B)
1073 {
1074   return (__m64) __builtin_ia32_pminub ((__v8qi)__A, (__v8qi)__B);
1075 }
1076
1077 static __inline __m64 __attribute__((__always_inline__))
1078 _m_pminub (__m64 __A, __m64 __B)
1079 {
1080   return _mm_min_pu8 (__A, __B);
1081 }
1082
1083 /* Create an 8-bit mask of the signs of 8-bit values.  */
1084 static __inline int __attribute__((__always_inline__))
1085 _mm_movemask_pi8 (__m64 __A)
1086 {
1087   return __builtin_ia32_pmovmskb ((__v8qi)__A);
1088 }
1089
1090 static __inline int __attribute__((__always_inline__))
1091 _m_pmovmskb (__m64 __A)
1092 {
1093   return _mm_movemask_pi8 (__A);
1094 }
1095
1096 /* Multiply four unsigned 16-bit values in A by four unsigned 16-bit values
1097    in B and produce the high 16 bits of the 32-bit results.  */
1098 static __inline __m64 __attribute__((__always_inline__))
1099 _mm_mulhi_pu16 (__m64 __A, __m64 __B)
1100 {
1101   return (__m64) __builtin_ia32_pmulhuw ((__v4hi)__A, (__v4hi)__B);
1102 }
1103
1104 static __inline __m64 __attribute__((__always_inline__))
1105 _m_pmulhuw (__m64 __A, __m64 __B)
1106 {
1107   return _mm_mulhi_pu16 (__A, __B);
1108 }
1109
1110 /* Return a combination of the four 16-bit values in A.  The selector
1111    must be an immediate.  */
1112 #if 0
1113 static __inline __m64 __attribute__((__always_inline__))
1114 _mm_shuffle_pi16 (__m64 __A, int __N)
1115 {
1116   return (__m64) __builtin_ia32_pshufw ((__v4hi)__A, __N);
1117 }
1118
1119 static __inline __m64 __attribute__((__always_inline__))
1120 _m_pshufw (__m64 __A, int __N)
1121 {
1122   return _mm_shuffle_pi16 (__A, __N);
1123 }
1124 #else
1125 #define _mm_shuffle_pi16(A, N) \
1126   ((__m64) __builtin_ia32_pshufw ((__v4hi)(A), (N)))
1127 #define _m_pshufw(A, N)         _mm_shuffle_pi16 ((A), (N))
1128 #endif
1129
1130 /* Conditionally store byte elements of A into P.  The high bit of each
1131    byte in the selector N determines whether the corresponding byte from
1132    A is stored.  */
1133 static __inline void __attribute__((__always_inline__))
1134 _mm_maskmove_si64 (__m64 __A, __m64 __N, char *__P)
1135 {
1136   __builtin_ia32_maskmovq ((__v8qi)__A, (__v8qi)__N, __P);
1137 }
1138
1139 static __inline void __attribute__((__always_inline__))
1140 _m_maskmovq (__m64 __A, __m64 __N, char *__P)
1141 {
1142   _mm_maskmove_si64 (__A, __N, __P);
1143 }
1144
1145 /* Compute the rounded averages of the unsigned 8-bit values in A and B.  */
1146 static __inline __m64 __attribute__((__always_inline__))
1147 _mm_avg_pu8 (__m64 __A, __m64 __B)
1148 {
1149   return (__m64) __builtin_ia32_pavgb ((__v8qi)__A, (__v8qi)__B);
1150 }
1151
1152 static __inline __m64 __attribute__((__always_inline__))
1153 _m_pavgb (__m64 __A, __m64 __B)
1154 {
1155   return _mm_avg_pu8 (__A, __B);
1156 }
1157
1158 /* Compute the rounded averages of the unsigned 16-bit values in A and B.  */
1159 static __inline __m64 __attribute__((__always_inline__))
1160 _mm_avg_pu16 (__m64 __A, __m64 __B)
1161 {
1162   return (__m64) __builtin_ia32_pavgw ((__v4hi)__A, (__v4hi)__B);
1163 }
1164
1165 static __inline __m64 __attribute__((__always_inline__))
1166 _m_pavgw (__m64 __A, __m64 __B)
1167 {
1168   return _mm_avg_pu16 (__A, __B);
1169 }
1170
1171 /* Compute the sum of the absolute differences of the unsigned 8-bit
1172    values in A and B.  Return the value in the lower 16-bit word; the
1173    upper words are cleared.  */
1174 static __inline __m64 __attribute__((__always_inline__))
1175 _mm_sad_pu8 (__m64 __A, __m64 __B)
1176 {
1177   return (__m64) __builtin_ia32_psadbw ((__v8qi)__A, (__v8qi)__B);
1178 }
1179
1180 static __inline __m64 __attribute__((__always_inline__))
1181 _m_psadbw (__m64 __A, __m64 __B)
1182 {
1183   return _mm_sad_pu8 (__A, __B);
1184 }
1185
1186 /* Loads one cache line from address P to a location "closer" to the
1187    processor.  The selector I specifies the type of prefetch operation.  */
1188 #if 0
1189 static __inline void __attribute__((__always_inline__))
1190 _mm_prefetch (void *__P, enum _mm_hint __I)
1191 {
1192   __builtin_prefetch (__P, 0, __I);
1193 }
1194 #else
1195 #define _mm_prefetch(P, I) \
1196   __builtin_prefetch ((P), 0, (I))
1197 #endif
1198
1199 /* Stores the data in A to the address P without polluting the caches.  */
1200 static __inline void __attribute__((__always_inline__))
1201 _mm_stream_pi (__m64 *__P, __m64 __A)
1202 {
1203   __builtin_ia32_movntq ((unsigned long long *)__P, (unsigned long long)__A);
1204 }
1205
1206 /* Likewise.  The address must be 16-byte aligned.  */
1207 static __inline void __attribute__((__always_inline__))
1208 _mm_stream_ps (float *__P, __m128 __A)
1209 {
1210   __builtin_ia32_movntps (__P, (__v4sf)__A);
1211 }
1212
1213 /* Guarantees that every preceding store is globally visible before
1214    any subsequent store.  */
1215 static __inline void __attribute__((__always_inline__))
1216 _mm_sfence (void)
1217 {
1218   __builtin_ia32_sfence ();
1219 }
1220
1221 /* The execution of the next instruction is delayed by an implementation
1222    specific amount of time.  The instruction does not modify the
1223    architectural state.  */
1224 static __inline void __attribute__((__always_inline__))
1225 _mm_pause (void)
1226 {
1227   __asm__ __volatile__ ("rep; nop" : : );
1228 }
1229
1230 /* Transpose the 4x4 matrix composed of row[0-3].  */
1231 #define _MM_TRANSPOSE4_PS(row0, row1, row2, row3)                       \
1232 do {                                                                    \
1233   __v4sf __r0 = (row0), __r1 = (row1), __r2 = (row2), __r3 = (row3);    \
1234   __v4sf __t0 = __builtin_ia32_unpcklps (__r0, __r1);                   \
1235   __v4sf __t1 = __builtin_ia32_unpcklps (__r2, __r3);                   \
1236   __v4sf __t2 = __builtin_ia32_unpckhps (__r0, __r1);                   \
1237   __v4sf __t3 = __builtin_ia32_unpckhps (__r2, __r3);                   \
1238   (row0) = __builtin_ia32_movlhps (__t0, __t1);                         \
1239   (row1) = __builtin_ia32_movhlps (__t1, __t0);                         \
1240   (row2) = __builtin_ia32_movlhps (__t2, __t3);                         \
1241   (row3) = __builtin_ia32_movhlps (__t3, __t2);                         \
1242 } while (0)
1243
1244 /* For backward source compatibility.  */
1245 #include <emmintrin.h>
1246
1247 #endif /* __SSE__ */
1248 #endif /* _XMMINTRIN_H_INCLUDED */