1 /* Copyright (C) 2003, 2004, 2005, 2007 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 2, or (at your option)
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 You should have received a copy of the GNU General Public License
16 along with GCC; see the file COPYING. If not, write to
17 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA. */
20 /* As a special exception, if you include this header file into source
21 files compiled by GCC, this header file does not by itself cause
22 the resulting executable to be covered by the GNU General Public
23 License. This exception does not however invalidate any other
24 reasons why the executable file might be covered by the GNU General
27 /* Implemented from the specification included in the Intel C++ Compiler
28 User Guide and Reference, version 8.0. */
30 #ifndef _EMMINTRIN_H_INCLUDED
31 #define _EMMINTRIN_H_INCLUDED
34 #include <xmmintrin.h>
37 typedef double __v2df
__attribute__ ((__vector_size__ (16)));
38 typedef long long __v2di
__attribute__ ((__vector_size__ (16)));
39 typedef int __v4si
__attribute__ ((__vector_size__ (16)));
40 typedef short __v8hi
__attribute__ ((__vector_size__ (16)));
41 typedef char __v16qi
__attribute__ ((__vector_size__ (16)));
43 /* The Intel API is flexible enough that we must allow aliasing with other
44 vector types, and their scalar components. */
45 typedef long long __m128i
__attribute__ ((__vector_size__ (16), __may_alias__
));
46 typedef double __m128d
__attribute__ ((__vector_size__ (16), __may_alias__
));
48 /* Create a selector for use with the SHUFPD instruction. */
49 #define _MM_SHUFFLE2(fp1,fp0) \
50 (((fp1) << 1) | (fp0))
52 /* Create a vector with element 0 as F and the rest zero. */
53 static __inline __m128d
__attribute__((__always_inline__
))
54 _mm_set_sd (double __F
)
56 return __extension__ (__m128d
){ __F
, 0 };
59 /* Create a vector with both elements equal to F. */
60 static __inline __m128d
__attribute__((__always_inline__
))
61 _mm_set1_pd (double __F
)
63 return __extension__ (__m128d
){ __F
, __F
};
66 static __inline __m128d
__attribute__((__always_inline__
))
67 _mm_set_pd1 (double __F
)
69 return _mm_set1_pd (__F
);
72 /* Create a vector with the lower value X and upper value W. */
73 static __inline __m128d
__attribute__((__always_inline__
))
74 _mm_set_pd (double __W
, double __X
)
76 return __extension__ (__m128d
){ __X
, __W
};
79 /* Create a vector with the lower value W and upper value X. */
80 static __inline __m128d
__attribute__((__always_inline__
))
81 _mm_setr_pd (double __W
, double __X
)
83 return __extension__ (__m128d
){ __W
, __X
};
86 /* Create a vector of zeros. */
87 static __inline __m128d
__attribute__((__always_inline__
))
90 return __extension__ (__m128d
){ 0.0, 0.0 };
93 /* Sets the low DPFP value of A from the low value of B. */
94 static __inline __m128d
__attribute__((__always_inline__
))
95 _mm_move_sd (__m128d __A
, __m128d __B
)
97 return (__m128d
) __builtin_ia32_movsd ((__v2df
)__A
, (__v2df
)__B
);
100 /* Load two DPFP values from P. The address must be 16-byte aligned. */
101 static __inline __m128d
__attribute__((__always_inline__
))
102 _mm_load_pd (double const *__P
)
104 return *(__m128d
*)__P
;
107 /* Load two DPFP values from P. The address need not be 16-byte aligned. */
108 static __inline __m128d
__attribute__((__always_inline__
))
109 _mm_loadu_pd (double const *__P
)
111 return __builtin_ia32_loadupd (__P
);
114 /* Create a vector with all two elements equal to *P. */
115 static __inline __m128d
__attribute__((__always_inline__
))
116 _mm_load1_pd (double const *__P
)
118 return _mm_set1_pd (*__P
);
121 /* Create a vector with element 0 as *P and the rest zero. */
122 static __inline __m128d
__attribute__((__always_inline__
))
123 _mm_load_sd (double const *__P
)
125 return _mm_set_sd (*__P
);
128 static __inline __m128d
__attribute__((__always_inline__
))
129 _mm_load_pd1 (double const *__P
)
131 return _mm_load1_pd (__P
);
134 /* Load two DPFP values in reverse order. The address must be aligned. */
135 static __inline __m128d
__attribute__((__always_inline__
))
136 _mm_loadr_pd (double const *__P
)
138 __m128d __tmp
= _mm_load_pd (__P
);
139 return __builtin_ia32_shufpd (__tmp
, __tmp
, _MM_SHUFFLE2 (0,1));
142 /* Store two DPFP values. The address must be 16-byte aligned. */
143 static __inline
void __attribute__((__always_inline__
))
144 _mm_store_pd (double *__P
, __m128d __A
)
146 *(__m128d
*)__P
= __A
;
149 /* Store two DPFP values. The address need not be 16-byte aligned. */
150 static __inline
void __attribute__((__always_inline__
))
151 _mm_storeu_pd (double *__P
, __m128d __A
)
153 __builtin_ia32_storeupd (__P
, __A
);
156 /* Stores the lower DPFP value. */
157 static __inline
void __attribute__((__always_inline__
))
158 _mm_store_sd (double *__P
, __m128d __A
)
160 *__P
= __builtin_ia32_vec_ext_v2df (__A
, 0);
163 static __inline
void __attribute__((__always_inline__
))
164 _mm_storel_pd (double *__P
, __m128d __A
)
166 _mm_store_sd (__P
, __A
);
169 /* Stores the upper DPFP value. */
170 static __inline
void __attribute__((__always_inline__
))
171 _mm_storeh_pd (double *__P
, __m128d __A
)
173 *__P
= __builtin_ia32_vec_ext_v2df (__A
, 1);
176 /* Store the lower DPFP value across two words.
177 The address must be 16-byte aligned. */
178 static __inline
void __attribute__((__always_inline__
))
179 _mm_store1_pd (double *__P
, __m128d __A
)
181 _mm_store_pd (__P
, __builtin_ia32_shufpd (__A
, __A
, _MM_SHUFFLE2 (0,0)));
184 static __inline
void __attribute__((__always_inline__
))
185 _mm_store_pd1 (double *__P
, __m128d __A
)
187 _mm_store1_pd (__P
, __A
);
190 /* Store two DPFP values in reverse order. The address must be aligned. */
191 static __inline
void __attribute__((__always_inline__
))
192 _mm_storer_pd (double *__P
, __m128d __A
)
194 _mm_store_pd (__P
, __builtin_ia32_shufpd (__A
, __A
, _MM_SHUFFLE2 (0,1)));
197 static __inline
int __attribute__((__always_inline__
))
198 _mm_cvtsi128_si32 (__m128i __A
)
200 return __builtin_ia32_vec_ext_v4si ((__v4si
)__A
, 0);
204 static __inline
long long __attribute__((__always_inline__
))
205 _mm_cvtsi128_si64x (__m128i __A
)
207 return __builtin_ia32_vec_ext_v2di ((__v2di
)__A
, 0);
211 static __inline __m128d
__attribute__((__always_inline__
))
212 _mm_add_pd (__m128d __A
, __m128d __B
)
214 return (__m128d
)__builtin_ia32_addpd ((__v2df
)__A
, (__v2df
)__B
);
217 static __inline __m128d
__attribute__((__always_inline__
))
218 _mm_add_sd (__m128d __A
, __m128d __B
)
220 return (__m128d
)__builtin_ia32_addsd ((__v2df
)__A
, (__v2df
)__B
);
223 static __inline __m128d
__attribute__((__always_inline__
))
224 _mm_sub_pd (__m128d __A
, __m128d __B
)
226 return (__m128d
)__builtin_ia32_subpd ((__v2df
)__A
, (__v2df
)__B
);
229 static __inline __m128d
__attribute__((__always_inline__
))
230 _mm_sub_sd (__m128d __A
, __m128d __B
)
232 return (__m128d
)__builtin_ia32_subsd ((__v2df
)__A
, (__v2df
)__B
);
235 static __inline __m128d
__attribute__((__always_inline__
))
236 _mm_mul_pd (__m128d __A
, __m128d __B
)
238 return (__m128d
)__builtin_ia32_mulpd ((__v2df
)__A
, (__v2df
)__B
);
241 static __inline __m128d
__attribute__((__always_inline__
))
242 _mm_mul_sd (__m128d __A
, __m128d __B
)
244 return (__m128d
)__builtin_ia32_mulsd ((__v2df
)__A
, (__v2df
)__B
);
247 static __inline __m128d
__attribute__((__always_inline__
))
248 _mm_div_pd (__m128d __A
, __m128d __B
)
250 return (__m128d
)__builtin_ia32_divpd ((__v2df
)__A
, (__v2df
)__B
);
253 static __inline __m128d
__attribute__((__always_inline__
))
254 _mm_div_sd (__m128d __A
, __m128d __B
)
256 return (__m128d
)__builtin_ia32_divsd ((__v2df
)__A
, (__v2df
)__B
);
259 static __inline __m128d
__attribute__((__always_inline__
))
260 _mm_sqrt_pd (__m128d __A
)
262 return (__m128d
)__builtin_ia32_sqrtpd ((__v2df
)__A
);
265 /* Return pair {sqrt (A[0), B[1]}. */
266 static __inline __m128d
__attribute__((__always_inline__
))
267 _mm_sqrt_sd (__m128d __A
, __m128d __B
)
269 __v2df __tmp
= __builtin_ia32_movsd ((__v2df
)__A
, (__v2df
)__B
);
270 return (__m128d
)__builtin_ia32_sqrtsd ((__v2df
)__tmp
);
273 static __inline __m128d
__attribute__((__always_inline__
))
274 _mm_min_pd (__m128d __A
, __m128d __B
)
276 return (__m128d
)__builtin_ia32_minpd ((__v2df
)__A
, (__v2df
)__B
);
279 static __inline __m128d
__attribute__((__always_inline__
))
280 _mm_min_sd (__m128d __A
, __m128d __B
)
282 return (__m128d
)__builtin_ia32_minsd ((__v2df
)__A
, (__v2df
)__B
);
285 static __inline __m128d
__attribute__((__always_inline__
))
286 _mm_max_pd (__m128d __A
, __m128d __B
)
288 return (__m128d
)__builtin_ia32_maxpd ((__v2df
)__A
, (__v2df
)__B
);
291 static __inline __m128d
__attribute__((__always_inline__
))
292 _mm_max_sd (__m128d __A
, __m128d __B
)
294 return (__m128d
)__builtin_ia32_maxsd ((__v2df
)__A
, (__v2df
)__B
);
297 static __inline __m128d
__attribute__((__always_inline__
))
298 _mm_and_pd (__m128d __A
, __m128d __B
)
300 return (__m128d
)__builtin_ia32_andpd ((__v2df
)__A
, (__v2df
)__B
);
303 static __inline __m128d
__attribute__((__always_inline__
))
304 _mm_andnot_pd (__m128d __A
, __m128d __B
)
306 return (__m128d
)__builtin_ia32_andnpd ((__v2df
)__A
, (__v2df
)__B
);
309 static __inline __m128d
__attribute__((__always_inline__
))
310 _mm_or_pd (__m128d __A
, __m128d __B
)
312 return (__m128d
)__builtin_ia32_orpd ((__v2df
)__A
, (__v2df
)__B
);
315 static __inline __m128d
__attribute__((__always_inline__
))
316 _mm_xor_pd (__m128d __A
, __m128d __B
)
318 return (__m128d
)__builtin_ia32_xorpd ((__v2df
)__A
, (__v2df
)__B
);
321 static __inline __m128d
__attribute__((__always_inline__
))
322 _mm_cmpeq_pd (__m128d __A
, __m128d __B
)
324 return (__m128d
)__builtin_ia32_cmpeqpd ((__v2df
)__A
, (__v2df
)__B
);
327 static __inline __m128d
__attribute__((__always_inline__
))
328 _mm_cmplt_pd (__m128d __A
, __m128d __B
)
330 return (__m128d
)__builtin_ia32_cmpltpd ((__v2df
)__A
, (__v2df
)__B
);
333 static __inline __m128d
__attribute__((__always_inline__
))
334 _mm_cmple_pd (__m128d __A
, __m128d __B
)
336 return (__m128d
)__builtin_ia32_cmplepd ((__v2df
)__A
, (__v2df
)__B
);
339 static __inline __m128d
__attribute__((__always_inline__
))
340 _mm_cmpgt_pd (__m128d __A
, __m128d __B
)
342 return (__m128d
)__builtin_ia32_cmpgtpd ((__v2df
)__A
, (__v2df
)__B
);
345 static __inline __m128d
__attribute__((__always_inline__
))
346 _mm_cmpge_pd (__m128d __A
, __m128d __B
)
348 return (__m128d
)__builtin_ia32_cmpgepd ((__v2df
)__A
, (__v2df
)__B
);
351 static __inline __m128d
__attribute__((__always_inline__
))
352 _mm_cmpneq_pd (__m128d __A
, __m128d __B
)
354 return (__m128d
)__builtin_ia32_cmpneqpd ((__v2df
)__A
, (__v2df
)__B
);
357 static __inline __m128d
__attribute__((__always_inline__
))
358 _mm_cmpnlt_pd (__m128d __A
, __m128d __B
)
360 return (__m128d
)__builtin_ia32_cmpnltpd ((__v2df
)__A
, (__v2df
)__B
);
363 static __inline __m128d
__attribute__((__always_inline__
))
364 _mm_cmpnle_pd (__m128d __A
, __m128d __B
)
366 return (__m128d
)__builtin_ia32_cmpnlepd ((__v2df
)__A
, (__v2df
)__B
);
369 static __inline __m128d
__attribute__((__always_inline__
))
370 _mm_cmpngt_pd (__m128d __A
, __m128d __B
)
372 return (__m128d
)__builtin_ia32_cmpngtpd ((__v2df
)__A
, (__v2df
)__B
);
375 static __inline __m128d
__attribute__((__always_inline__
))
376 _mm_cmpnge_pd (__m128d __A
, __m128d __B
)
378 return (__m128d
)__builtin_ia32_cmpngepd ((__v2df
)__A
, (__v2df
)__B
);
381 static __inline __m128d
__attribute__((__always_inline__
))
382 _mm_cmpord_pd (__m128d __A
, __m128d __B
)
384 return (__m128d
)__builtin_ia32_cmpordpd ((__v2df
)__A
, (__v2df
)__B
);
387 static __inline __m128d
__attribute__((__always_inline__
))
388 _mm_cmpunord_pd (__m128d __A
, __m128d __B
)
390 return (__m128d
)__builtin_ia32_cmpunordpd ((__v2df
)__A
, (__v2df
)__B
);
393 static __inline __m128d
__attribute__((__always_inline__
))
394 _mm_cmpeq_sd (__m128d __A
, __m128d __B
)
396 return (__m128d
)__builtin_ia32_cmpeqsd ((__v2df
)__A
, (__v2df
)__B
);
399 static __inline __m128d
__attribute__((__always_inline__
))
400 _mm_cmplt_sd (__m128d __A
, __m128d __B
)
402 return (__m128d
)__builtin_ia32_cmpltsd ((__v2df
)__A
, (__v2df
)__B
);
405 static __inline __m128d
__attribute__((__always_inline__
))
406 _mm_cmple_sd (__m128d __A
, __m128d __B
)
408 return (__m128d
)__builtin_ia32_cmplesd ((__v2df
)__A
, (__v2df
)__B
);
411 static __inline __m128d
__attribute__((__always_inline__
))
412 _mm_cmpgt_sd (__m128d __A
, __m128d __B
)
414 return (__m128d
) __builtin_ia32_movsd ((__v2df
) __A
,
416 __builtin_ia32_cmpltsd ((__v2df
) __B
,
421 static __inline __m128d
__attribute__((__always_inline__
))
422 _mm_cmpge_sd (__m128d __A
, __m128d __B
)
424 return (__m128d
) __builtin_ia32_movsd ((__v2df
) __A
,
426 __builtin_ia32_cmplesd ((__v2df
) __B
,
431 static __inline __m128d
__attribute__((__always_inline__
))
432 _mm_cmpneq_sd (__m128d __A
, __m128d __B
)
434 return (__m128d
)__builtin_ia32_cmpneqsd ((__v2df
)__A
, (__v2df
)__B
);
437 static __inline __m128d
__attribute__((__always_inline__
))
438 _mm_cmpnlt_sd (__m128d __A
, __m128d __B
)
440 return (__m128d
)__builtin_ia32_cmpnltsd ((__v2df
)__A
, (__v2df
)__B
);
443 static __inline __m128d
__attribute__((__always_inline__
))
444 _mm_cmpnle_sd (__m128d __A
, __m128d __B
)
446 return (__m128d
)__builtin_ia32_cmpnlesd ((__v2df
)__A
, (__v2df
)__B
);
449 static __inline __m128d
__attribute__((__always_inline__
))
450 _mm_cmpngt_sd (__m128d __A
, __m128d __B
)
452 return (__m128d
) __builtin_ia32_movsd ((__v2df
) __A
,
454 __builtin_ia32_cmpnltsd ((__v2df
) __B
,
459 static __inline __m128d
__attribute__((__always_inline__
))
460 _mm_cmpnge_sd (__m128d __A
, __m128d __B
)
462 return (__m128d
) __builtin_ia32_movsd ((__v2df
) __A
,
464 __builtin_ia32_cmpnlesd ((__v2df
) __B
,
469 static __inline __m128d
__attribute__((__always_inline__
))
470 _mm_cmpord_sd (__m128d __A
, __m128d __B
)
472 return (__m128d
)__builtin_ia32_cmpordsd ((__v2df
)__A
, (__v2df
)__B
);
475 static __inline __m128d
__attribute__((__always_inline__
))
476 _mm_cmpunord_sd (__m128d __A
, __m128d __B
)
478 return (__m128d
)__builtin_ia32_cmpunordsd ((__v2df
)__A
, (__v2df
)__B
);
481 static __inline
int __attribute__((__always_inline__
))
482 _mm_comieq_sd (__m128d __A
, __m128d __B
)
484 return __builtin_ia32_comisdeq ((__v2df
)__A
, (__v2df
)__B
);
487 static __inline
int __attribute__((__always_inline__
))
488 _mm_comilt_sd (__m128d __A
, __m128d __B
)
490 return __builtin_ia32_comisdlt ((__v2df
)__A
, (__v2df
)__B
);
493 static __inline
int __attribute__((__always_inline__
))
494 _mm_comile_sd (__m128d __A
, __m128d __B
)
496 return __builtin_ia32_comisdle ((__v2df
)__A
, (__v2df
)__B
);
499 static __inline
int __attribute__((__always_inline__
))
500 _mm_comigt_sd (__m128d __A
, __m128d __B
)
502 return __builtin_ia32_comisdgt ((__v2df
)__A
, (__v2df
)__B
);
505 static __inline
int __attribute__((__always_inline__
))
506 _mm_comige_sd (__m128d __A
, __m128d __B
)
508 return __builtin_ia32_comisdge ((__v2df
)__A
, (__v2df
)__B
);
511 static __inline
int __attribute__((__always_inline__
))
512 _mm_comineq_sd (__m128d __A
, __m128d __B
)
514 return __builtin_ia32_comisdneq ((__v2df
)__A
, (__v2df
)__B
);
517 static __inline
int __attribute__((__always_inline__
))
518 _mm_ucomieq_sd (__m128d __A
, __m128d __B
)
520 return __builtin_ia32_ucomisdeq ((__v2df
)__A
, (__v2df
)__B
);
523 static __inline
int __attribute__((__always_inline__
))
524 _mm_ucomilt_sd (__m128d __A
, __m128d __B
)
526 return __builtin_ia32_ucomisdlt ((__v2df
)__A
, (__v2df
)__B
);
529 static __inline
int __attribute__((__always_inline__
))
530 _mm_ucomile_sd (__m128d __A
, __m128d __B
)
532 return __builtin_ia32_ucomisdle ((__v2df
)__A
, (__v2df
)__B
);
535 static __inline
int __attribute__((__always_inline__
))
536 _mm_ucomigt_sd (__m128d __A
, __m128d __B
)
538 return __builtin_ia32_ucomisdgt ((__v2df
)__A
, (__v2df
)__B
);
541 static __inline
int __attribute__((__always_inline__
))
542 _mm_ucomige_sd (__m128d __A
, __m128d __B
)
544 return __builtin_ia32_ucomisdge ((__v2df
)__A
, (__v2df
)__B
);
547 static __inline
int __attribute__((__always_inline__
))
548 _mm_ucomineq_sd (__m128d __A
, __m128d __B
)
550 return __builtin_ia32_ucomisdneq ((__v2df
)__A
, (__v2df
)__B
);
553 /* Create a vector of Qi, where i is the element number. */
555 static __inline __m128i
__attribute__((__always_inline__
))
556 _mm_set_epi64x (long long __q1
, long long __q0
)
558 return __extension__ (__m128i
)(__v2di
){ __q0
, __q1
};
561 static __inline __m128i
__attribute__((__always_inline__
))
562 _mm_set_epi64 (__m64 __q1
, __m64 __q0
)
564 return _mm_set_epi64x ((long long)__q1
, (long long)__q0
);
567 static __inline __m128i
__attribute__((__always_inline__
))
568 _mm_set_epi32 (int __q3
, int __q2
, int __q1
, int __q0
)
570 return __extension__ (__m128i
)(__v4si
){ __q0
, __q1
, __q2
, __q3
};
573 static __inline __m128i
__attribute__((__always_inline__
))
574 _mm_set_epi16 (short __q7
, short __q6
, short __q5
, short __q4
,
575 short __q3
, short __q2
, short __q1
, short __q0
)
577 return __extension__ (__m128i
)(__v8hi
){
578 __q0
, __q1
, __q2
, __q3
, __q4
, __q5
, __q6
, __q7
};
581 static __inline __m128i
__attribute__((__always_inline__
))
582 _mm_set_epi8 (char __q15
, char __q14
, char __q13
, char __q12
,
583 char __q11
, char __q10
, char __q09
, char __q08
,
584 char __q07
, char __q06
, char __q05
, char __q04
,
585 char __q03
, char __q02
, char __q01
, char __q00
)
587 return __extension__ (__m128i
)(__v16qi
){
588 __q00
, __q01
, __q02
, __q03
, __q04
, __q05
, __q06
, __q07
,
589 __q08
, __q09
, __q10
, __q11
, __q12
, __q13
, __q14
, __q15
593 /* Set all of the elements of the vector to A. */
595 static __inline __m128i
__attribute__((__always_inline__
))
596 _mm_set1_epi64x (long long __A
)
598 return _mm_set_epi64x (__A
, __A
);
601 static __inline __m128i
__attribute__((__always_inline__
))
602 _mm_set1_epi64 (__m64 __A
)
604 return _mm_set_epi64 (__A
, __A
);
607 static __inline __m128i
__attribute__((__always_inline__
))
608 _mm_set1_epi32 (int __A
)
610 return _mm_set_epi32 (__A
, __A
, __A
, __A
);
613 static __inline __m128i
__attribute__((__always_inline__
))
614 _mm_set1_epi16 (short __A
)
616 return _mm_set_epi16 (__A
, __A
, __A
, __A
, __A
, __A
, __A
, __A
);
619 static __inline __m128i
__attribute__((__always_inline__
))
620 _mm_set1_epi8 (char __A
)
622 return _mm_set_epi8 (__A
, __A
, __A
, __A
, __A
, __A
, __A
, __A
,
623 __A
, __A
, __A
, __A
, __A
, __A
, __A
, __A
);
626 /* Create a vector of Qi, where i is the element number.
627 The parameter order is reversed from the _mm_set_epi* functions. */
629 static __inline __m128i
__attribute__((__always_inline__
))
630 _mm_setr_epi64 (__m64 __q0
, __m64 __q1
)
632 return _mm_set_epi64 (__q1
, __q0
);
635 static __inline __m128i
__attribute__((__always_inline__
))
636 _mm_setr_epi32 (int __q0
, int __q1
, int __q2
, int __q3
)
638 return _mm_set_epi32 (__q3
, __q2
, __q1
, __q0
);
641 static __inline __m128i
__attribute__((__always_inline__
))
642 _mm_setr_epi16 (short __q0
, short __q1
, short __q2
, short __q3
,
643 short __q4
, short __q5
, short __q6
, short __q7
)
645 return _mm_set_epi16 (__q7
, __q6
, __q5
, __q4
, __q3
, __q2
, __q1
, __q0
);
648 static __inline __m128i
__attribute__((__always_inline__
))
649 _mm_setr_epi8 (char __q00
, char __q01
, char __q02
, char __q03
,
650 char __q04
, char __q05
, char __q06
, char __q07
,
651 char __q08
, char __q09
, char __q10
, char __q11
,
652 char __q12
, char __q13
, char __q14
, char __q15
)
654 return _mm_set_epi8 (__q15
, __q14
, __q13
, __q12
, __q11
, __q10
, __q09
, __q08
,
655 __q07
, __q06
, __q05
, __q04
, __q03
, __q02
, __q01
, __q00
);
658 /* Create a vector with element 0 as *P and the rest zero. */
660 static __inline __m128i
__attribute__((__always_inline__
))
661 _mm_load_si128 (__m128i
const *__P
)
666 static __inline __m128i
__attribute__((__always_inline__
))
667 _mm_loadu_si128 (__m128i
const *__P
)
669 return (__m128i
) __builtin_ia32_loaddqu ((char const *)__P
);
672 static __inline __m128i
__attribute__((__always_inline__
))
673 _mm_loadl_epi64 (__m128i
const *__P
)
675 return _mm_set_epi64 ((__m64
)0LL, *(__m64
*)__P
);
678 static __inline
void __attribute__((__always_inline__
))
679 _mm_store_si128 (__m128i
*__P
, __m128i __B
)
684 static __inline
void __attribute__((__always_inline__
))
685 _mm_storeu_si128 (__m128i
*__P
, __m128i __B
)
687 __builtin_ia32_storedqu ((char *)__P
, (__v16qi
)__B
);
690 static __inline
void __attribute__((__always_inline__
))
691 _mm_storel_epi64 (__m128i
*__P
, __m128i __B
)
693 *(long long *)__P
= __builtin_ia32_vec_ext_v2di ((__v2di
)__B
, 0);
696 static __inline __m64
__attribute__((__always_inline__
))
697 _mm_movepi64_pi64 (__m128i __B
)
699 return (__m64
) __builtin_ia32_vec_ext_v2di ((__v2di
)__B
, 0);
702 static __inline __m128i
__attribute__((__always_inline__
))
703 _mm_movpi64_epi64 (__m64 __A
)
705 return _mm_set_epi64 ((__m64
)0LL, __A
);
708 static __inline __m128i
__attribute__((__always_inline__
))
709 _mm_move_epi64 (__m128i __A
)
711 return _mm_set_epi64 ((__m64
)0LL, _mm_movepi64_pi64 (__A
));
714 /* Create a vector of zeros. */
715 static __inline __m128i
__attribute__((__always_inline__
))
716 _mm_setzero_si128 (void)
718 return __extension__ (__m128i
)(__v4si
){ 0, 0, 0, 0 };
721 static __inline __m128d
__attribute__((__always_inline__
))
722 _mm_cvtepi32_pd (__m128i __A
)
724 return (__m128d
)__builtin_ia32_cvtdq2pd ((__v4si
) __A
);
727 static __inline __m128
__attribute__((__always_inline__
))
728 _mm_cvtepi32_ps (__m128i __A
)
730 return (__m128
)__builtin_ia32_cvtdq2ps ((__v4si
) __A
);
733 static __inline __m128i
__attribute__((__always_inline__
))
734 _mm_cvtpd_epi32 (__m128d __A
)
736 return (__m128i
)__builtin_ia32_cvtpd2dq ((__v2df
) __A
);
739 static __inline __m64
__attribute__((__always_inline__
))
740 _mm_cvtpd_pi32 (__m128d __A
)
742 return (__m64
)__builtin_ia32_cvtpd2pi ((__v2df
) __A
);
745 static __inline __m128
__attribute__((__always_inline__
))
746 _mm_cvtpd_ps (__m128d __A
)
748 return (__m128
)__builtin_ia32_cvtpd2ps ((__v2df
) __A
);
751 static __inline __m128i
__attribute__((__always_inline__
))
752 _mm_cvttpd_epi32 (__m128d __A
)
754 return (__m128i
)__builtin_ia32_cvttpd2dq ((__v2df
) __A
);
757 static __inline __m64
__attribute__((__always_inline__
))
758 _mm_cvttpd_pi32 (__m128d __A
)
760 return (__m64
)__builtin_ia32_cvttpd2pi ((__v2df
) __A
);
763 static __inline __m128d
__attribute__((__always_inline__
))
764 _mm_cvtpi32_pd (__m64 __A
)
766 return (__m128d
)__builtin_ia32_cvtpi2pd ((__v2si
) __A
);
769 static __inline __m128i
__attribute__((__always_inline__
))
770 _mm_cvtps_epi32 (__m128 __A
)
772 return (__m128i
)__builtin_ia32_cvtps2dq ((__v4sf
) __A
);
775 static __inline __m128i
__attribute__((__always_inline__
))
776 _mm_cvttps_epi32 (__m128 __A
)
778 return (__m128i
)__builtin_ia32_cvttps2dq ((__v4sf
) __A
);
781 static __inline __m128d
__attribute__((__always_inline__
))
782 _mm_cvtps_pd (__m128 __A
)
784 return (__m128d
)__builtin_ia32_cvtps2pd ((__v4sf
) __A
);
787 static __inline
int __attribute__((__always_inline__
))
788 _mm_cvtsd_si32 (__m128d __A
)
790 return __builtin_ia32_cvtsd2si ((__v2df
) __A
);
794 static __inline
long long __attribute__((__always_inline__
))
795 _mm_cvtsd_si64x (__m128d __A
)
797 return __builtin_ia32_cvtsd2si64 ((__v2df
) __A
);
801 static __inline
int __attribute__((__always_inline__
))
802 _mm_cvttsd_si32 (__m128d __A
)
804 return __builtin_ia32_cvttsd2si ((__v2df
) __A
);
808 static __inline
long long __attribute__((__always_inline__
))
809 _mm_cvttsd_si64x (__m128d __A
)
811 return __builtin_ia32_cvttsd2si64 ((__v2df
) __A
);
815 static __inline __m128
__attribute__((__always_inline__
))
816 _mm_cvtsd_ss (__m128 __A
, __m128d __B
)
818 return (__m128
)__builtin_ia32_cvtsd2ss ((__v4sf
) __A
, (__v2df
) __B
);
821 static __inline __m128d
__attribute__((__always_inline__
))
822 _mm_cvtsi32_sd (__m128d __A
, int __B
)
824 return (__m128d
)__builtin_ia32_cvtsi2sd ((__v2df
) __A
, __B
);
828 static __inline __m128d
__attribute__((__always_inline__
))
829 _mm_cvtsi64x_sd (__m128d __A
, long long __B
)
831 return (__m128d
)__builtin_ia32_cvtsi642sd ((__v2df
) __A
, __B
);
835 static __inline __m128d
__attribute__((__always_inline__
))
836 _mm_cvtss_sd (__m128d __A
, __m128 __B
)
838 return (__m128d
)__builtin_ia32_cvtss2sd ((__v2df
) __A
, (__v4sf
)__B
);
841 #define _mm_shuffle_pd(__A, __B, __C) ((__m128d)__builtin_ia32_shufpd ((__v2df)__A, (__v2df)__B, (__C)))
843 static __inline __m128d
__attribute__((__always_inline__
))
844 _mm_unpackhi_pd (__m128d __A
, __m128d __B
)
846 return (__m128d
)__builtin_ia32_unpckhpd ((__v2df
)__A
, (__v2df
)__B
);
849 static __inline __m128d
__attribute__((__always_inline__
))
850 _mm_unpacklo_pd (__m128d __A
, __m128d __B
)
852 return (__m128d
)__builtin_ia32_unpcklpd ((__v2df
)__A
, (__v2df
)__B
);
855 static __inline __m128d
__attribute__((__always_inline__
))
856 _mm_loadh_pd (__m128d __A
, double const *__B
)
858 return (__m128d
)__builtin_ia32_loadhpd ((__v2df
)__A
, __B
);
861 static __inline __m128d
__attribute__((__always_inline__
))
862 _mm_loadl_pd (__m128d __A
, double const *__B
)
864 return (__m128d
)__builtin_ia32_loadlpd ((__v2df
)__A
, __B
);
867 static __inline
int __attribute__((__always_inline__
))
868 _mm_movemask_pd (__m128d __A
)
870 return __builtin_ia32_movmskpd ((__v2df
)__A
);
873 static __inline __m128i
__attribute__((__always_inline__
))
874 _mm_packs_epi16 (__m128i __A
, __m128i __B
)
876 return (__m128i
)__builtin_ia32_packsswb128 ((__v8hi
)__A
, (__v8hi
)__B
);
879 static __inline __m128i
__attribute__((__always_inline__
))
880 _mm_packs_epi32 (__m128i __A
, __m128i __B
)
882 return (__m128i
)__builtin_ia32_packssdw128 ((__v4si
)__A
, (__v4si
)__B
);
885 static __inline __m128i
__attribute__((__always_inline__
))
886 _mm_packus_epi16 (__m128i __A
, __m128i __B
)
888 return (__m128i
)__builtin_ia32_packuswb128 ((__v8hi
)__A
, (__v8hi
)__B
);
891 static __inline __m128i
__attribute__((__always_inline__
))
892 _mm_unpackhi_epi8 (__m128i __A
, __m128i __B
)
894 return (__m128i
)__builtin_ia32_punpckhbw128 ((__v16qi
)__A
, (__v16qi
)__B
);
897 static __inline __m128i
__attribute__((__always_inline__
))
898 _mm_unpackhi_epi16 (__m128i __A
, __m128i __B
)
900 return (__m128i
)__builtin_ia32_punpckhwd128 ((__v8hi
)__A
, (__v8hi
)__B
);
903 static __inline __m128i
__attribute__((__always_inline__
))
904 _mm_unpackhi_epi32 (__m128i __A
, __m128i __B
)
906 return (__m128i
)__builtin_ia32_punpckhdq128 ((__v4si
)__A
, (__v4si
)__B
);
909 static __inline __m128i
__attribute__((__always_inline__
))
910 _mm_unpackhi_epi64 (__m128i __A
, __m128i __B
)
912 return (__m128i
)__builtin_ia32_punpckhqdq128 ((__v2di
)__A
, (__v2di
)__B
);
915 static __inline __m128i
__attribute__((__always_inline__
))
916 _mm_unpacklo_epi8 (__m128i __A
, __m128i __B
)
918 return (__m128i
)__builtin_ia32_punpcklbw128 ((__v16qi
)__A
, (__v16qi
)__B
);
921 static __inline __m128i
__attribute__((__always_inline__
))
922 _mm_unpacklo_epi16 (__m128i __A
, __m128i __B
)
924 return (__m128i
)__builtin_ia32_punpcklwd128 ((__v8hi
)__A
, (__v8hi
)__B
);
927 static __inline __m128i
__attribute__((__always_inline__
))
928 _mm_unpacklo_epi32 (__m128i __A
, __m128i __B
)
930 return (__m128i
)__builtin_ia32_punpckldq128 ((__v4si
)__A
, (__v4si
)__B
);
933 static __inline __m128i
__attribute__((__always_inline__
))
934 _mm_unpacklo_epi64 (__m128i __A
, __m128i __B
)
936 return (__m128i
)__builtin_ia32_punpcklqdq128 ((__v2di
)__A
, (__v2di
)__B
);
939 static __inline __m128i
__attribute__((__always_inline__
))
940 _mm_add_epi8 (__m128i __A
, __m128i __B
)
942 return (__m128i
)__builtin_ia32_paddb128 ((__v16qi
)__A
, (__v16qi
)__B
);
945 static __inline __m128i
__attribute__((__always_inline__
))
946 _mm_add_epi16 (__m128i __A
, __m128i __B
)
948 return (__m128i
)__builtin_ia32_paddw128 ((__v8hi
)__A
, (__v8hi
)__B
);
951 static __inline __m128i
__attribute__((__always_inline__
))
952 _mm_add_epi32 (__m128i __A
, __m128i __B
)
954 return (__m128i
)__builtin_ia32_paddd128 ((__v4si
)__A
, (__v4si
)__B
);
957 static __inline __m128i
__attribute__((__always_inline__
))
958 _mm_add_epi64 (__m128i __A
, __m128i __B
)
960 return (__m128i
)__builtin_ia32_paddq128 ((__v2di
)__A
, (__v2di
)__B
);
963 static __inline __m128i
__attribute__((__always_inline__
))
964 _mm_adds_epi8 (__m128i __A
, __m128i __B
)
966 return (__m128i
)__builtin_ia32_paddsb128 ((__v16qi
)__A
, (__v16qi
)__B
);
969 static __inline __m128i
__attribute__((__always_inline__
))
970 _mm_adds_epi16 (__m128i __A
, __m128i __B
)
972 return (__m128i
)__builtin_ia32_paddsw128 ((__v8hi
)__A
, (__v8hi
)__B
);
975 static __inline __m128i
__attribute__((__always_inline__
))
976 _mm_adds_epu8 (__m128i __A
, __m128i __B
)
978 return (__m128i
)__builtin_ia32_paddusb128 ((__v16qi
)__A
, (__v16qi
)__B
);
981 static __inline __m128i
__attribute__((__always_inline__
))
982 _mm_adds_epu16 (__m128i __A
, __m128i __B
)
984 return (__m128i
)__builtin_ia32_paddusw128 ((__v8hi
)__A
, (__v8hi
)__B
);
987 static __inline __m128i
__attribute__((__always_inline__
))
988 _mm_sub_epi8 (__m128i __A
, __m128i __B
)
990 return (__m128i
)__builtin_ia32_psubb128 ((__v16qi
)__A
, (__v16qi
)__B
);
993 static __inline __m128i
__attribute__((__always_inline__
))
994 _mm_sub_epi16 (__m128i __A
, __m128i __B
)
996 return (__m128i
)__builtin_ia32_psubw128 ((__v8hi
)__A
, (__v8hi
)__B
);
999 static __inline __m128i
__attribute__((__always_inline__
))
1000 _mm_sub_epi32 (__m128i __A
, __m128i __B
)
1002 return (__m128i
)__builtin_ia32_psubd128 ((__v4si
)__A
, (__v4si
)__B
);
1005 static __inline __m128i
__attribute__((__always_inline__
))
1006 _mm_sub_epi64 (__m128i __A
, __m128i __B
)
1008 return (__m128i
)__builtin_ia32_psubq128 ((__v2di
)__A
, (__v2di
)__B
);
1011 static __inline __m128i
__attribute__((__always_inline__
))
1012 _mm_subs_epi8 (__m128i __A
, __m128i __B
)
1014 return (__m128i
)__builtin_ia32_psubsb128 ((__v16qi
)__A
, (__v16qi
)__B
);
1017 static __inline __m128i
__attribute__((__always_inline__
))
1018 _mm_subs_epi16 (__m128i __A
, __m128i __B
)
1020 return (__m128i
)__builtin_ia32_psubsw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1023 static __inline __m128i
__attribute__((__always_inline__
))
1024 _mm_subs_epu8 (__m128i __A
, __m128i __B
)
1026 return (__m128i
)__builtin_ia32_psubusb128 ((__v16qi
)__A
, (__v16qi
)__B
);
1029 static __inline __m128i
__attribute__((__always_inline__
))
1030 _mm_subs_epu16 (__m128i __A
, __m128i __B
)
1032 return (__m128i
)__builtin_ia32_psubusw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1035 static __inline __m128i
__attribute__((__always_inline__
))
1036 _mm_madd_epi16 (__m128i __A
, __m128i __B
)
1038 return (__m128i
)__builtin_ia32_pmaddwd128 ((__v8hi
)__A
, (__v8hi
)__B
);
1041 static __inline __m128i
__attribute__((__always_inline__
))
1042 _mm_mulhi_epi16 (__m128i __A
, __m128i __B
)
1044 return (__m128i
)__builtin_ia32_pmulhw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1047 static __inline __m128i
__attribute__((__always_inline__
))
1048 _mm_mullo_epi16 (__m128i __A
, __m128i __B
)
1050 return (__m128i
)__builtin_ia32_pmullw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1053 static __inline __m64
__attribute__((__always_inline__
))
1054 _mm_mul_su32 (__m64 __A
, __m64 __B
)
1056 return (__m64
)__builtin_ia32_pmuludq ((__v2si
)__A
, (__v2si
)__B
);
1059 static __inline __m128i
__attribute__((__always_inline__
))
1060 _mm_mul_epu32 (__m128i __A
, __m128i __B
)
1062 return (__m128i
)__builtin_ia32_pmuludq128 ((__v4si
)__A
, (__v4si
)__B
);
1066 static __inline __m128i
__attribute__((__always_inline__
))
1067 _mm_slli_epi16 (__m128i __A
, int __B
)
1069 return (__m128i
)__builtin_ia32_psllwi128 ((__v8hi
)__A
, __B
);
1072 static __inline __m128i
__attribute__((__always_inline__
))
1073 _mm_slli_epi32 (__m128i __A
, int __B
)
1075 return (__m128i
)__builtin_ia32_pslldi128 ((__v4si
)__A
, __B
);
1078 static __inline __m128i
__attribute__((__always_inline__
))
1079 _mm_slli_epi64 (__m128i __A
, int __B
)
1081 return (__m128i
)__builtin_ia32_psllqi128 ((__v2di
)__A
, __B
);
1084 #define _mm_slli_epi16(__A, __B) \
1085 ((__m128i)__builtin_ia32_psllwi128 ((__v8hi)(__A), __B))
1086 #define _mm_slli_epi32(__A, __B) \
1087 ((__m128i)__builtin_ia32_pslldi128 ((__v8hi)(__A), __B))
1088 #define _mm_slli_epi64(__A, __B) \
1089 ((__m128i)__builtin_ia32_psllqi128 ((__v8hi)(__A), __B))
1093 static __inline __m128i
__attribute__((__always_inline__
))
1094 _mm_srai_epi16 (__m128i __A
, int __B
)
1096 return (__m128i
)__builtin_ia32_psrawi128 ((__v8hi
)__A
, __B
);
1099 static __inline __m128i
__attribute__((__always_inline__
))
1100 _mm_srai_epi32 (__m128i __A
, int __B
)
1102 return (__m128i
)__builtin_ia32_psradi128 ((__v4si
)__A
, __B
);
1105 #define _mm_srai_epi16(__A, __B) \
1106 ((__m128i)__builtin_ia32_psrawi128 ((__v8hi)(__A), __B))
1107 #define _mm_srai_epi32(__A, __B) \
1108 ((__m128i)__builtin_ia32_psradi128 ((__v8hi)(__A), __B))
1112 static __m128i
__attribute__((__always_inline__
))
1113 _mm_srli_si128 (__m128i __A
, int __B
)
1115 return ((__m128i
)__builtin_ia32_psrldqi128 (__A
, __B
* 8));
1118 static __m128i
__attribute__((__always_inline__
))
1119 _mm_srli_si128 (__m128i __A
, int __B
)
1121 return ((__m128i
)__builtin_ia32_pslldqi128 (__A
, __B
* 8));
1124 #define _mm_srli_si128(__A, __B) \
1125 ((__m128i)__builtin_ia32_psrldqi128 (__A, (__B) * 8))
1126 #define _mm_slli_si128(__A, __B) \
1127 ((__m128i)__builtin_ia32_pslldqi128 (__A, (__B) * 8))
1131 static __inline __m128i
__attribute__((__always_inline__
))
1132 _mm_srli_epi16 (__m128i __A
, int __B
)
1134 return (__m128i
)__builtin_ia32_psrlwi128 ((__v8hi
)__A
, __B
);
1137 static __inline __m128i
__attribute__((__always_inline__
))
1138 _mm_srli_epi32 (__m128i __A
, int __B
)
1140 return (__m128i
)__builtin_ia32_psrldi128 ((__v4si
)__A
, __B
);
1143 static __inline __m128i
__attribute__((__always_inline__
))
1144 _mm_srli_epi64 (__m128i __A
, int __B
)
1146 return (__m128i
)__builtin_ia32_psrlqi128 ((__v2di
)__A
, __B
);
1149 #define _mm_srli_epi16(__A, __B) \
1150 ((__m128i)__builtin_ia32_psrlwi128 ((__v8hi)(__A), __B))
1151 #define _mm_srli_epi32(__A, __B) \
1152 ((__m128i)__builtin_ia32_psrldi128 ((__v4si)(__A), __B))
1153 #define _mm_srli_epi64(__A, __B) \
1154 ((__m128i)__builtin_ia32_psrlqi128 ((__v4si)(__A), __B))
1157 static __inline __m128i
__attribute__((__always_inline__
))
1158 _mm_sll_epi16 (__m128i __A
, __m128i __B
)
1160 return (__m128i
)__builtin_ia32_psllw128((__v8hi
)__A
, (__v8hi
)__B
);
1163 static __inline __m128i
__attribute__((__always_inline__
))
1164 _mm_sll_epi32 (__m128i __A
, __m128i __B
)
1166 return (__m128i
)__builtin_ia32_pslld128((__v4si
)__A
, (__v4si
)__B
);
1169 static __inline __m128i
__attribute__((__always_inline__
))
1170 _mm_sll_epi64 (__m128i __A
, __m128i __B
)
1172 return (__m128i
)__builtin_ia32_psllq128((__v2di
)__A
, (__v2di
)__B
);
1175 static __inline __m128i
__attribute__((__always_inline__
))
1176 _mm_sra_epi16 (__m128i __A
, __m128i __B
)
1178 return (__m128i
)__builtin_ia32_psraw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1181 static __inline __m128i
__attribute__((__always_inline__
))
1182 _mm_sra_epi32 (__m128i __A
, __m128i __B
)
1184 return (__m128i
)__builtin_ia32_psrad128 ((__v4si
)__A
, (__v4si
)__B
);
1187 static __inline __m128i
__attribute__((__always_inline__
))
1188 _mm_srl_epi16 (__m128i __A
, __m128i __B
)
1190 return (__m128i
)__builtin_ia32_psrlw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1193 static __inline __m128i
__attribute__((__always_inline__
))
1194 _mm_srl_epi32 (__m128i __A
, __m128i __B
)
1196 return (__m128i
)__builtin_ia32_psrld128 ((__v4si
)__A
, (__v4si
)__B
);
1199 static __inline __m128i
__attribute__((__always_inline__
))
1200 _mm_srl_epi64 (__m128i __A
, __m128i __B
)
1202 return (__m128i
)__builtin_ia32_psrlq128 ((__v2di
)__A
, (__v2di
)__B
);
1205 static __inline __m128i
__attribute__((__always_inline__
))
1206 _mm_and_si128 (__m128i __A
, __m128i __B
)
1208 return (__m128i
)__builtin_ia32_pand128 ((__v2di
)__A
, (__v2di
)__B
);
1211 static __inline __m128i
__attribute__((__always_inline__
))
1212 _mm_andnot_si128 (__m128i __A
, __m128i __B
)
1214 return (__m128i
)__builtin_ia32_pandn128 ((__v2di
)__A
, (__v2di
)__B
);
1217 static __inline __m128i
__attribute__((__always_inline__
))
1218 _mm_or_si128 (__m128i __A
, __m128i __B
)
1220 return (__m128i
)__builtin_ia32_por128 ((__v2di
)__A
, (__v2di
)__B
);
1223 static __inline __m128i
__attribute__((__always_inline__
))
1224 _mm_xor_si128 (__m128i __A
, __m128i __B
)
1226 return (__m128i
)__builtin_ia32_pxor128 ((__v2di
)__A
, (__v2di
)__B
);
1229 static __inline __m128i
__attribute__((__always_inline__
))
1230 _mm_cmpeq_epi8 (__m128i __A
, __m128i __B
)
1232 return (__m128i
)__builtin_ia32_pcmpeqb128 ((__v16qi
)__A
, (__v16qi
)__B
);
1235 static __inline __m128i
__attribute__((__always_inline__
))
1236 _mm_cmpeq_epi16 (__m128i __A
, __m128i __B
)
1238 return (__m128i
)__builtin_ia32_pcmpeqw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1241 static __inline __m128i
__attribute__((__always_inline__
))
1242 _mm_cmpeq_epi32 (__m128i __A
, __m128i __B
)
1244 return (__m128i
)__builtin_ia32_pcmpeqd128 ((__v4si
)__A
, (__v4si
)__B
);
1247 static __inline __m128i
__attribute__((__always_inline__
))
1248 _mm_cmplt_epi8 (__m128i __A
, __m128i __B
)
1250 return (__m128i
)__builtin_ia32_pcmpgtb128 ((__v16qi
)__B
, (__v16qi
)__A
);
1253 static __inline __m128i
__attribute__((__always_inline__
))
1254 _mm_cmplt_epi16 (__m128i __A
, __m128i __B
)
1256 return (__m128i
)__builtin_ia32_pcmpgtw128 ((__v8hi
)__B
, (__v8hi
)__A
);
1259 static __inline __m128i
__attribute__((__always_inline__
))
1260 _mm_cmplt_epi32 (__m128i __A
, __m128i __B
)
1262 return (__m128i
)__builtin_ia32_pcmpgtd128 ((__v4si
)__B
, (__v4si
)__A
);
1265 static __inline __m128i
__attribute__((__always_inline__
))
1266 _mm_cmpgt_epi8 (__m128i __A
, __m128i __B
)
1268 return (__m128i
)__builtin_ia32_pcmpgtb128 ((__v16qi
)__A
, (__v16qi
)__B
);
1271 static __inline __m128i
__attribute__((__always_inline__
))
1272 _mm_cmpgt_epi16 (__m128i __A
, __m128i __B
)
1274 return (__m128i
)__builtin_ia32_pcmpgtw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1277 static __inline __m128i
__attribute__((__always_inline__
))
1278 _mm_cmpgt_epi32 (__m128i __A
, __m128i __B
)
1280 return (__m128i
)__builtin_ia32_pcmpgtd128 ((__v4si
)__A
, (__v4si
)__B
);
1284 static __inline
int __attribute__((__always_inline__
))
1285 _mm_extract_epi16 (__m128i
const __A
, int const __N
)
1287 return __builtin_ia32_vec_ext_v8hi ((__v8hi
)__A
, __N
);
1290 static __inline __m128i
__attribute__((__always_inline__
))
1291 _mm_insert_epi16 (__m128i
const __A
, int const __D
, int const __N
)
1293 return (__m128i
) __builtin_ia32_vec_set_v8hi ((__v8hi
)__A
, __D
, __N
);
1296 #define _mm_extract_epi16(A, N) \
1297 ((int) __builtin_ia32_vec_ext_v8hi ((__v8hi)(A), (N)))
1298 #define _mm_insert_epi16(A, D, N) \
1299 ((__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)(A), (D), (N)))
1302 static __inline __m128i
__attribute__((__always_inline__
))
1303 _mm_max_epi16 (__m128i __A
, __m128i __B
)
1305 return (__m128i
)__builtin_ia32_pmaxsw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1308 static __inline __m128i
__attribute__((__always_inline__
))
1309 _mm_max_epu8 (__m128i __A
, __m128i __B
)
1311 return (__m128i
)__builtin_ia32_pmaxub128 ((__v16qi
)__A
, (__v16qi
)__B
);
1314 static __inline __m128i
__attribute__((__always_inline__
))
1315 _mm_min_epi16 (__m128i __A
, __m128i __B
)
1317 return (__m128i
)__builtin_ia32_pminsw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1320 static __inline __m128i
__attribute__((__always_inline__
))
1321 _mm_min_epu8 (__m128i __A
, __m128i __B
)
1323 return (__m128i
)__builtin_ia32_pminub128 ((__v16qi
)__A
, (__v16qi
)__B
);
1326 static __inline
int __attribute__((__always_inline__
))
1327 _mm_movemask_epi8 (__m128i __A
)
1329 return __builtin_ia32_pmovmskb128 ((__v16qi
)__A
);
1332 static __inline __m128i
__attribute__((__always_inline__
))
1333 _mm_mulhi_epu16 (__m128i __A
, __m128i __B
)
1335 return (__m128i
)__builtin_ia32_pmulhuw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1338 #define _mm_shufflehi_epi16(__A, __B) ((__m128i)__builtin_ia32_pshufhw ((__v8hi)__A, __B))
1339 #define _mm_shufflelo_epi16(__A, __B) ((__m128i)__builtin_ia32_pshuflw ((__v8hi)__A, __B))
1340 #define _mm_shuffle_epi32(__A, __B) ((__m128i)__builtin_ia32_pshufd ((__v4si)__A, __B))
1342 static __inline
void __attribute__((__always_inline__
))
1343 _mm_maskmoveu_si128 (__m128i __A
, __m128i __B
, char *__C
)
1345 __builtin_ia32_maskmovdqu ((__v16qi
)__A
, (__v16qi
)__B
, __C
);
1348 static __inline __m128i
__attribute__((__always_inline__
))
1349 _mm_avg_epu8 (__m128i __A
, __m128i __B
)
1351 return (__m128i
)__builtin_ia32_pavgb128 ((__v16qi
)__A
, (__v16qi
)__B
);
1354 static __inline __m128i
__attribute__((__always_inline__
))
1355 _mm_avg_epu16 (__m128i __A
, __m128i __B
)
1357 return (__m128i
)__builtin_ia32_pavgw128 ((__v8hi
)__A
, (__v8hi
)__B
);
1360 static __inline __m128i
__attribute__((__always_inline__
))
1361 _mm_sad_epu8 (__m128i __A
, __m128i __B
)
1363 return (__m128i
)__builtin_ia32_psadbw128 ((__v16qi
)__A
, (__v16qi
)__B
);
1366 static __inline
void __attribute__((__always_inline__
))
1367 _mm_stream_si32 (int *__A
, int __B
)
1369 __builtin_ia32_movnti (__A
, __B
);
1372 static __inline
void __attribute__((__always_inline__
))
1373 _mm_stream_si128 (__m128i
*__A
, __m128i __B
)
1375 __builtin_ia32_movntdq ((__v2di
*)__A
, (__v2di
)__B
);
1378 static __inline
void __attribute__((__always_inline__
))
1379 _mm_stream_pd (double *__A
, __m128d __B
)
1381 __builtin_ia32_movntpd (__A
, (__v2df
)__B
);
1384 static __inline
void __attribute__((__always_inline__
))
1385 _mm_clflush (void const *__A
)
1387 __builtin_ia32_clflush (__A
);
1390 static __inline
void __attribute__((__always_inline__
))
1393 __builtin_ia32_lfence ();
1396 static __inline
void __attribute__((__always_inline__
))
1399 __builtin_ia32_mfence ();
1402 static __inline __m128i
__attribute__((__always_inline__
))
1403 _mm_cvtsi32_si128 (int __A
)
1405 return _mm_set_epi32 (0, 0, 0, __A
);
1409 static __inline __m128i
__attribute__((__always_inline__
))
1410 _mm_cvtsi64x_si128 (long long __A
)
1412 return _mm_set_epi64x (0, __A
);
1416 /* Casts between various SP, DP, INT vector types. Note that these do no
1417 conversion of values, they just change the type. */
1418 static __inline __m128
__attribute__((__always_inline__
))
1419 _mm_castpd_ps(__m128d __A
)
1421 return (__m128
) __A
;
1424 static __inline __m128i
__attribute__((__always_inline__
))
1425 _mm_castpd_si128(__m128d __A
)
1427 return (__m128i
) __A
;
1430 static __inline __m128d
__attribute__((__always_inline__
))
1431 _mm_castps_pd(__m128 __A
)
1433 return (__m128d
) __A
;
1436 static __inline __m128i
__attribute__((__always_inline__
))
1437 _mm_castps_si128(__m128 __A
)
1439 return (__m128i
) __A
;
1442 static __inline __m128
__attribute__((__always_inline__
))
1443 _mm_castsi128_ps(__m128i __A
)
1445 return (__m128
) __A
;
1448 static __inline __m128d
__attribute__((__always_inline__
))
1449 _mm_castsi128_pd(__m128i __A
)
1451 return (__m128d
) __A
;
1454 #endif /* __SSE2__ */
1456 #endif /* _EMMINTRIN_H_INCLUDED */