blob: e777ec0171ea73e787e010d69f1bf5e2bc4a2602 [file] [log] [blame]
Ying Wanga6720142011-12-20 14:43:20 -08001/*===---- xmmintrin.h - SSE intrinsics -------------------------------------===
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 *
21 *===-----------------------------------------------------------------------===
22 */
23
24#ifndef __XMMINTRIN_H
25#define __XMMINTRIN_H
26
27#ifndef __SSE__
28#error "SSE instruction set not enabled"
29#else
30
31#include <mmintrin.h>
32
33typedef int __v4si __attribute__((__vector_size__(16)));
34typedef float __v4sf __attribute__((__vector_size__(16)));
35typedef float __m128 __attribute__((__vector_size__(16)));
36
37// This header should only be included in a hosted environment as it depends on
38// a standard library to provide allocation routines.
39#if __STDC_HOSTED__
40#include <mm_malloc.h>
41#endif
42
43static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070044_mm_add_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080045{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070046 __a[0] += __b[0];
47 return __a;
Ying Wanga6720142011-12-20 14:43:20 -080048}
49
50static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070051_mm_add_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080052{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070053 return __a + __b;
Ying Wanga6720142011-12-20 14:43:20 -080054}
55
56static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070057_mm_sub_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080058{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070059 __a[0] -= __b[0];
60 return __a;
Ying Wanga6720142011-12-20 14:43:20 -080061}
62
63static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070064_mm_sub_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080065{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070066 return __a - __b;
Ying Wanga6720142011-12-20 14:43:20 -080067}
68
69static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070070_mm_mul_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080071{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070072 __a[0] *= __b[0];
73 return __a;
Ying Wanga6720142011-12-20 14:43:20 -080074}
75
76static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070077_mm_mul_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080078{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070079 return __a * __b;
Ying Wanga6720142011-12-20 14:43:20 -080080}
81
82static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070083_mm_div_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080084{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070085 __a[0] /= __b[0];
86 return __a;
Ying Wanga6720142011-12-20 14:43:20 -080087}
88
89static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070090_mm_div_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -080091{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070092 return __a / __b;
Ying Wanga6720142011-12-20 14:43:20 -080093}
94
95static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070096_mm_sqrt_ss(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -080097{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -070098 __m128 __c = __builtin_ia32_sqrtss(__a);
99 return (__m128) { __c[0], __a[1], __a[2], __a[3] };
Ying Wanga6720142011-12-20 14:43:20 -0800100}
101
102static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700103_mm_sqrt_ps(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800104{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700105 return __builtin_ia32_sqrtps(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800106}
107
108static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700109_mm_rcp_ss(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800110{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700111 __m128 __c = __builtin_ia32_rcpss(__a);
112 return (__m128) { __c[0], __a[1], __a[2], __a[3] };
Ying Wanga6720142011-12-20 14:43:20 -0800113}
114
115static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700116_mm_rcp_ps(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800117{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700118 return __builtin_ia32_rcpps(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800119}
120
121static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700122_mm_rsqrt_ss(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800123{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700124 __m128 __c = __builtin_ia32_rsqrtss(__a);
125 return (__m128) { __c[0], __a[1], __a[2], __a[3] };
Ying Wanga6720142011-12-20 14:43:20 -0800126}
127
128static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700129_mm_rsqrt_ps(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800130{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700131 return __builtin_ia32_rsqrtps(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800132}
133
134static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700135_mm_min_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800136{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700137 return __builtin_ia32_minss(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800138}
139
140static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700141_mm_min_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800142{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700143 return __builtin_ia32_minps(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800144}
145
146static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700147_mm_max_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800148{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700149 return __builtin_ia32_maxss(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800150}
151
152static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700153_mm_max_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800154{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700155 return __builtin_ia32_maxps(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800156}
157
158static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700159_mm_and_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800160{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700161 return (__m128)((__v4si)__a & (__v4si)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800162}
163
164static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700165_mm_andnot_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800166{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700167 return (__m128)(~(__v4si)__a & (__v4si)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800168}
169
170static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700171_mm_or_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800172{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700173 return (__m128)((__v4si)__a | (__v4si)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800174}
175
176static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700177_mm_xor_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800178{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700179 return (__m128)((__v4si)__a ^ (__v4si)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800180}
181
182static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700183_mm_cmpeq_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800184{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700185 return (__m128)__builtin_ia32_cmpss(__a, __b, 0);
Ying Wanga6720142011-12-20 14:43:20 -0800186}
187
188static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700189_mm_cmpeq_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800190{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700191 return (__m128)__builtin_ia32_cmpps(__a, __b, 0);
Ying Wanga6720142011-12-20 14:43:20 -0800192}
193
194static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700195_mm_cmplt_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800196{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700197 return (__m128)__builtin_ia32_cmpss(__a, __b, 1);
Ying Wanga6720142011-12-20 14:43:20 -0800198}
199
200static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700201_mm_cmplt_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800202{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700203 return (__m128)__builtin_ia32_cmpps(__a, __b, 1);
Ying Wanga6720142011-12-20 14:43:20 -0800204}
205
206static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700207_mm_cmple_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800208{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700209 return (__m128)__builtin_ia32_cmpss(__a, __b, 2);
Ying Wanga6720142011-12-20 14:43:20 -0800210}
211
212static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700213_mm_cmple_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800214{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700215 return (__m128)__builtin_ia32_cmpps(__a, __b, 2);
Ying Wanga6720142011-12-20 14:43:20 -0800216}
217
218static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700219_mm_cmpgt_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800220{
Stephen Hines996e4dc2013-08-13 01:04:14 -0700221 return (__m128)__builtin_shufflevector(__a,
222 __builtin_ia32_cmpss(__b, __a, 1),
223 4, 1, 2, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800224}
225
226static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700227_mm_cmpgt_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800228{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700229 return (__m128)__builtin_ia32_cmpps(__b, __a, 1);
Ying Wanga6720142011-12-20 14:43:20 -0800230}
231
232static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700233_mm_cmpge_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800234{
Stephen Hines996e4dc2013-08-13 01:04:14 -0700235 return (__m128)__builtin_shufflevector(__a,
236 __builtin_ia32_cmpss(__b, __a, 2),
237 4, 1, 2, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800238}
239
240static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700241_mm_cmpge_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800242{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700243 return (__m128)__builtin_ia32_cmpps(__b, __a, 2);
Ying Wanga6720142011-12-20 14:43:20 -0800244}
245
246static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700247_mm_cmpneq_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800248{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700249 return (__m128)__builtin_ia32_cmpss(__a, __b, 4);
Ying Wanga6720142011-12-20 14:43:20 -0800250}
251
252static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700253_mm_cmpneq_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800254{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700255 return (__m128)__builtin_ia32_cmpps(__a, __b, 4);
Ying Wanga6720142011-12-20 14:43:20 -0800256}
257
258static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700259_mm_cmpnlt_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800260{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700261 return (__m128)__builtin_ia32_cmpss(__a, __b, 5);
Ying Wanga6720142011-12-20 14:43:20 -0800262}
263
264static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700265_mm_cmpnlt_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800266{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700267 return (__m128)__builtin_ia32_cmpps(__a, __b, 5);
Ying Wanga6720142011-12-20 14:43:20 -0800268}
269
270static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700271_mm_cmpnle_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800272{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700273 return (__m128)__builtin_ia32_cmpss(__a, __b, 6);
Ying Wanga6720142011-12-20 14:43:20 -0800274}
275
276static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700277_mm_cmpnle_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800278{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700279 return (__m128)__builtin_ia32_cmpps(__a, __b, 6);
Ying Wanga6720142011-12-20 14:43:20 -0800280}
281
282static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700283_mm_cmpngt_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800284{
Stephen Hines996e4dc2013-08-13 01:04:14 -0700285 return (__m128)__builtin_shufflevector(__a,
286 __builtin_ia32_cmpss(__b, __a, 5),
287 4, 1, 2, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800288}
289
290static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700291_mm_cmpngt_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800292{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700293 return (__m128)__builtin_ia32_cmpps(__b, __a, 5);
Ying Wanga6720142011-12-20 14:43:20 -0800294}
295
296static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700297_mm_cmpnge_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800298{
Stephen Hines996e4dc2013-08-13 01:04:14 -0700299 return (__m128)__builtin_shufflevector(__a,
300 __builtin_ia32_cmpss(__b, __a, 6),
301 4, 1, 2, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800302}
303
304static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700305_mm_cmpnge_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800306{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700307 return (__m128)__builtin_ia32_cmpps(__b, __a, 6);
Ying Wanga6720142011-12-20 14:43:20 -0800308}
309
310static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700311_mm_cmpord_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800312{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700313 return (__m128)__builtin_ia32_cmpss(__a, __b, 7);
Ying Wanga6720142011-12-20 14:43:20 -0800314}
315
316static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700317_mm_cmpord_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800318{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700319 return (__m128)__builtin_ia32_cmpps(__a, __b, 7);
Ying Wanga6720142011-12-20 14:43:20 -0800320}
321
322static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700323_mm_cmpunord_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800324{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700325 return (__m128)__builtin_ia32_cmpss(__a, __b, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800326}
327
328static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700329_mm_cmpunord_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800330{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700331 return (__m128)__builtin_ia32_cmpps(__a, __b, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800332}
333
334static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700335_mm_comieq_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800336{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700337 return __builtin_ia32_comieq(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800338}
339
340static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700341_mm_comilt_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800342{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700343 return __builtin_ia32_comilt(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800344}
345
346static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700347_mm_comile_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800348{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700349 return __builtin_ia32_comile(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800350}
351
352static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700353_mm_comigt_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800354{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700355 return __builtin_ia32_comigt(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800356}
357
358static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700359_mm_comige_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800360{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700361 return __builtin_ia32_comige(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800362}
363
364static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700365_mm_comineq_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800366{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700367 return __builtin_ia32_comineq(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800368}
369
370static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700371_mm_ucomieq_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800372{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700373 return __builtin_ia32_ucomieq(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800374}
375
376static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700377_mm_ucomilt_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800378{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700379 return __builtin_ia32_ucomilt(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800380}
381
382static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700383_mm_ucomile_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800384{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700385 return __builtin_ia32_ucomile(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800386}
387
388static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700389_mm_ucomigt_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800390{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700391 return __builtin_ia32_ucomigt(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800392}
393
394static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700395_mm_ucomige_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800396{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700397 return __builtin_ia32_ucomige(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800398}
399
400static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700401_mm_ucomineq_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800402{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700403 return __builtin_ia32_ucomineq(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800404}
405
406static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700407_mm_cvtss_si32(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800408{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700409 return __builtin_ia32_cvtss2si(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800410}
411
412static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700413_mm_cvt_ss2si(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800414{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700415 return _mm_cvtss_si32(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800416}
417
418#ifdef __x86_64__
419
420static __inline__ long long __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700421_mm_cvtss_si64(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800422{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700423 return __builtin_ia32_cvtss2si64(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800424}
425
426#endif
427
428static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700429_mm_cvtps_pi32(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800430{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700431 return (__m64)__builtin_ia32_cvtps2pi(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800432}
433
434static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700435_mm_cvt_ps2pi(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800436{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700437 return _mm_cvtps_pi32(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800438}
439
440static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700441_mm_cvttss_si32(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800442{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700443 return __a[0];
Ying Wanga6720142011-12-20 14:43:20 -0800444}
445
446static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700447_mm_cvtt_ss2si(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800448{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700449 return _mm_cvttss_si32(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800450}
451
452static __inline__ long long __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700453_mm_cvttss_si64(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800454{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700455 return __a[0];
Ying Wanga6720142011-12-20 14:43:20 -0800456}
457
458static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700459_mm_cvttps_pi32(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800460{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700461 return (__m64)__builtin_ia32_cvttps2pi(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800462}
463
464static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700465_mm_cvtt_ps2pi(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800466{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700467 return _mm_cvttps_pi32(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800468}
469
470static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700471_mm_cvtsi32_ss(__m128 __a, int __b)
Ying Wanga6720142011-12-20 14:43:20 -0800472{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700473 __a[0] = __b;
474 return __a;
Ying Wanga6720142011-12-20 14:43:20 -0800475}
476
477static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700478_mm_cvt_si2ss(__m128 __a, int __b)
Ying Wanga6720142011-12-20 14:43:20 -0800479{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700480 return _mm_cvtsi32_ss(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800481}
482
483#ifdef __x86_64__
484
485static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700486_mm_cvtsi64_ss(__m128 __a, long long __b)
Ying Wanga6720142011-12-20 14:43:20 -0800487{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700488 __a[0] = __b;
489 return __a;
Ying Wanga6720142011-12-20 14:43:20 -0800490}
491
492#endif
493
494static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700495_mm_cvtpi32_ps(__m128 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800496{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700497 return __builtin_ia32_cvtpi2ps(__a, (__v2si)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800498}
499
500static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700501_mm_cvt_pi2ps(__m128 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800502{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700503 return _mm_cvtpi32_ps(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800504}
505
506static __inline__ float __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700507_mm_cvtss_f32(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800508{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700509 return __a[0];
Ying Wanga6720142011-12-20 14:43:20 -0800510}
511
512static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700513_mm_loadh_pi(__m128 __a, const __m64 *__p)
Ying Wanga6720142011-12-20 14:43:20 -0800514{
515 typedef float __mm_loadh_pi_v2f32 __attribute__((__vector_size__(8)));
516 struct __mm_loadh_pi_struct {
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700517 __mm_loadh_pi_v2f32 __u;
Ying Wanga6720142011-12-20 14:43:20 -0800518 } __attribute__((__packed__, __may_alias__));
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700519 __mm_loadh_pi_v2f32 __b = ((struct __mm_loadh_pi_struct*)__p)->__u;
520 __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
521 return __builtin_shufflevector(__a, __bb, 0, 1, 4, 5);
Ying Wanga6720142011-12-20 14:43:20 -0800522}
523
524static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700525_mm_loadl_pi(__m128 __a, const __m64 *__p)
Ying Wanga6720142011-12-20 14:43:20 -0800526{
527 typedef float __mm_loadl_pi_v2f32 __attribute__((__vector_size__(8)));
528 struct __mm_loadl_pi_struct {
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700529 __mm_loadl_pi_v2f32 __u;
Ying Wanga6720142011-12-20 14:43:20 -0800530 } __attribute__((__packed__, __may_alias__));
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700531 __mm_loadl_pi_v2f32 __b = ((struct __mm_loadl_pi_struct*)__p)->__u;
532 __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
533 return __builtin_shufflevector(__a, __bb, 4, 5, 2, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800534}
535
536static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700537_mm_load_ss(const float *__p)
Ying Wanga6720142011-12-20 14:43:20 -0800538{
539 struct __mm_load_ss_struct {
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700540 float __u;
Ying Wanga6720142011-12-20 14:43:20 -0800541 } __attribute__((__packed__, __may_alias__));
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700542 float __u = ((struct __mm_load_ss_struct*)__p)->__u;
543 return (__m128){ __u, 0, 0, 0 };
Ying Wanga6720142011-12-20 14:43:20 -0800544}
545
546static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700547_mm_load1_ps(const float *__p)
Ying Wanga6720142011-12-20 14:43:20 -0800548{
549 struct __mm_load1_ps_struct {
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700550 float __u;
Ying Wanga6720142011-12-20 14:43:20 -0800551 } __attribute__((__packed__, __may_alias__));
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700552 float __u = ((struct __mm_load1_ps_struct*)__p)->__u;
553 return (__m128){ __u, __u, __u, __u };
Ying Wanga6720142011-12-20 14:43:20 -0800554}
555
556#define _mm_load_ps1(p) _mm_load1_ps(p)
557
558static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700559_mm_load_ps(const float *__p)
Ying Wanga6720142011-12-20 14:43:20 -0800560{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700561 return *(__m128*)__p;
Ying Wanga6720142011-12-20 14:43:20 -0800562}
563
564static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700565_mm_loadu_ps(const float *__p)
Ying Wanga6720142011-12-20 14:43:20 -0800566{
567 struct __loadu_ps {
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700568 __m128 __v;
Ying Wanga6720142011-12-20 14:43:20 -0800569 } __attribute__((__packed__, __may_alias__));
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700570 return ((struct __loadu_ps*)__p)->__v;
Ying Wanga6720142011-12-20 14:43:20 -0800571}
572
573static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700574_mm_loadr_ps(const float *__p)
Ying Wanga6720142011-12-20 14:43:20 -0800575{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700576 __m128 __a = _mm_load_ps(__p);
577 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
Ying Wanga6720142011-12-20 14:43:20 -0800578}
579
580static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700581_mm_set_ss(float __w)
Ying Wanga6720142011-12-20 14:43:20 -0800582{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700583 return (__m128){ __w, 0, 0, 0 };
Ying Wanga6720142011-12-20 14:43:20 -0800584}
585
586static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700587_mm_set1_ps(float __w)
Ying Wanga6720142011-12-20 14:43:20 -0800588{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700589 return (__m128){ __w, __w, __w, __w };
Ying Wanga6720142011-12-20 14:43:20 -0800590}
591
592// Microsoft specific.
593static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700594_mm_set_ps1(float __w)
Ying Wanga6720142011-12-20 14:43:20 -0800595{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700596 return _mm_set1_ps(__w);
Ying Wanga6720142011-12-20 14:43:20 -0800597}
598
599static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700600_mm_set_ps(float __z, float __y, float __x, float __w)
Ying Wanga6720142011-12-20 14:43:20 -0800601{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700602 return (__m128){ __w, __x, __y, __z };
Ying Wanga6720142011-12-20 14:43:20 -0800603}
604
605static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700606_mm_setr_ps(float __z, float __y, float __x, float __w)
Ying Wanga6720142011-12-20 14:43:20 -0800607{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700608 return (__m128){ __z, __y, __x, __w };
Ying Wanga6720142011-12-20 14:43:20 -0800609}
610
611static __inline__ __m128 __attribute__((__always_inline__))
612_mm_setzero_ps(void)
613{
614 return (__m128){ 0, 0, 0, 0 };
615}
616
617static __inline__ void __attribute__((__always_inline__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700618_mm_storeh_pi(__m64 *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800619{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700620 __builtin_ia32_storehps((__v2si *)__p, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800621}
622
623static __inline__ void __attribute__((__always_inline__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700624_mm_storel_pi(__m64 *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800625{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700626 __builtin_ia32_storelps((__v2si *)__p, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800627}
628
629static __inline__ void __attribute__((__always_inline__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700630_mm_store_ss(float *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800631{
632 struct __mm_store_ss_struct {
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700633 float __u;
Ying Wanga6720142011-12-20 14:43:20 -0800634 } __attribute__((__packed__, __may_alias__));
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700635 ((struct __mm_store_ss_struct*)__p)->__u = __a[0];
Ying Wanga6720142011-12-20 14:43:20 -0800636}
637
638static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700639_mm_storeu_ps(float *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800640{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700641 __builtin_ia32_storeups(__p, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800642}
643
644static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700645_mm_store1_ps(float *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800646{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700647 __a = __builtin_shufflevector(__a, __a, 0, 0, 0, 0);
648 _mm_storeu_ps(__p, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800649}
650
651static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700652_mm_store_ps1(float *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800653{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700654 return _mm_store1_ps(__p, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800655}
656
657static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700658_mm_store_ps(float *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800659{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700660 *(__m128 *)__p = __a;
Ying Wanga6720142011-12-20 14:43:20 -0800661}
662
663static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700664_mm_storer_ps(float *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800665{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700666 __a = __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
667 _mm_store_ps(__p, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800668}
669
670#define _MM_HINT_T0 3
671#define _MM_HINT_T1 2
672#define _MM_HINT_T2 1
673#define _MM_HINT_NTA 0
674
Stephen Hines30047ab2014-04-24 10:38:22 -0700675#ifndef _MSC_VER
Ying Wanga6720142011-12-20 14:43:20 -0800676/* FIXME: We have to #define this because "sel" must be a constant integer, and
677 Sema doesn't do any form of constant propagation yet. */
678
Ying Wang60999142013-01-07 13:59:36 -0800679#define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), 0, (sel)))
Stephen Hines30047ab2014-04-24 10:38:22 -0700680#endif
Ying Wanga6720142011-12-20 14:43:20 -0800681
682static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700683_mm_stream_pi(__m64 *__p, __m64 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800684{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700685 __builtin_ia32_movntq(__p, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800686}
687
688static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700689_mm_stream_ps(float *__p, __m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800690{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700691 __builtin_ia32_movntps(__p, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800692}
693
694static __inline__ void __attribute__((__always_inline__, __nodebug__))
695_mm_sfence(void)
696{
697 __builtin_ia32_sfence();
698}
699
700static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700701_mm_extract_pi16(__m64 __a, int __n)
Ying Wanga6720142011-12-20 14:43:20 -0800702{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700703 __v4hi __b = (__v4hi)__a;
704 return (unsigned short)__b[__n & 3];
Ying Wanga6720142011-12-20 14:43:20 -0800705}
706
707static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700708_mm_insert_pi16(__m64 __a, int __d, int __n)
Ying Wanga6720142011-12-20 14:43:20 -0800709{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700710 __v4hi __b = (__v4hi)__a;
711 __b[__n & 3] = __d;
712 return (__m64)__b;
Ying Wanga6720142011-12-20 14:43:20 -0800713}
714
715static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700716_mm_max_pi16(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800717{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700718 return (__m64)__builtin_ia32_pmaxsw((__v4hi)__a, (__v4hi)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800719}
720
721static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700722_mm_max_pu8(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800723{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700724 return (__m64)__builtin_ia32_pmaxub((__v8qi)__a, (__v8qi)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800725}
726
727static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700728_mm_min_pi16(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800729{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700730 return (__m64)__builtin_ia32_pminsw((__v4hi)__a, (__v4hi)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800731}
732
733static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700734_mm_min_pu8(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800735{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700736 return (__m64)__builtin_ia32_pminub((__v8qi)__a, (__v8qi)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800737}
738
739static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700740_mm_movemask_pi8(__m64 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800741{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700742 return __builtin_ia32_pmovmskb((__v8qi)__a);
Ying Wanga6720142011-12-20 14:43:20 -0800743}
744
745static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700746_mm_mulhi_pu16(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800747{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700748 return (__m64)__builtin_ia32_pmulhuw((__v4hi)__a, (__v4hi)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800749}
750
Ying Wang60999142013-01-07 13:59:36 -0800751#define _mm_shuffle_pi16(a, n) __extension__ ({ \
752 __m64 __a = (a); \
753 (__m64)__builtin_ia32_pshufw((__v4hi)__a, (n)); })
Ying Wanga6720142011-12-20 14:43:20 -0800754
755static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700756_mm_maskmove_si64(__m64 __d, __m64 __n, char *__p)
Ying Wanga6720142011-12-20 14:43:20 -0800757{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700758 __builtin_ia32_maskmovq((__v8qi)__d, (__v8qi)__n, __p);
Ying Wanga6720142011-12-20 14:43:20 -0800759}
760
761static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700762_mm_avg_pu8(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800763{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700764 return (__m64)__builtin_ia32_pavgb((__v8qi)__a, (__v8qi)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800765}
766
767static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700768_mm_avg_pu16(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800769{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700770 return (__m64)__builtin_ia32_pavgw((__v4hi)__a, (__v4hi)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800771}
772
773static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700774_mm_sad_pu8(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800775{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700776 return (__m64)__builtin_ia32_psadbw((__v8qi)__a, (__v8qi)__b);
Ying Wanga6720142011-12-20 14:43:20 -0800777}
778
779static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
780_mm_getcsr(void)
781{
782 return __builtin_ia32_stmxcsr();
783}
784
785static __inline__ void __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700786_mm_setcsr(unsigned int __i)
Ying Wanga6720142011-12-20 14:43:20 -0800787{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700788 __builtin_ia32_ldmxcsr(__i);
Ying Wanga6720142011-12-20 14:43:20 -0800789}
790
Ying Wang60999142013-01-07 13:59:36 -0800791#define _mm_shuffle_ps(a, b, mask) __extension__ ({ \
792 __m128 __a = (a); \
793 __m128 __b = (b); \
794 (__m128)__builtin_shufflevector((__v4sf)__a, (__v4sf)__b, \
795 (mask) & 0x3, ((mask) & 0xc) >> 2, \
796 (((mask) & 0x30) >> 4) + 4, \
797 (((mask) & 0xc0) >> 6) + 4); })
Ying Wanga6720142011-12-20 14:43:20 -0800798
799static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700800_mm_unpackhi_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800801{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700802 return __builtin_shufflevector(__a, __b, 2, 6, 3, 7);
Ying Wanga6720142011-12-20 14:43:20 -0800803}
804
805static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700806_mm_unpacklo_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800807{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700808 return __builtin_shufflevector(__a, __b, 0, 4, 1, 5);
Ying Wanga6720142011-12-20 14:43:20 -0800809}
810
811static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700812_mm_move_ss(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800813{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700814 return __builtin_shufflevector(__a, __b, 4, 1, 2, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800815}
816
817static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700818_mm_movehl_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800819{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700820 return __builtin_shufflevector(__a, __b, 6, 7, 2, 3);
Ying Wanga6720142011-12-20 14:43:20 -0800821}
822
823static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700824_mm_movelh_ps(__m128 __a, __m128 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800825{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700826 return __builtin_shufflevector(__a, __b, 0, 1, 4, 5);
Ying Wanga6720142011-12-20 14:43:20 -0800827}
828
829static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700830_mm_cvtpi16_ps(__m64 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800831{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700832 __m64 __b, __c;
833 __m128 __r;
Ying Wanga6720142011-12-20 14:43:20 -0800834
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700835 __b = _mm_setzero_si64();
836 __b = _mm_cmpgt_pi16(__b, __a);
837 __c = _mm_unpackhi_pi16(__a, __b);
838 __r = _mm_setzero_ps();
839 __r = _mm_cvtpi32_ps(__r, __c);
840 __r = _mm_movelh_ps(__r, __r);
841 __c = _mm_unpacklo_pi16(__a, __b);
842 __r = _mm_cvtpi32_ps(__r, __c);
Ying Wanga6720142011-12-20 14:43:20 -0800843
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700844 return __r;
Ying Wanga6720142011-12-20 14:43:20 -0800845}
846
847static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700848_mm_cvtpu16_ps(__m64 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800849{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700850 __m64 __b, __c;
851 __m128 __r;
Ying Wanga6720142011-12-20 14:43:20 -0800852
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700853 __b = _mm_setzero_si64();
854 __c = _mm_unpackhi_pi16(__a, __b);
855 __r = _mm_setzero_ps();
856 __r = _mm_cvtpi32_ps(__r, __c);
857 __r = _mm_movelh_ps(__r, __r);
858 __c = _mm_unpacklo_pi16(__a, __b);
859 __r = _mm_cvtpi32_ps(__r, __c);
Ying Wanga6720142011-12-20 14:43:20 -0800860
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700861 return __r;
Ying Wanga6720142011-12-20 14:43:20 -0800862}
863
864static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700865_mm_cvtpi8_ps(__m64 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800866{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700867 __m64 __b;
Ying Wanga6720142011-12-20 14:43:20 -0800868
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700869 __b = _mm_setzero_si64();
870 __b = _mm_cmpgt_pi8(__b, __a);
871 __b = _mm_unpacklo_pi8(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800872
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700873 return _mm_cvtpi16_ps(__b);
Ying Wanga6720142011-12-20 14:43:20 -0800874}
875
876static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700877_mm_cvtpu8_ps(__m64 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800878{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700879 __m64 __b;
Ying Wanga6720142011-12-20 14:43:20 -0800880
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700881 __b = _mm_setzero_si64();
882 __b = _mm_unpacklo_pi8(__a, __b);
Ying Wanga6720142011-12-20 14:43:20 -0800883
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700884 return _mm_cvtpi16_ps(__b);
Ying Wanga6720142011-12-20 14:43:20 -0800885}
886
887static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700888_mm_cvtpi32x2_ps(__m64 __a, __m64 __b)
Ying Wanga6720142011-12-20 14:43:20 -0800889{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700890 __m128 __c;
Ying Wanga6720142011-12-20 14:43:20 -0800891
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700892 __c = _mm_setzero_ps();
893 __c = _mm_cvtpi32_ps(__c, __b);
894 __c = _mm_movelh_ps(__c, __c);
Ying Wanga6720142011-12-20 14:43:20 -0800895
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700896 return _mm_cvtpi32_ps(__c, __a);
Ying Wanga6720142011-12-20 14:43:20 -0800897}
898
899static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700900_mm_cvtps_pi16(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800901{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700902 __m64 __b, __c;
Ying Wanga6720142011-12-20 14:43:20 -0800903
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700904 __b = _mm_cvtps_pi32(__a);
905 __a = _mm_movehl_ps(__a, __a);
906 __c = _mm_cvtps_pi32(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800907
Stephen Hinese65db132014-05-30 13:26:31 -0700908 return _mm_packs_pi32(__b, __c);
Ying Wanga6720142011-12-20 14:43:20 -0800909}
910
911static __inline__ __m64 __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700912_mm_cvtps_pi8(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800913{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700914 __m64 __b, __c;
Ying Wanga6720142011-12-20 14:43:20 -0800915
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700916 __b = _mm_cvtps_pi16(__a);
917 __c = _mm_setzero_si64();
Ying Wanga6720142011-12-20 14:43:20 -0800918
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700919 return _mm_packs_pi16(__b, __c);
Ying Wanga6720142011-12-20 14:43:20 -0800920}
921
922static __inline__ int __attribute__((__always_inline__, __nodebug__))
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700923_mm_movemask_ps(__m128 __a)
Ying Wanga6720142011-12-20 14:43:20 -0800924{
Stephen Hinesc6ee7df2013-04-02 18:41:57 -0700925 return __builtin_ia32_movmskps(__a);
Ying Wanga6720142011-12-20 14:43:20 -0800926}
927
928#define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
929
930#define _MM_EXCEPT_INVALID (0x0001)
931#define _MM_EXCEPT_DENORM (0x0002)
932#define _MM_EXCEPT_DIV_ZERO (0x0004)
933#define _MM_EXCEPT_OVERFLOW (0x0008)
934#define _MM_EXCEPT_UNDERFLOW (0x0010)
935#define _MM_EXCEPT_INEXACT (0x0020)
936#define _MM_EXCEPT_MASK (0x003f)
937
938#define _MM_MASK_INVALID (0x0080)
939#define _MM_MASK_DENORM (0x0100)
940#define _MM_MASK_DIV_ZERO (0x0200)
941#define _MM_MASK_OVERFLOW (0x0400)
942#define _MM_MASK_UNDERFLOW (0x0800)
943#define _MM_MASK_INEXACT (0x1000)
944#define _MM_MASK_MASK (0x1f80)
945
946#define _MM_ROUND_NEAREST (0x0000)
947#define _MM_ROUND_DOWN (0x2000)
948#define _MM_ROUND_UP (0x4000)
949#define _MM_ROUND_TOWARD_ZERO (0x6000)
950#define _MM_ROUND_MASK (0x6000)
951
952#define _MM_FLUSH_ZERO_MASK (0x8000)
953#define _MM_FLUSH_ZERO_ON (0x8000)
Ying Wang60999142013-01-07 13:59:36 -0800954#define _MM_FLUSH_ZERO_OFF (0x0000)
Ying Wanga6720142011-12-20 14:43:20 -0800955
956#define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK)
957#define _MM_GET_EXCEPTION_STATE() (_mm_getcsr() & _MM_EXCEPT_MASK)
958#define _MM_GET_FLUSH_ZERO_MODE() (_mm_getcsr() & _MM_FLUSH_ZERO_MASK)
959#define _MM_GET_ROUNDING_MODE() (_mm_getcsr() & _MM_ROUND_MASK)
960
961#define _MM_SET_EXCEPTION_MASK(x) (_mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | (x)))
962#define _MM_SET_EXCEPTION_STATE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | (x)))
963#define _MM_SET_FLUSH_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | (x)))
964#define _MM_SET_ROUNDING_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | (x)))
965
966#define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) \
967do { \
968 __m128 tmp3, tmp2, tmp1, tmp0; \
969 tmp0 = _mm_unpacklo_ps((row0), (row1)); \
970 tmp2 = _mm_unpacklo_ps((row2), (row3)); \
971 tmp1 = _mm_unpackhi_ps((row0), (row1)); \
972 tmp3 = _mm_unpackhi_ps((row2), (row3)); \
973 (row0) = _mm_movelh_ps(tmp0, tmp2); \
974 (row1) = _mm_movehl_ps(tmp2, tmp0); \
975 (row2) = _mm_movelh_ps(tmp1, tmp3); \
976 (row3) = _mm_movehl_ps(tmp3, tmp1); \
977} while (0)
978
979/* Aliases for compatibility. */
980#define _m_pextrw _mm_extract_pi16
981#define _m_pinsrw _mm_insert_pi16
982#define _m_pmaxsw _mm_max_pi16
983#define _m_pmaxub _mm_max_pu8
984#define _m_pminsw _mm_min_pi16
985#define _m_pminub _mm_min_pu8
986#define _m_pmovmskb _mm_movemask_pi8
987#define _m_pmulhuw _mm_mulhi_pu16
988#define _m_pshufw _mm_shuffle_pi16
989#define _m_maskmovq _mm_maskmove_si64
990#define _m_pavgb _mm_avg_pu8
991#define _m_pavgw _mm_avg_pu16
992#define _m_psadbw _mm_sad_pu8
993#define _m_ _mm_
994#define _m_ _mm_
995
996/* Ugly hack for backwards-compatibility (compatible with gcc) */
997#ifdef __SSE2__
998#include <emmintrin.h>
999#endif
1000
1001#endif /* __SSE__ */
1002
1003#endif /* __XMMINTRIN_H */