1193326Sed/*===---- xmmintrin.h - SSE intrinsics -------------------------------------===
2193326Sed *
3353358Sdim * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim * See https://llvm.org/LICENSE.txt for license information.
5353358Sdim * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6193326Sed *
7193326Sed *===-----------------------------------------------------------------------===
8193326Sed */
9296417Sdim
10193326Sed#ifndef __XMMINTRIN_H
11193326Sed#define __XMMINTRIN_H
12193326Sed
13193326Sed#include <mmintrin.h>
14193326Sed
15205408Srdivackytypedef int __v4si __attribute__((__vector_size__(16)));
16193326Sedtypedef float __v4sf __attribute__((__vector_size__(16)));
17353358Sdimtypedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
18193326Sed
19353358Sdimtypedef float __m128_u __attribute__((__vector_size__(16), __aligned__(1)));
20353358Sdim
21309124Sdim/* Unsigned types */
22309124Sdimtypedef unsigned int __v4su __attribute__((__vector_size__(16)));
23309124Sdim
24276479Sdim/* This header should only be included in a hosted environment as it depends on
25276479Sdim * a standard library to provide allocation routines. */
26218893Sdim#if __STDC_HOSTED__
27193326Sed#include <mm_malloc.h>
28218893Sdim#endif
29193326Sed
30288943Sdim/* Define the default attributes for the functions in this file. */
31341825Sdim#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse"), __min_vector_width__(128)))
32341825Sdim#define __DEFAULT_FN_ATTRS_MMX __attribute__((__always_inline__, __nodebug__, __target__("mmx,sse"), __min_vector_width__(64)))
33288943Sdim
34341825Sdim/// Adds the 32-bit float values in the low-order bits of the operands.
35309124Sdim///
36309124Sdim/// \headerfile <x86intrin.h>
37309124Sdim///
38314564Sdim/// This intrinsic corresponds to the <c> VADDSS / ADDSS </c> instructions.
39309124Sdim///
40309124Sdim/// \param __a
41309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
42309124Sdim///    The lower 32 bits of this operand are used in the calculation.
43309124Sdim/// \param __b
44309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
45309124Sdim///    The lower 32 bits of this operand are used in the calculation.
46309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the sum
47309124Sdim///    of the lower 32 bits of both operands. The upper 96 bits are copied from
48309124Sdim///    the upper 96 bits of the first source operand.
49288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
50249423Sdim_mm_add_ss(__m128 __a, __m128 __b)
51193326Sed{
52249423Sdim  __a[0] += __b[0];
53249423Sdim  return __a;
54193326Sed}
55193326Sed
56341825Sdim/// Adds two 128-bit vectors of [4 x float], and returns the results of
57309124Sdim///    the addition.
58309124Sdim///
59309124Sdim/// \headerfile <x86intrin.h>
60309124Sdim///
61314564Sdim/// This intrinsic corresponds to the <c> VADDPS / ADDPS </c> instructions.
62309124Sdim///
63309124Sdim/// \param __a
64309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
65309124Sdim/// \param __b
66309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
67309124Sdim/// \returns A 128-bit vector of [4 x float] containing the sums of both
68309124Sdim///    operands.
69288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
70249423Sdim_mm_add_ps(__m128 __a, __m128 __b)
71193326Sed{
72309124Sdim  return (__m128)((__v4sf)__a + (__v4sf)__b);
73193326Sed}
74193326Sed
75341825Sdim/// Subtracts the 32-bit float value in the low-order bits of the second
76309124Sdim///    operand from the corresponding value in the first operand.
77309124Sdim///
78309124Sdim/// \headerfile <x86intrin.h>
79309124Sdim///
80314564Sdim/// This intrinsic corresponds to the <c> VSUBSS / SUBSS </c> instructions.
81309124Sdim///
82309124Sdim/// \param __a
83309124Sdim///    A 128-bit vector of [4 x float] containing the minuend. The lower 32 bits
84309124Sdim///    of this operand are used in the calculation.
85309124Sdim/// \param __b
86309124Sdim///    A 128-bit vector of [4 x float] containing the subtrahend. The lower 32
87309124Sdim///    bits of this operand are used in the calculation.
88309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
89309124Sdim///    difference of the lower 32 bits of both operands. The upper 96 bits are
90309124Sdim///    copied from the upper 96 bits of the first source operand.
91288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
92249423Sdim_mm_sub_ss(__m128 __a, __m128 __b)
93193326Sed{
94249423Sdim  __a[0] -= __b[0];
95249423Sdim  return __a;
96193326Sed}
97193326Sed
98341825Sdim/// Subtracts each of the values of the second operand from the first
99309124Sdim///    operand, both of which are 128-bit vectors of [4 x float] and returns
100309124Sdim///    the results of the subtraction.
101309124Sdim///
102309124Sdim/// \headerfile <x86intrin.h>
103309124Sdim///
104314564Sdim/// This intrinsic corresponds to the <c> VSUBPS / SUBPS </c> instructions.
105309124Sdim///
106309124Sdim/// \param __a
107309124Sdim///    A 128-bit vector of [4 x float] containing the minuend.
108309124Sdim/// \param __b
109309124Sdim///    A 128-bit vector of [4 x float] containing the subtrahend.
110309124Sdim/// \returns A 128-bit vector of [4 x float] containing the differences between
111309124Sdim///    both operands.
112288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
113249423Sdim_mm_sub_ps(__m128 __a, __m128 __b)
114193326Sed{
115309124Sdim  return (__m128)((__v4sf)__a - (__v4sf)__b);
116193326Sed}
117193326Sed
118341825Sdim/// Multiplies two 32-bit float values in the low-order bits of the
119309124Sdim///    operands.
120309124Sdim///
121309124Sdim/// \headerfile <x86intrin.h>
122309124Sdim///
123314564Sdim/// This intrinsic corresponds to the <c> VMULSS / MULSS </c> instructions.
124309124Sdim///
125309124Sdim/// \param __a
126309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
127309124Sdim///    The lower 32 bits of this operand are used in the calculation.
128309124Sdim/// \param __b
129309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
130309124Sdim///    The lower 32 bits of this operand are used in the calculation.
131309124Sdim/// \returns A 128-bit vector of [4 x float] containing the product of the lower
132309124Sdim///    32 bits of both operands. The upper 96 bits are copied from the upper 96
133309124Sdim///    bits of the first source operand.
134288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
135249423Sdim_mm_mul_ss(__m128 __a, __m128 __b)
136193326Sed{
137249423Sdim  __a[0] *= __b[0];
138249423Sdim  return __a;
139193326Sed}
140193326Sed
141341825Sdim/// Multiplies two 128-bit vectors of [4 x float] and returns the
142309124Sdim///    results of the multiplication.
143309124Sdim///
144309124Sdim/// \headerfile <x86intrin.h>
145309124Sdim///
146314564Sdim/// This intrinsic corresponds to the <c> VMULPS / MULPS </c> instructions.
147309124Sdim///
148309124Sdim/// \param __a
149309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
150309124Sdim/// \param __b
151309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
152309124Sdim/// \returns A 128-bit vector of [4 x float] containing the products of both
153309124Sdim///    operands.
154288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
155249423Sdim_mm_mul_ps(__m128 __a, __m128 __b)
156193326Sed{
157309124Sdim  return (__m128)((__v4sf)__a * (__v4sf)__b);
158193326Sed}
159193326Sed
160341825Sdim/// Divides the value in the low-order 32 bits of the first operand by
161309124Sdim///    the corresponding value in the second operand.
162309124Sdim///
163309124Sdim/// \headerfile <x86intrin.h>
164309124Sdim///
165314564Sdim/// This intrinsic corresponds to the <c> VDIVSS / DIVSS </c> instructions.
166309124Sdim///
167309124Sdim/// \param __a
168309124Sdim///    A 128-bit vector of [4 x float] containing the dividend. The lower 32
169309124Sdim///    bits of this operand are used in the calculation.
170309124Sdim/// \param __b
171309124Sdim///    A 128-bit vector of [4 x float] containing the divisor. The lower 32 bits
172309124Sdim///    of this operand are used in the calculation.
173309124Sdim/// \returns A 128-bit vector of [4 x float] containing the quotients of the
174309124Sdim///    lower 32 bits of both operands. The upper 96 bits are copied from the
175309124Sdim///    upper 96 bits of the first source operand.
176288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
177249423Sdim_mm_div_ss(__m128 __a, __m128 __b)
178193326Sed{
179249423Sdim  __a[0] /= __b[0];
180249423Sdim  return __a;
181193326Sed}
182193326Sed
183341825Sdim/// Divides two 128-bit vectors of [4 x float].
184309124Sdim///
185309124Sdim/// \headerfile <x86intrin.h>
186309124Sdim///
187314564Sdim/// This intrinsic corresponds to the <c> VDIVPS / DIVPS </c> instructions.
188309124Sdim///
189309124Sdim/// \param __a
190309124Sdim///    A 128-bit vector of [4 x float] containing the dividend.
191309124Sdim/// \param __b
192309124Sdim///    A 128-bit vector of [4 x float] containing the divisor.
193309124Sdim/// \returns A 128-bit vector of [4 x float] containing the quotients of both
194309124Sdim///    operands.
195288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
196249423Sdim_mm_div_ps(__m128 __a, __m128 __b)
197193326Sed{
198309124Sdim  return (__m128)((__v4sf)__a / (__v4sf)__b);
199193326Sed}
200193326Sed
201341825Sdim/// Calculates the square root of the value stored in the low-order bits
202309124Sdim///    of a 128-bit vector of [4 x float].
203309124Sdim///
204309124Sdim/// \headerfile <x86intrin.h>
205309124Sdim///
206314564Sdim/// This intrinsic corresponds to the <c> VSQRTSS / SQRTSS </c> instructions.
207309124Sdim///
208309124Sdim/// \param __a
209309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
210309124Sdim///    used in the calculation.
211309124Sdim/// \returns A 128-bit vector of [4 x float] containing the square root of the
212309124Sdim///    value in the low-order bits of the operand.
213288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
214249423Sdim_mm_sqrt_ss(__m128 __a)
215193326Sed{
216341825Sdim  return (__m128)__builtin_ia32_sqrtss((__v4sf)__a);
217193326Sed}
218193326Sed
219341825Sdim/// Calculates the square roots of the values stored in a 128-bit vector
220309124Sdim///    of [4 x float].
221309124Sdim///
222309124Sdim/// \headerfile <x86intrin.h>
223309124Sdim///
224314564Sdim/// This intrinsic corresponds to the <c> VSQRTPS / SQRTPS </c> instructions.
225309124Sdim///
226309124Sdim/// \param __a
227309124Sdim///    A 128-bit vector of [4 x float].
228309124Sdim/// \returns A 128-bit vector of [4 x float] containing the square roots of the
229309124Sdim///    values in the operand.
230288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
231249423Sdim_mm_sqrt_ps(__m128 __a)
232193326Sed{
233309124Sdim  return __builtin_ia32_sqrtps((__v4sf)__a);
234193326Sed}
235193326Sed
236341825Sdim/// Calculates the approximate reciprocal of the value stored in the
237309124Sdim///    low-order bits of a 128-bit vector of [4 x float].
238309124Sdim///
239309124Sdim/// \headerfile <x86intrin.h>
240309124Sdim///
241314564Sdim/// This intrinsic corresponds to the <c> VRCPSS / RCPSS </c> instructions.
242309124Sdim///
243309124Sdim/// \param __a
244309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
245309124Sdim///    used in the calculation.
246309124Sdim/// \returns A 128-bit vector of [4 x float] containing the approximate
247309124Sdim///    reciprocal of the value in the low-order bits of the operand.
248288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
249249423Sdim_mm_rcp_ss(__m128 __a)
250193326Sed{
251341825Sdim  return (__m128)__builtin_ia32_rcpss((__v4sf)__a);
252193326Sed}
253193326Sed
254341825Sdim/// Calculates the approximate reciprocals of the values stored in a
255309124Sdim///    128-bit vector of [4 x float].
256309124Sdim///
257309124Sdim/// \headerfile <x86intrin.h>
258309124Sdim///
259314564Sdim/// This intrinsic corresponds to the <c> VRCPPS / RCPPS </c> instructions.
260309124Sdim///
261309124Sdim/// \param __a
262309124Sdim///    A 128-bit vector of [4 x float].
263309124Sdim/// \returns A 128-bit vector of [4 x float] containing the approximate
264309124Sdim///    reciprocals of the values in the operand.
265288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
266249423Sdim_mm_rcp_ps(__m128 __a)
267193326Sed{
268341825Sdim  return (__m128)__builtin_ia32_rcpps((__v4sf)__a);
269193326Sed}
270193326Sed
271341825Sdim/// Calculates the approximate reciprocal of the square root of the value
272309124Sdim///    stored in the low-order bits of a 128-bit vector of [4 x float].
273309124Sdim///
274309124Sdim/// \headerfile <x86intrin.h>
275309124Sdim///
276314564Sdim/// This intrinsic corresponds to the <c> VRSQRTSS / RSQRTSS </c> instructions.
277309124Sdim///
278309124Sdim/// \param __a
279309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
280309124Sdim///    used in the calculation.
281309124Sdim/// \returns A 128-bit vector of [4 x float] containing the approximate
282309124Sdim///    reciprocal of the square root of the value in the low-order bits of the
283309124Sdim///    operand.
284288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
285249423Sdim_mm_rsqrt_ss(__m128 __a)
286193326Sed{
287341825Sdim  return __builtin_ia32_rsqrtss((__v4sf)__a);
288193326Sed}
289193326Sed
290341825Sdim/// Calculates the approximate reciprocals of the square roots of the
291309124Sdim///    values stored in a 128-bit vector of [4 x float].
292309124Sdim///
293309124Sdim/// \headerfile <x86intrin.h>
294309124Sdim///
295314564Sdim/// This intrinsic corresponds to the <c> VRSQRTPS / RSQRTPS </c> instructions.
296309124Sdim///
297309124Sdim/// \param __a
298309124Sdim///    A 128-bit vector of [4 x float].
299309124Sdim/// \returns A 128-bit vector of [4 x float] containing the approximate
300309124Sdim///    reciprocals of the square roots of the values in the operand.
301288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
302249423Sdim_mm_rsqrt_ps(__m128 __a)
303193326Sed{
304309124Sdim  return __builtin_ia32_rsqrtps((__v4sf)__a);
305193326Sed}
306193326Sed
307341825Sdim/// Compares two 32-bit float values in the low-order bits of both
308309124Sdim///    operands and returns the lesser value in the low-order bits of the
309309124Sdim///    vector of [4 x float].
310309124Sdim///
311309124Sdim/// \headerfile <x86intrin.h>
312309124Sdim///
313314564Sdim/// This intrinsic corresponds to the <c> VMINSS / MINSS </c> instructions.
314309124Sdim///
315309124Sdim/// \param __a
316309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
317309124Sdim///    32 bits of this operand are used in the comparison.
318309124Sdim/// \param __b
319309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
320309124Sdim///    32 bits of this operand are used in the comparison.
321309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
322309124Sdim///    minimum value between both operands. The upper 96 bits are copied from
323309124Sdim///    the upper 96 bits of the first source operand.
324288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
325249423Sdim_mm_min_ss(__m128 __a, __m128 __b)
326193326Sed{
327309124Sdim  return __builtin_ia32_minss((__v4sf)__a, (__v4sf)__b);
328193326Sed}
329193326Sed
330341825Sdim/// Compares two 128-bit vectors of [4 x float] and returns the lesser
331314564Sdim///    of each pair of values.
332309124Sdim///
333309124Sdim/// \headerfile <x86intrin.h>
334309124Sdim///
335314564Sdim/// This intrinsic corresponds to the <c> VMINPS / MINPS </c> instructions.
336309124Sdim///
337309124Sdim/// \param __a
338309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands.
339309124Sdim/// \param __b
340309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands.
341309124Sdim/// \returns A 128-bit vector of [4 x float] containing the minimum values
342309124Sdim///    between both operands.
343288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
344249423Sdim_mm_min_ps(__m128 __a, __m128 __b)
345193326Sed{
346309124Sdim  return __builtin_ia32_minps((__v4sf)__a, (__v4sf)__b);
347193326Sed}
348193326Sed
349341825Sdim/// Compares two 32-bit float values in the low-order bits of both
350314564Sdim///    operands and returns the greater value in the low-order bits of a 128-bit
351314564Sdim///    vector of [4 x float].
352309124Sdim///
353309124Sdim/// \headerfile <x86intrin.h>
354309124Sdim///
355314564Sdim/// This intrinsic corresponds to the <c> VMAXSS / MAXSS </c> instructions.
356309124Sdim///
357309124Sdim/// \param __a
358309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
359309124Sdim///    32 bits of this operand are used in the comparison.
360309124Sdim/// \param __b
361309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
362309124Sdim///    32 bits of this operand are used in the comparison.
363309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
364309124Sdim///    maximum value between both operands. The upper 96 bits are copied from
365309124Sdim///    the upper 96 bits of the first source operand.
366288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
367249423Sdim_mm_max_ss(__m128 __a, __m128 __b)
368193326Sed{
369309124Sdim  return __builtin_ia32_maxss((__v4sf)__a, (__v4sf)__b);
370193326Sed}
371193326Sed
372341825Sdim/// Compares two 128-bit vectors of [4 x float] and returns the greater
373309124Sdim///    of each pair of values.
374309124Sdim///
375309124Sdim/// \headerfile <x86intrin.h>
376309124Sdim///
377314564Sdim/// This intrinsic corresponds to the <c> VMAXPS / MAXPS </c> instructions.
378309124Sdim///
379309124Sdim/// \param __a
380309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands.
381309124Sdim/// \param __b
382309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands.
383309124Sdim/// \returns A 128-bit vector of [4 x float] containing the maximum values
384309124Sdim///    between both operands.
385288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
386249423Sdim_mm_max_ps(__m128 __a, __m128 __b)
387193326Sed{
388309124Sdim  return __builtin_ia32_maxps((__v4sf)__a, (__v4sf)__b);
389193326Sed}
390193326Sed
391341825Sdim/// Performs a bitwise AND of two 128-bit vectors of [4 x float].
392309124Sdim///
393309124Sdim/// \headerfile <x86intrin.h>
394309124Sdim///
395314564Sdim/// This intrinsic corresponds to the <c> VANDPS / ANDPS </c> instructions.
396309124Sdim///
397309124Sdim/// \param __a
398309124Sdim///    A 128-bit vector containing one of the source operands.
399309124Sdim/// \param __b
400309124Sdim///    A 128-bit vector containing one of the source operands.
401309124Sdim/// \returns A 128-bit vector of [4 x float] containing the bitwise AND of the
402309124Sdim///    values between both operands.
403288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
404249423Sdim_mm_and_ps(__m128 __a, __m128 __b)
405193326Sed{
406309124Sdim  return (__m128)((__v4su)__a & (__v4su)__b);
407193326Sed}
408193326Sed
409341825Sdim/// Performs a bitwise AND of two 128-bit vectors of [4 x float], using
410309124Sdim///    the one's complement of the values contained in the first source
411309124Sdim///    operand.
412309124Sdim///
413309124Sdim/// \headerfile <x86intrin.h>
414309124Sdim///
415314564Sdim/// This intrinsic corresponds to the <c> VANDNPS / ANDNPS </c> instructions.
416309124Sdim///
417309124Sdim/// \param __a
418309124Sdim///    A 128-bit vector of [4 x float] containing the first source operand. The
419309124Sdim///    one's complement of this value is used in the bitwise AND.
420309124Sdim/// \param __b
421309124Sdim///    A 128-bit vector of [4 x float] containing the second source operand.
422309124Sdim/// \returns A 128-bit vector of [4 x float] containing the bitwise AND of the
423309124Sdim///    one's complement of the first operand and the values in the second
424309124Sdim///    operand.
425288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
426249423Sdim_mm_andnot_ps(__m128 __a, __m128 __b)
427193326Sed{
428309124Sdim  return (__m128)(~(__v4su)__a & (__v4su)__b);
429193326Sed}
430193326Sed
431341825Sdim/// Performs a bitwise OR of two 128-bit vectors of [4 x float].
432309124Sdim///
433309124Sdim/// \headerfile <x86intrin.h>
434309124Sdim///
435314564Sdim/// This intrinsic corresponds to the <c> VORPS / ORPS </c> instructions.
436309124Sdim///
437309124Sdim/// \param __a
438309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
439309124Sdim/// \param __b
440309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
441309124Sdim/// \returns A 128-bit vector of [4 x float] containing the bitwise OR of the
442309124Sdim///    values between both operands.
443288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
444249423Sdim_mm_or_ps(__m128 __a, __m128 __b)
445193326Sed{
446309124Sdim  return (__m128)((__v4su)__a | (__v4su)__b);
447193326Sed}
448193326Sed
449341825Sdim/// Performs a bitwise exclusive OR of two 128-bit vectors of
450309124Sdim///    [4 x float].
451309124Sdim///
452309124Sdim/// \headerfile <x86intrin.h>
453309124Sdim///
454314564Sdim/// This intrinsic corresponds to the <c> VXORPS / XORPS </c> instructions.
455309124Sdim///
456309124Sdim/// \param __a
457309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
458309124Sdim/// \param __b
459309124Sdim///    A 128-bit vector of [4 x float] containing one of the source operands.
460309124Sdim/// \returns A 128-bit vector of [4 x float] containing the bitwise exclusive OR
461309124Sdim///    of the values between both operands.
462288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
463249423Sdim_mm_xor_ps(__m128 __a, __m128 __b)
464193326Sed{
465309124Sdim  return (__m128)((__v4su)__a ^ (__v4su)__b);
466193326Sed}
467193326Sed
468341825Sdim/// Compares two 32-bit float values in the low-order bits of both
469309124Sdim///    operands for equality and returns the result of the comparison in the
470309124Sdim///    low-order bits of a vector [4 x float].
471309124Sdim///
472309124Sdim/// \headerfile <x86intrin.h>
473309124Sdim///
474314564Sdim/// This intrinsic corresponds to the <c> VCMPEQSS / CMPEQSS </c> instructions.
475309124Sdim///
476309124Sdim/// \param __a
477309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
478309124Sdim///    32 bits of this operand are used in the comparison.
479309124Sdim/// \param __b
480309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
481309124Sdim///    32 bits of this operand are used in the comparison.
482309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
483309124Sdim///    in the low-order bits.
484288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
485249423Sdim_mm_cmpeq_ss(__m128 __a, __m128 __b)
486193326Sed{
487309124Sdim  return (__m128)__builtin_ia32_cmpeqss((__v4sf)__a, (__v4sf)__b);
488193326Sed}
489193326Sed
490341825Sdim/// Compares each of the corresponding 32-bit float values of the
491309124Sdim///    128-bit vectors of [4 x float] for equality.
492309124Sdim///
493309124Sdim/// \headerfile <x86intrin.h>
494309124Sdim///
495314564Sdim/// This intrinsic corresponds to the <c> VCMPEQPS / CMPEQPS </c> instructions.
496309124Sdim///
497309124Sdim/// \param __a
498309124Sdim///    A 128-bit vector of [4 x float].
499309124Sdim/// \param __b
500309124Sdim///    A 128-bit vector of [4 x float].
501309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
502288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
503249423Sdim_mm_cmpeq_ps(__m128 __a, __m128 __b)
504193326Sed{
505309124Sdim  return (__m128)__builtin_ia32_cmpeqps((__v4sf)__a, (__v4sf)__b);
506193326Sed}
507193326Sed
508341825Sdim/// Compares two 32-bit float values in the low-order bits of both
509309124Sdim///    operands to determine if the value in the first operand is less than the
510309124Sdim///    corresponding value in the second operand and returns the result of the
511309124Sdim///    comparison in the low-order bits of a vector of [4 x float].
512309124Sdim///
513309124Sdim/// \headerfile <x86intrin.h>
514309124Sdim///
515314564Sdim/// This intrinsic corresponds to the <c> VCMPLTSS / CMPLTSS </c> instructions.
516309124Sdim///
517309124Sdim/// \param __a
518309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
519309124Sdim///    32 bits of this operand are used in the comparison.
520309124Sdim/// \param __b
521309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
522309124Sdim///    32 bits of this operand are used in the comparison.
523309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
524309124Sdim///    in the low-order bits.
525288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
526249423Sdim_mm_cmplt_ss(__m128 __a, __m128 __b)
527193326Sed{
528309124Sdim  return (__m128)__builtin_ia32_cmpltss((__v4sf)__a, (__v4sf)__b);
529193326Sed}
530193326Sed
531341825Sdim/// Compares each of the corresponding 32-bit float values of the
532309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
533309124Sdim///    operand are less than those in the second operand.
534309124Sdim///
535309124Sdim/// \headerfile <x86intrin.h>
536309124Sdim///
537314564Sdim/// This intrinsic corresponds to the <c> VCMPLTPS / CMPLTPS </c> instructions.
538309124Sdim///
539309124Sdim/// \param __a
540309124Sdim///    A 128-bit vector of [4 x float].
541309124Sdim/// \param __b
542309124Sdim///    A 128-bit vector of [4 x float].
543309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
544288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
545249423Sdim_mm_cmplt_ps(__m128 __a, __m128 __b)
546193326Sed{
547309124Sdim  return (__m128)__builtin_ia32_cmpltps((__v4sf)__a, (__v4sf)__b);
548193326Sed}
549193326Sed
550341825Sdim/// Compares two 32-bit float values in the low-order bits of both
551309124Sdim///    operands to determine if the value in the first operand is less than or
552309124Sdim///    equal to the corresponding value in the second operand and returns the
553309124Sdim///    result of the comparison in the low-order bits of a vector of
554309124Sdim///    [4 x float].
555309124Sdim///
556309124Sdim/// \headerfile <x86intrin.h>
557309124Sdim///
558314564Sdim/// This intrinsic corresponds to the <c> VCMPLESS / CMPLESS </c> instructions.
559309124Sdim///
560309124Sdim/// \param __a
561309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
562309124Sdim///    32 bits of this operand are used in the comparison.
563309124Sdim/// \param __b
564309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
565309124Sdim///    32 bits of this operand are used in the comparison.
566309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
567309124Sdim///    in the low-order bits.
568288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
569249423Sdim_mm_cmple_ss(__m128 __a, __m128 __b)
570193326Sed{
571309124Sdim  return (__m128)__builtin_ia32_cmpless((__v4sf)__a, (__v4sf)__b);
572193326Sed}
573193326Sed
574341825Sdim/// Compares each of the corresponding 32-bit float values of the
575309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
576309124Sdim///    operand are less than or equal to those in the second operand.
577309124Sdim///
578309124Sdim/// \headerfile <x86intrin.h>
579309124Sdim///
580314564Sdim/// This intrinsic corresponds to the <c> VCMPLEPS / CMPLEPS </c> instructions.
581309124Sdim///
582309124Sdim/// \param __a
583309124Sdim///    A 128-bit vector of [4 x float].
584309124Sdim/// \param __b
585309124Sdim///    A 128-bit vector of [4 x float].
586309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
587288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
588249423Sdim_mm_cmple_ps(__m128 __a, __m128 __b)
589193326Sed{
590309124Sdim  return (__m128)__builtin_ia32_cmpleps((__v4sf)__a, (__v4sf)__b);
591193326Sed}
592193326Sed
593341825Sdim/// Compares two 32-bit float values in the low-order bits of both
594309124Sdim///    operands to determine if the value in the first operand is greater than
595309124Sdim///    the corresponding value in the second operand and returns the result of
596309124Sdim///    the comparison in the low-order bits of a vector of [4 x float].
597309124Sdim///
598309124Sdim/// \headerfile <x86intrin.h>
599309124Sdim///
600314564Sdim/// This intrinsic corresponds to the <c> VCMPLTSS / CMPLTSS </c> instructions.
601309124Sdim///
602309124Sdim/// \param __a
603309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
604309124Sdim///    32 bits of this operand are used in the comparison.
605309124Sdim/// \param __b
606309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
607309124Sdim///    32 bits of this operand are used in the comparison.
608309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
609309124Sdim///    in the low-order bits.
610288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
611249423Sdim_mm_cmpgt_ss(__m128 __a, __m128 __b)
612193326Sed{
613309124Sdim  return (__m128)__builtin_shufflevector((__v4sf)__a,
614309124Sdim                                         (__v4sf)__builtin_ia32_cmpltss((__v4sf)__b, (__v4sf)__a),
615261991Sdim                                         4, 1, 2, 3);
616193326Sed}
617193326Sed
618341825Sdim/// Compares each of the corresponding 32-bit float values of the
619309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
620309124Sdim///    operand are greater than those in the second operand.
621309124Sdim///
622309124Sdim/// \headerfile <x86intrin.h>
623309124Sdim///
624314564Sdim/// This intrinsic corresponds to the <c> VCMPLTPS / CMPLTPS </c> instructions.
625309124Sdim///
626309124Sdim/// \param __a
627309124Sdim///    A 128-bit vector of [4 x float].
628309124Sdim/// \param __b
629309124Sdim///    A 128-bit vector of [4 x float].
630309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
631288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
632249423Sdim_mm_cmpgt_ps(__m128 __a, __m128 __b)
633193326Sed{
634309124Sdim  return (__m128)__builtin_ia32_cmpltps((__v4sf)__b, (__v4sf)__a);
635193326Sed}
636193326Sed
637341825Sdim/// Compares two 32-bit float values in the low-order bits of both
638309124Sdim///    operands to determine if the value in the first operand is greater than
639309124Sdim///    or equal to the corresponding value in the second operand and returns
640309124Sdim///    the result of the comparison in the low-order bits of a vector of
641309124Sdim///    [4 x float].
642309124Sdim///
643309124Sdim/// \headerfile <x86intrin.h>
644309124Sdim///
645314564Sdim/// This intrinsic corresponds to the <c> VCMPLESS / CMPLESS </c> instructions.
646309124Sdim///
647309124Sdim/// \param __a
648309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
649309124Sdim///    32 bits of this operand are used in the comparison.
650309124Sdim/// \param __b
651309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
652309124Sdim///    32 bits of this operand are used in the comparison.
653309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
654309124Sdim///    in the low-order bits.
655288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
656249423Sdim_mm_cmpge_ss(__m128 __a, __m128 __b)
657193326Sed{
658309124Sdim  return (__m128)__builtin_shufflevector((__v4sf)__a,
659309124Sdim                                         (__v4sf)__builtin_ia32_cmpless((__v4sf)__b, (__v4sf)__a),
660261991Sdim                                         4, 1, 2, 3);
661193326Sed}
662193326Sed
663341825Sdim/// Compares each of the corresponding 32-bit float values of the
664309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
665309124Sdim///    operand are greater than or equal to those in the second operand.
666309124Sdim///
667309124Sdim/// \headerfile <x86intrin.h>
668309124Sdim///
669314564Sdim/// This intrinsic corresponds to the <c> VCMPLEPS / CMPLEPS </c> instructions.
670309124Sdim///
671309124Sdim/// \param __a
672309124Sdim///    A 128-bit vector of [4 x float].
673309124Sdim/// \param __b
674309124Sdim///    A 128-bit vector of [4 x float].
675309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
676288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
677249423Sdim_mm_cmpge_ps(__m128 __a, __m128 __b)
678193326Sed{
679309124Sdim  return (__m128)__builtin_ia32_cmpleps((__v4sf)__b, (__v4sf)__a);
680193326Sed}
681193326Sed
682341825Sdim/// Compares two 32-bit float values in the low-order bits of both
683309124Sdim///    operands for inequality and returns the result of the comparison in the
684309124Sdim///    low-order bits of a vector of [4 x float].
685309124Sdim///
686309124Sdim/// \headerfile <x86intrin.h>
687309124Sdim///
688314564Sdim/// This intrinsic corresponds to the <c> VCMPNEQSS / CMPNEQSS </c>
689314564Sdim///   instructions.
690309124Sdim///
691309124Sdim/// \param __a
692309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
693309124Sdim///    32 bits of this operand are used in the comparison.
694309124Sdim/// \param __b
695309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
696309124Sdim///    32 bits of this operand are used in the comparison.
697309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
698309124Sdim///    in the low-order bits.
699288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
700249423Sdim_mm_cmpneq_ss(__m128 __a, __m128 __b)
701193326Sed{
702309124Sdim  return (__m128)__builtin_ia32_cmpneqss((__v4sf)__a, (__v4sf)__b);
703193326Sed}
704193326Sed
705341825Sdim/// Compares each of the corresponding 32-bit float values of the
706309124Sdim///    128-bit vectors of [4 x float] for inequality.
707309124Sdim///
708309124Sdim/// \headerfile <x86intrin.h>
709309124Sdim///
710314564Sdim/// This intrinsic corresponds to the <c> VCMPNEQPS / CMPNEQPS </c>
711314564Sdim///   instructions.
712309124Sdim///
713309124Sdim/// \param __a
714309124Sdim///    A 128-bit vector of [4 x float].
715309124Sdim/// \param __b
716309124Sdim///    A 128-bit vector of [4 x float].
717309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
718288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
719249423Sdim_mm_cmpneq_ps(__m128 __a, __m128 __b)
720193326Sed{
721309124Sdim  return (__m128)__builtin_ia32_cmpneqps((__v4sf)__a, (__v4sf)__b);
722193326Sed}
723193326Sed
724341825Sdim/// Compares two 32-bit float values in the low-order bits of both
725309124Sdim///    operands to determine if the value in the first operand is not less than
726309124Sdim///    the corresponding value in the second operand and returns the result of
727309124Sdim///    the comparison in the low-order bits of a vector of [4 x float].
728309124Sdim///
729309124Sdim/// \headerfile <x86intrin.h>
730309124Sdim///
731314564Sdim/// This intrinsic corresponds to the <c> VCMPNLTSS / CMPNLTSS </c>
732314564Sdim///   instructions.
733309124Sdim///
734309124Sdim/// \param __a
735309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
736309124Sdim///    32 bits of this operand are used in the comparison.
737309124Sdim/// \param __b
738309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
739309124Sdim///    32 bits of this operand are used in the comparison.
740309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
741309124Sdim///    in the low-order bits.
742288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
743249423Sdim_mm_cmpnlt_ss(__m128 __a, __m128 __b)
744193326Sed{
745309124Sdim  return (__m128)__builtin_ia32_cmpnltss((__v4sf)__a, (__v4sf)__b);
746193326Sed}
747193326Sed
748341825Sdim/// Compares each of the corresponding 32-bit float values of the
749309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
750309124Sdim///    operand are not less than those in the second operand.
751309124Sdim///
752309124Sdim/// \headerfile <x86intrin.h>
753309124Sdim///
754314564Sdim/// This intrinsic corresponds to the <c> VCMPNLTPS / CMPNLTPS </c>
755314564Sdim///   instructions.
756309124Sdim///
757309124Sdim/// \param __a
758309124Sdim///    A 128-bit vector of [4 x float].
759309124Sdim/// \param __b
760309124Sdim///    A 128-bit vector of [4 x float].
761309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
762288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
763249423Sdim_mm_cmpnlt_ps(__m128 __a, __m128 __b)
764193326Sed{
765309124Sdim  return (__m128)__builtin_ia32_cmpnltps((__v4sf)__a, (__v4sf)__b);
766193326Sed}
767193326Sed
768341825Sdim/// Compares two 32-bit float values in the low-order bits of both
769309124Sdim///    operands to determine if the value in the first operand is not less than
770309124Sdim///    or equal to the corresponding value in the second operand and returns
771309124Sdim///    the result of the comparison in the low-order bits of a vector of
772309124Sdim///    [4 x float].
773309124Sdim///
774309124Sdim/// \headerfile <x86intrin.h>
775309124Sdim///
776314564Sdim/// This intrinsic corresponds to the <c> VCMPNLESS / CMPNLESS </c>
777314564Sdim///   instructions.
778309124Sdim///
779309124Sdim/// \param __a
780309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
781309124Sdim///    32 bits of this operand are used in the comparison.
782309124Sdim/// \param __b
783309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
784309124Sdim///    32 bits of this operand are used in the comparison.
785309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
786309124Sdim///    in the low-order bits.
787288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
788249423Sdim_mm_cmpnle_ss(__m128 __a, __m128 __b)
789193326Sed{
790309124Sdim  return (__m128)__builtin_ia32_cmpnless((__v4sf)__a, (__v4sf)__b);
791193326Sed}
792193326Sed
793341825Sdim/// Compares each of the corresponding 32-bit float values of the
794309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
795309124Sdim///    operand are not less than or equal to those in the second operand.
796309124Sdim///
797309124Sdim/// \headerfile <x86intrin.h>
798309124Sdim///
799314564Sdim/// This intrinsic corresponds to the <c> VCMPNLEPS / CMPNLEPS </c>
800314564Sdim///   instructions.
801309124Sdim///
802309124Sdim/// \param __a
803309124Sdim///    A 128-bit vector of [4 x float].
804309124Sdim/// \param __b
805309124Sdim///    A 128-bit vector of [4 x float].
806309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
807288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
808249423Sdim_mm_cmpnle_ps(__m128 __a, __m128 __b)
809193326Sed{
810309124Sdim  return (__m128)__builtin_ia32_cmpnleps((__v4sf)__a, (__v4sf)__b);
811193326Sed}
812193326Sed
813341825Sdim/// Compares two 32-bit float values in the low-order bits of both
814309124Sdim///    operands to determine if the value in the first operand is not greater
815309124Sdim///    than the corresponding value in the second operand and returns the
816309124Sdim///    result of the comparison in the low-order bits of a vector of
817309124Sdim///    [4 x float].
818309124Sdim///
819309124Sdim/// \headerfile <x86intrin.h>
820309124Sdim///
821314564Sdim/// This intrinsic corresponds to the <c> VCMPNLTSS / CMPNLTSS </c>
822314564Sdim///   instructions.
823309124Sdim///
824309124Sdim/// \param __a
825309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
826309124Sdim///    32 bits of this operand are used in the comparison.
827309124Sdim/// \param __b
828309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
829309124Sdim///    32 bits of this operand are used in the comparison.
830309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
831309124Sdim///    in the low-order bits.
832288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
833249423Sdim_mm_cmpngt_ss(__m128 __a, __m128 __b)
834193326Sed{
835309124Sdim  return (__m128)__builtin_shufflevector((__v4sf)__a,
836309124Sdim                                         (__v4sf)__builtin_ia32_cmpnltss((__v4sf)__b, (__v4sf)__a),
837261991Sdim                                         4, 1, 2, 3);
838193326Sed}
839193326Sed
840341825Sdim/// Compares each of the corresponding 32-bit float values of the
841309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
842309124Sdim///    operand are not greater than those in the second operand.
843309124Sdim///
844309124Sdim/// \headerfile <x86intrin.h>
845309124Sdim///
846314564Sdim/// This intrinsic corresponds to the <c> VCMPNLTPS / CMPNLTPS </c>
847314564Sdim///   instructions.
848309124Sdim///
849309124Sdim/// \param __a
850309124Sdim///    A 128-bit vector of [4 x float].
851309124Sdim/// \param __b
852309124Sdim///    A 128-bit vector of [4 x float].
853309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
854288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
855249423Sdim_mm_cmpngt_ps(__m128 __a, __m128 __b)
856193326Sed{
857309124Sdim  return (__m128)__builtin_ia32_cmpnltps((__v4sf)__b, (__v4sf)__a);
858193326Sed}
859193326Sed
860341825Sdim/// Compares two 32-bit float values in the low-order bits of both
861309124Sdim///    operands to determine if the value in the first operand is not greater
862309124Sdim///    than or equal to the corresponding value in the second operand and
863309124Sdim///    returns the result of the comparison in the low-order bits of a vector
864309124Sdim///    of [4 x float].
865309124Sdim///
866309124Sdim/// \headerfile <x86intrin.h>
867309124Sdim///
868314564Sdim/// This intrinsic corresponds to the <c> VCMPNLESS / CMPNLESS </c>
869314564Sdim///   instructions.
870309124Sdim///
871309124Sdim/// \param __a
872309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
873309124Sdim///    32 bits of this operand are used in the comparison.
874309124Sdim/// \param __b
875309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
876309124Sdim///    32 bits of this operand are used in the comparison.
877309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
878309124Sdim///    in the low-order bits.
879288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
880249423Sdim_mm_cmpnge_ss(__m128 __a, __m128 __b)
881193326Sed{
882309124Sdim  return (__m128)__builtin_shufflevector((__v4sf)__a,
883309124Sdim                                         (__v4sf)__builtin_ia32_cmpnless((__v4sf)__b, (__v4sf)__a),
884261991Sdim                                         4, 1, 2, 3);
885193326Sed}
886193326Sed
887341825Sdim/// Compares each of the corresponding 32-bit float values of the
888309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
889309124Sdim///    operand are not greater than or equal to those in the second operand.
890309124Sdim///
891309124Sdim/// \headerfile <x86intrin.h>
892309124Sdim///
893314564Sdim/// This intrinsic corresponds to the <c> VCMPNLEPS / CMPNLEPS </c>
894314564Sdim///   instructions.
895309124Sdim///
896309124Sdim/// \param __a
897309124Sdim///    A 128-bit vector of [4 x float].
898309124Sdim/// \param __b
899309124Sdim///    A 128-bit vector of [4 x float].
900309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
901288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
902249423Sdim_mm_cmpnge_ps(__m128 __a, __m128 __b)
903193326Sed{
904309124Sdim  return (__m128)__builtin_ia32_cmpnleps((__v4sf)__b, (__v4sf)__a);
905193326Sed}
906193326Sed
907341825Sdim/// Compares two 32-bit float values in the low-order bits of both
908309124Sdim///    operands to determine if the value in the first operand is ordered with
909309124Sdim///    respect to the corresponding value in the second operand and returns the
910309124Sdim///    result of the comparison in the low-order bits of a vector of
911309124Sdim///    [4 x float].
912309124Sdim///
913309124Sdim/// \headerfile <x86intrin.h>
914309124Sdim///
915314564Sdim/// This intrinsic corresponds to the <c> VCMPORDSS / CMPORDSS </c>
916314564Sdim///   instructions.
917309124Sdim///
918309124Sdim/// \param __a
919309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
920309124Sdim///    32 bits of this operand are used in the comparison.
921309124Sdim/// \param __b
922309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
923309124Sdim///    32 bits of this operand are used in the comparison.
924309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
925309124Sdim///    in the low-order bits.
926288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
927249423Sdim_mm_cmpord_ss(__m128 __a, __m128 __b)
928193326Sed{
929309124Sdim  return (__m128)__builtin_ia32_cmpordss((__v4sf)__a, (__v4sf)__b);
930193326Sed}
931193326Sed
932341825Sdim/// Compares each of the corresponding 32-bit float values of the
933309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
934309124Sdim///    operand are ordered with respect to those in the second operand.
935309124Sdim///
936309124Sdim/// \headerfile <x86intrin.h>
937309124Sdim///
938314564Sdim/// This intrinsic corresponds to the <c> VCMPORDPS / CMPORDPS </c>
939314564Sdim///   instructions.
940309124Sdim///
941309124Sdim/// \param __a
942309124Sdim///    A 128-bit vector of [4 x float].
943309124Sdim/// \param __b
944309124Sdim///    A 128-bit vector of [4 x float].
945309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
946288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
947249423Sdim_mm_cmpord_ps(__m128 __a, __m128 __b)
948193326Sed{
949309124Sdim  return (__m128)__builtin_ia32_cmpordps((__v4sf)__a, (__v4sf)__b);
950193326Sed}
951193326Sed
952341825Sdim/// Compares two 32-bit float values in the low-order bits of both
953309124Sdim///    operands to determine if the value in the first operand is unordered
954309124Sdim///    with respect to the corresponding value in the second operand and
955309124Sdim///    returns the result of the comparison in the low-order bits of a vector
956309124Sdim///    of [4 x float].
957309124Sdim///
958309124Sdim/// \headerfile <x86intrin.h>
959309124Sdim///
960314564Sdim/// This intrinsic corresponds to the <c> VCMPUNORDSS / CMPUNORDSS </c>
961314564Sdim///   instructions.
962309124Sdim///
963309124Sdim/// \param __a
964309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
965309124Sdim///    32 bits of this operand are used in the comparison.
966309124Sdim/// \param __b
967309124Sdim///    A 128-bit vector of [4 x float] containing one of the operands. The lower
968309124Sdim///    32 bits of this operand are used in the comparison.
969309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results
970309124Sdim///    in the low-order bits.
971288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
972249423Sdim_mm_cmpunord_ss(__m128 __a, __m128 __b)
973193326Sed{
974309124Sdim  return (__m128)__builtin_ia32_cmpunordss((__v4sf)__a, (__v4sf)__b);
975193326Sed}
976193326Sed
977341825Sdim/// Compares each of the corresponding 32-bit float values of the
978309124Sdim///    128-bit vectors of [4 x float] to determine if the values in the first
979309124Sdim///    operand are unordered with respect to those in the second operand.
980309124Sdim///
981309124Sdim/// \headerfile <x86intrin.h>
982309124Sdim///
983314564Sdim/// This intrinsic corresponds to the <c> VCMPUNORDPS / CMPUNORDPS </c>
984314564Sdim///   instructions.
985309124Sdim///
986309124Sdim/// \param __a
987309124Sdim///    A 128-bit vector of [4 x float].
988309124Sdim/// \param __b
989309124Sdim///    A 128-bit vector of [4 x float].
990309124Sdim/// \returns A 128-bit vector of [4 x float] containing the comparison results.
991288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
992249423Sdim_mm_cmpunord_ps(__m128 __a, __m128 __b)
993193326Sed{
994309124Sdim  return (__m128)__builtin_ia32_cmpunordps((__v4sf)__a, (__v4sf)__b);
995193326Sed}
996193326Sed
997341825Sdim/// Compares two 32-bit float values in the low-order bits of both
998309124Sdim///    operands for equality and returns the result of the comparison.
999309124Sdim///
1000341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1001341825Sdim///
1002309124Sdim/// \headerfile <x86intrin.h>
1003309124Sdim///
1004314564Sdim/// This intrinsic corresponds to the <c> VCOMISS / COMISS </c>
1005314564Sdim///   instructions.
1006309124Sdim///
1007309124Sdim/// \param __a
1008309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1009309124Sdim///    used in the comparison.
1010309124Sdim/// \param __b
1011309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1012309124Sdim///    used in the comparison.
1013341825Sdim/// \returns An integer containing the comparison results. If either of the
1014341825Sdim///    two lower 32-bit values is NaN, 0 is returned.
1015288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1016249423Sdim_mm_comieq_ss(__m128 __a, __m128 __b)
1017193326Sed{
1018309124Sdim  return __builtin_ia32_comieq((__v4sf)__a, (__v4sf)__b);
1019193326Sed}
1020193326Sed
1021341825Sdim/// Compares two 32-bit float values in the low-order bits of both
1022309124Sdim///    operands to determine if the first operand is less than the second
1023309124Sdim///    operand and returns the result of the comparison.
1024309124Sdim///
1025341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1026341825Sdim///
1027309124Sdim/// \headerfile <x86intrin.h>
1028309124Sdim///
1029314564Sdim/// This intrinsic corresponds to the <c> VCOMISS / COMISS </c>
1030314564Sdim///   instructions.
1031309124Sdim///
1032309124Sdim/// \param __a
1033309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1034309124Sdim///    used in the comparison.
1035309124Sdim/// \param __b
1036309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1037309124Sdim///    used in the comparison.
1038341825Sdim/// \returns An integer containing the comparison results. If either of the two
1039341825Sdim///     lower 32-bit values is NaN, 0 is returned.
1040288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1041249423Sdim_mm_comilt_ss(__m128 __a, __m128 __b)
1042193326Sed{
1043309124Sdim  return __builtin_ia32_comilt((__v4sf)__a, (__v4sf)__b);
1044193326Sed}
1045193326Sed
1046341825Sdim/// Compares two 32-bit float values in the low-order bits of both
1047309124Sdim///    operands to determine if the first operand is less than or equal to the
1048309124Sdim///    second operand and returns the result of the comparison.
1049309124Sdim///
1050341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1051341825Sdim///
1052309124Sdim/// \headerfile <x86intrin.h>
1053309124Sdim///
1054314564Sdim/// This intrinsic corresponds to the <c> VCOMISS / COMISS </c> instructions.
1055309124Sdim///
1056309124Sdim/// \param __a
1057309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1058309124Sdim///    used in the comparison.
1059309124Sdim/// \param __b
1060309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1061309124Sdim///    used in the comparison.
1062341825Sdim/// \returns An integer containing the comparison results. If either of the two
1063341825Sdim///     lower 32-bit values is NaN, 0 is returned.
1064288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1065249423Sdim_mm_comile_ss(__m128 __a, __m128 __b)
1066193326Sed{
1067309124Sdim  return __builtin_ia32_comile((__v4sf)__a, (__v4sf)__b);
1068193326Sed}
1069193326Sed
1070341825Sdim/// Compares two 32-bit float values in the low-order bits of both
1071309124Sdim///    operands to determine if the first operand is greater than the second
1072309124Sdim///    operand and returns the result of the comparison.
1073309124Sdim///
1074341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1075341825Sdim///
1076309124Sdim/// \headerfile <x86intrin.h>
1077309124Sdim///
1078314564Sdim/// This intrinsic corresponds to the <c> VCOMISS / COMISS </c> instructions.
1079309124Sdim///
1080309124Sdim/// \param __a
1081309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1082309124Sdim///    used in the comparison.
1083309124Sdim/// \param __b
1084309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1085309124Sdim///    used in the comparison.
1086341825Sdim/// \returns An integer containing the comparison results. If either of the
1087341825Sdim///     two lower 32-bit values is NaN, 0 is returned.
1088288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1089249423Sdim_mm_comigt_ss(__m128 __a, __m128 __b)
1090193326Sed{
1091309124Sdim  return __builtin_ia32_comigt((__v4sf)__a, (__v4sf)__b);
1092193326Sed}
1093193326Sed
1094341825Sdim/// Compares two 32-bit float values in the low-order bits of both
1095309124Sdim///    operands to determine if the first operand is greater than or equal to
1096309124Sdim///    the second operand and returns the result of the comparison.
1097309124Sdim///
1098341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1099341825Sdim///
1100309124Sdim/// \headerfile <x86intrin.h>
1101309124Sdim///
1102314564Sdim/// This intrinsic corresponds to the <c> VCOMISS / COMISS </c> instructions.
1103309124Sdim///
1104309124Sdim/// \param __a
1105309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1106309124Sdim///    used in the comparison.
1107309124Sdim/// \param __b
1108309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1109309124Sdim///    used in the comparison.
1110341825Sdim/// \returns An integer containing the comparison results. If either of the two
1111341825Sdim///    lower 32-bit values is NaN, 0 is returned.
1112288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1113249423Sdim_mm_comige_ss(__m128 __a, __m128 __b)
1114193326Sed{
1115309124Sdim  return __builtin_ia32_comige((__v4sf)__a, (__v4sf)__b);
1116193326Sed}
1117193326Sed
1118341825Sdim/// Compares two 32-bit float values in the low-order bits of both
1119309124Sdim///    operands to determine if the first operand is not equal to the second
1120309124Sdim///    operand and returns the result of the comparison.
1121309124Sdim///
1122341825Sdim///    If either of the two lower 32-bit values is NaN, 1 is returned.
1123341825Sdim///
1124309124Sdim/// \headerfile <x86intrin.h>
1125309124Sdim///
1126314564Sdim/// This intrinsic corresponds to the <c> VCOMISS / COMISS </c> instructions.
1127309124Sdim///
1128309124Sdim/// \param __a
1129309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1130309124Sdim///    used in the comparison.
1131309124Sdim/// \param __b
1132309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1133309124Sdim///    used in the comparison.
1134341825Sdim/// \returns An integer containing the comparison results. If either of the
1135341825Sdim///     two lower 32-bit values is NaN, 1 is returned.
1136288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1137249423Sdim_mm_comineq_ss(__m128 __a, __m128 __b)
1138193326Sed{
1139309124Sdim  return __builtin_ia32_comineq((__v4sf)__a, (__v4sf)__b);
1140193326Sed}
1141193326Sed
1142341825Sdim/// Performs an unordered comparison of two 32-bit float values using
1143309124Sdim///    the low-order bits of both operands to determine equality and returns
1144309124Sdim///    the result of the comparison.
1145309124Sdim///
1146341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1147341825Sdim///
1148309124Sdim/// \headerfile <x86intrin.h>
1149309124Sdim///
1150314564Sdim/// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
1151309124Sdim///
1152309124Sdim/// \param __a
1153309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1154309124Sdim///    used in the comparison.
1155309124Sdim/// \param __b
1156309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1157309124Sdim///    used in the comparison.
1158341825Sdim/// \returns An integer containing the comparison results. If either of the two
1159341825Sdim///     lower 32-bit values is NaN, 0 is returned.
1160288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1161249423Sdim_mm_ucomieq_ss(__m128 __a, __m128 __b)
1162193326Sed{
1163309124Sdim  return __builtin_ia32_ucomieq((__v4sf)__a, (__v4sf)__b);
1164193326Sed}
1165193326Sed
1166341825Sdim/// Performs an unordered comparison of two 32-bit float values using
1167309124Sdim///    the low-order bits of both operands to determine if the first operand is
1168309124Sdim///    less than the second operand and returns the result of the comparison.
1169309124Sdim///
1170341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1171341825Sdim///
1172309124Sdim/// \headerfile <x86intrin.h>
1173309124Sdim///
1174314564Sdim/// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
1175309124Sdim///
1176309124Sdim/// \param __a
1177309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1178309124Sdim///    used in the comparison.
1179309124Sdim/// \param __b
1180309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1181309124Sdim///    used in the comparison.
1182341825Sdim/// \returns An integer containing the comparison results. If either of the two
1183341825Sdim///    lower 32-bit values is NaN, 0 is returned.
1184288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1185249423Sdim_mm_ucomilt_ss(__m128 __a, __m128 __b)
1186193326Sed{
1187309124Sdim  return __builtin_ia32_ucomilt((__v4sf)__a, (__v4sf)__b);
1188193326Sed}
1189193326Sed
1190341825Sdim/// Performs an unordered comparison of two 32-bit float values using
1191314564Sdim///    the low-order bits of both operands to determine if the first operand is
1192314564Sdim///    less than or equal to the second operand and returns the result of the
1193314564Sdim///    comparison.
1194309124Sdim///
1195341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1196341825Sdim///
1197309124Sdim/// \headerfile <x86intrin.h>
1198309124Sdim///
1199314564Sdim/// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
1200309124Sdim///
1201309124Sdim/// \param __a
1202309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1203309124Sdim///    used in the comparison.
1204309124Sdim/// \param __b
1205309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1206309124Sdim///    used in the comparison.
1207341825Sdim/// \returns An integer containing the comparison results. If either of the two
1208341825Sdim///     lower 32-bit values is NaN, 0 is returned.
1209288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1210249423Sdim_mm_ucomile_ss(__m128 __a, __m128 __b)
1211193326Sed{
1212309124Sdim  return __builtin_ia32_ucomile((__v4sf)__a, (__v4sf)__b);
1213193326Sed}
1214193326Sed
1215341825Sdim/// Performs an unordered comparison of two 32-bit float values using
1216314564Sdim///    the low-order bits of both operands to determine if the first operand is
1217314564Sdim///    greater than the second operand and returns the result of the
1218309124Sdim///    comparison.
1219309124Sdim///
1220341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1221341825Sdim///
1222309124Sdim/// \headerfile <x86intrin.h>
1223309124Sdim///
1224314564Sdim/// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
1225309124Sdim///
1226309124Sdim/// \param __a
1227309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1228309124Sdim///    used in the comparison.
1229309124Sdim/// \param __b
1230309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1231309124Sdim///    used in the comparison.
1232341825Sdim/// \returns An integer containing the comparison results. If either of the two
1233341825Sdim///     lower 32-bit values is NaN, 0 is returned.
1234288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1235249423Sdim_mm_ucomigt_ss(__m128 __a, __m128 __b)
1236193326Sed{
1237309124Sdim  return __builtin_ia32_ucomigt((__v4sf)__a, (__v4sf)__b);
1238193326Sed}
1239193326Sed
1240341825Sdim/// Performs an unordered comparison of two 32-bit float values using
1241309124Sdim///    the low-order bits of both operands to determine if the first operand is
1242309124Sdim///    greater than or equal to the second operand and returns the result of
1243309124Sdim///    the comparison.
1244309124Sdim///
1245341825Sdim///    If either of the two lower 32-bit values is NaN, 0 is returned.
1246341825Sdim///
1247309124Sdim/// \headerfile <x86intrin.h>
1248309124Sdim///
1249314564Sdim/// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
1250309124Sdim///
1251309124Sdim/// \param __a
1252309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1253309124Sdim///    used in the comparison.
1254309124Sdim/// \param __b
1255309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1256309124Sdim///    used in the comparison.
1257341825Sdim/// \returns An integer containing the comparison results. If either of the two
1258341825Sdim///     lower 32-bit values is NaN, 0 is returned.
1259288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1260249423Sdim_mm_ucomige_ss(__m128 __a, __m128 __b)
1261193326Sed{
1262309124Sdim  return __builtin_ia32_ucomige((__v4sf)__a, (__v4sf)__b);
1263193326Sed}
1264193326Sed
1265341825Sdim/// Performs an unordered comparison of two 32-bit float values using
1266309124Sdim///    the low-order bits of both operands to determine inequality and returns
1267309124Sdim///    the result of the comparison.
1268309124Sdim///
1269341825Sdim///    If either of the two lower 32-bit values is NaN, 1 is returned.
1270341825Sdim///
1271309124Sdim/// \headerfile <x86intrin.h>
1272309124Sdim///
1273314564Sdim/// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
1274309124Sdim///
1275309124Sdim/// \param __a
1276309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1277309124Sdim///    used in the comparison.
1278309124Sdim/// \param __b
1279309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1280309124Sdim///    used in the comparison.
1281341825Sdim/// \returns An integer containing the comparison results. If either of the two
1282341825Sdim///    lower 32-bit values is NaN, 1 is returned.
1283288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1284249423Sdim_mm_ucomineq_ss(__m128 __a, __m128 __b)
1285193326Sed{
1286309124Sdim  return __builtin_ia32_ucomineq((__v4sf)__a, (__v4sf)__b);
1287193326Sed}
1288193326Sed
1289341825Sdim/// Converts a float value contained in the lower 32 bits of a vector of
1290309124Sdim///    [4 x float] into a 32-bit integer.
1291309124Sdim///
1292309124Sdim/// \headerfile <x86intrin.h>
1293309124Sdim///
1294314564Sdim/// This intrinsic corresponds to the <c> VCVTSS2SI / CVTSS2SI </c>
1295314564Sdim///   instructions.
1296309124Sdim///
1297309124Sdim/// \param __a
1298309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1299309124Sdim///    used in the conversion.
1300309124Sdim/// \returns A 32-bit integer containing the converted value.
1301288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1302249423Sdim_mm_cvtss_si32(__m128 __a)
1303193326Sed{
1304309124Sdim  return __builtin_ia32_cvtss2si((__v4sf)__a);
1305193326Sed}
1306193326Sed
1307341825Sdim/// Converts a float value contained in the lower 32 bits of a vector of
1308309124Sdim///    [4 x float] into a 32-bit integer.
1309309124Sdim///
1310309124Sdim/// \headerfile <x86intrin.h>
1311309124Sdim///
1312314564Sdim/// This intrinsic corresponds to the <c> VCVTSS2SI / CVTSS2SI </c>
1313314564Sdim///   instructions.
1314309124Sdim///
1315309124Sdim/// \param __a
1316309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1317309124Sdim///    used in the conversion.
1318309124Sdim/// \returns A 32-bit integer containing the converted value.
1319288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1320249423Sdim_mm_cvt_ss2si(__m128 __a)
1321204643Srdivacky{
1322249423Sdim  return _mm_cvtss_si32(__a);
1323204643Srdivacky}
1324204643Srdivacky
1325193576Sed#ifdef __x86_64__
1326193576Sed
1327341825Sdim/// Converts a float value contained in the lower 32 bits of a vector of
1328309124Sdim///    [4 x float] into a 64-bit integer.
1329309124Sdim///
1330309124Sdim/// \headerfile <x86intrin.h>
1331309124Sdim///
1332314564Sdim/// This intrinsic corresponds to the <c> VCVTSS2SI / CVTSS2SI </c>
1333314564Sdim///   instructions.
1334309124Sdim///
1335309124Sdim/// \param __a
1336309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1337309124Sdim///    used in the conversion.
1338309124Sdim/// \returns A 64-bit integer containing the converted value.
1339288943Sdimstatic __inline__ long long __DEFAULT_FN_ATTRS
1340249423Sdim_mm_cvtss_si64(__m128 __a)
1341193326Sed{
1342309124Sdim  return __builtin_ia32_cvtss2si64((__v4sf)__a);
1343193326Sed}
1344193326Sed
1345193576Sed#endif
1346193576Sed
1347341825Sdim/// Converts two low-order float values in a 128-bit vector of
1348309124Sdim///    [4 x float] into a 64-bit vector of [2 x i32].
1349309124Sdim///
1350309124Sdim/// \headerfile <x86intrin.h>
1351309124Sdim///
1352314564Sdim/// This intrinsic corresponds to the <c> CVTPS2PI </c> instruction.
1353309124Sdim///
1354309124Sdim/// \param __a
1355309124Sdim///    A 128-bit vector of [4 x float].
1356309124Sdim/// \returns A 64-bit integer vector containing the converted values.
1357341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
1358249423Sdim_mm_cvtps_pi32(__m128 __a)
1359193326Sed{
1360309124Sdim  return (__m64)__builtin_ia32_cvtps2pi((__v4sf)__a);
1361193326Sed}
1362193326Sed
1363341825Sdim/// Converts two low-order float values in a 128-bit vector of
1364309124Sdim///    [4 x float] into a 64-bit vector of [2 x i32].
1365309124Sdim///
1366309124Sdim/// \headerfile <x86intrin.h>
1367309124Sdim///
1368314564Sdim/// This intrinsic corresponds to the <c> CVTPS2PI </c> instruction.
1369309124Sdim///
1370309124Sdim/// \param __a
1371309124Sdim///    A 128-bit vector of [4 x float].
1372309124Sdim/// \returns A 64-bit integer vector containing the converted values.
1373341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
1374249423Sdim_mm_cvt_ps2pi(__m128 __a)
1375212904Sdim{
1376249423Sdim  return _mm_cvtps_pi32(__a);
1377212904Sdim}
1378212904Sdim
1379341825Sdim/// Converts a float value contained in the lower 32 bits of a vector of
1380309124Sdim///    [4 x float] into a 32-bit integer, truncating the result when it is
1381309124Sdim///    inexact.
1382309124Sdim///
1383309124Sdim/// \headerfile <x86intrin.h>
1384309124Sdim///
1385314564Sdim/// This intrinsic corresponds to the <c> VCVTTSS2SI / CVTTSS2SI </c>
1386314564Sdim///   instructions.
1387309124Sdim///
1388309124Sdim/// \param __a
1389309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1390309124Sdim///    used in the conversion.
1391309124Sdim/// \returns A 32-bit integer containing the converted value.
1392288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1393249423Sdim_mm_cvttss_si32(__m128 __a)
1394193326Sed{
1395309124Sdim  return __builtin_ia32_cvttss2si((__v4sf)__a);
1396193326Sed}
1397193326Sed
1398341825Sdim/// Converts a float value contained in the lower 32 bits of a vector of
1399309124Sdim///    [4 x float] into a 32-bit integer, truncating the result when it is
1400309124Sdim///    inexact.
1401309124Sdim///
1402309124Sdim/// \headerfile <x86intrin.h>
1403309124Sdim///
1404314564Sdim/// This intrinsic corresponds to the <c> VCVTTSS2SI / CVTTSS2SI </c>
1405314564Sdim///   instructions.
1406309124Sdim///
1407309124Sdim/// \param __a
1408309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1409309124Sdim///    used in the conversion.
1410309124Sdim/// \returns A 32-bit integer containing the converted value.
1411288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1412249423Sdim_mm_cvtt_ss2si(__m128 __a)
1413204643Srdivacky{
1414249423Sdim  return _mm_cvttss_si32(__a);
1415204643Srdivacky}
1416204643Srdivacky
1417314564Sdim#ifdef __x86_64__
1418341825Sdim/// Converts a float value contained in the lower 32 bits of a vector of
1419309124Sdim///    [4 x float] into a 64-bit integer, truncating the result when it is
1420309124Sdim///    inexact.
1421309124Sdim///
1422309124Sdim/// \headerfile <x86intrin.h>
1423309124Sdim///
1424314564Sdim/// This intrinsic corresponds to the <c> VCVTTSS2SI / CVTTSS2SI </c>
1425314564Sdim///   instructions.
1426309124Sdim///
1427309124Sdim/// \param __a
1428309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1429309124Sdim///    used in the conversion.
1430309124Sdim/// \returns A 64-bit integer containing the converted value.
1431288943Sdimstatic __inline__ long long __DEFAULT_FN_ATTRS
1432249423Sdim_mm_cvttss_si64(__m128 __a)
1433193326Sed{
1434309124Sdim  return __builtin_ia32_cvttss2si64((__v4sf)__a);
1435193326Sed}
1436314564Sdim#endif
1437193326Sed
1438341825Sdim/// Converts two low-order float values in a 128-bit vector of
1439309124Sdim///    [4 x float] into a 64-bit vector of [2 x i32], truncating the result
1440309124Sdim///    when it is inexact.
1441309124Sdim///
1442309124Sdim/// \headerfile <x86intrin.h>
1443309124Sdim///
1444314564Sdim/// This intrinsic corresponds to the <c> CVTTPS2PI / VTTPS2PI </c>
1445314564Sdim///   instructions.
1446309124Sdim///
1447309124Sdim/// \param __a
1448309124Sdim///    A 128-bit vector of [4 x float].
1449309124Sdim/// \returns A 64-bit integer vector containing the converted values.
1450341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
1451249423Sdim_mm_cvttps_pi32(__m128 __a)
1452193326Sed{
1453309124Sdim  return (__m64)__builtin_ia32_cvttps2pi((__v4sf)__a);
1454193326Sed}
1455193326Sed
1456341825Sdim/// Converts two low-order float values in a 128-bit vector of [4 x
1457309124Sdim///    float] into a 64-bit vector of [2 x i32], truncating the result when it
1458309124Sdim///    is inexact.
1459309124Sdim///
1460309124Sdim/// \headerfile <x86intrin.h>
1461309124Sdim///
1462314564Sdim/// This intrinsic corresponds to the <c> CVTTPS2PI </c> instruction.
1463309124Sdim///
1464309124Sdim/// \param __a
1465309124Sdim///    A 128-bit vector of [4 x float].
1466309124Sdim/// \returns A 64-bit integer vector containing the converted values.
1467341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
1468249423Sdim_mm_cvtt_ps2pi(__m128 __a)
1469212904Sdim{
1470249423Sdim  return _mm_cvttps_pi32(__a);
1471212904Sdim}
1472212904Sdim
1473341825Sdim/// Converts a 32-bit signed integer value into a floating point value
1474309124Sdim///    and writes it to the lower 32 bits of the destination. The remaining
1475309124Sdim///    higher order elements of the destination vector are copied from the
1476309124Sdim///    corresponding elements in the first operand.
1477309124Sdim///
1478309124Sdim/// \headerfile <x86intrin.h>
1479309124Sdim///
1480314564Sdim/// This intrinsic corresponds to the <c> VCVTSI2SS / CVTSI2SS </c> instruction.
1481309124Sdim///
1482309124Sdim/// \param __a
1483309124Sdim///    A 128-bit vector of [4 x float].
1484309124Sdim/// \param __b
1485309124Sdim///    A 32-bit signed integer operand containing the value to be converted.
1486309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
1487309124Sdim///    converted value of the second operand. The upper 96 bits are copied from
1488309124Sdim///    the upper 96 bits of the first operand.
1489288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1490249423Sdim_mm_cvtsi32_ss(__m128 __a, int __b)
1491193326Sed{
1492249423Sdim  __a[0] = __b;
1493249423Sdim  return __a;
1494193326Sed}
1495193326Sed
1496341825Sdim/// Converts a 32-bit signed integer value into a floating point value
1497309124Sdim///    and writes it to the lower 32 bits of the destination. The remaining
1498309124Sdim///    higher order elements of the destination are copied from the
1499309124Sdim///    corresponding elements in the first operand.
1500309124Sdim///
1501309124Sdim/// \headerfile <x86intrin.h>
1502309124Sdim///
1503314564Sdim/// This intrinsic corresponds to the <c> VCVTSI2SS / CVTSI2SS </c> instruction.
1504309124Sdim///
1505309124Sdim/// \param __a
1506309124Sdim///    A 128-bit vector of [4 x float].
1507309124Sdim/// \param __b
1508309124Sdim///    A 32-bit signed integer operand containing the value to be converted.
1509309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
1510309124Sdim///    converted value of the second operand. The upper 96 bits are copied from
1511309124Sdim///    the upper 96 bits of the first operand.
1512288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1513249423Sdim_mm_cvt_si2ss(__m128 __a, int __b)
1514212904Sdim{
1515249423Sdim  return _mm_cvtsi32_ss(__a, __b);
1516212904Sdim}
1517212904Sdim
1518193326Sed#ifdef __x86_64__
1519193326Sed
1520341825Sdim/// Converts a 64-bit signed integer value into a floating point value
1521309124Sdim///    and writes it to the lower 32 bits of the destination. The remaining
1522309124Sdim///    higher order elements of the destination are copied from the
1523309124Sdim///    corresponding elements in the first operand.
1524309124Sdim///
1525309124Sdim/// \headerfile <x86intrin.h>
1526309124Sdim///
1527314564Sdim/// This intrinsic corresponds to the <c> VCVTSI2SS / CVTSI2SS </c> instruction.
1528309124Sdim///
1529309124Sdim/// \param __a
1530309124Sdim///    A 128-bit vector of [4 x float].
1531309124Sdim/// \param __b
1532309124Sdim///    A 64-bit signed integer operand containing the value to be converted.
1533309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
1534309124Sdim///    converted value of the second operand. The upper 96 bits are copied from
1535309124Sdim///    the upper 96 bits of the first operand.
1536288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1537249423Sdim_mm_cvtsi64_ss(__m128 __a, long long __b)
1538193326Sed{
1539249423Sdim  __a[0] = __b;
1540249423Sdim  return __a;
1541193326Sed}
1542193326Sed
1543193326Sed#endif
1544193326Sed
1545341825Sdim/// Converts two elements of a 64-bit vector of [2 x i32] into two
1546309124Sdim///    floating point values and writes them to the lower 64-bits of the
1547309124Sdim///    destination. The remaining higher order elements of the destination are
1548309124Sdim///    copied from the corresponding elements in the first operand.
1549309124Sdim///
1550309124Sdim/// \headerfile <x86intrin.h>
1551309124Sdim///
1552314564Sdim/// This intrinsic corresponds to the <c> CVTPI2PS </c> instruction.
1553309124Sdim///
1554309124Sdim/// \param __a
1555309124Sdim///    A 128-bit vector of [4 x float].
1556309124Sdim/// \param __b
1557309124Sdim///    A 64-bit vector of [2 x i32]. The elements in this vector are converted
1558309124Sdim///    and written to the corresponding low-order elements in the destination.
1559309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the
1560309124Sdim///    converted value of the second operand. The upper 64 bits are copied from
1561309124Sdim///    the upper 64 bits of the first operand.
1562341825Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
1563249423Sdim_mm_cvtpi32_ps(__m128 __a, __m64 __b)
1564193326Sed{
1565309124Sdim  return __builtin_ia32_cvtpi2ps((__v4sf)__a, (__v2si)__b);
1566193326Sed}
1567193326Sed
1568341825Sdim/// Converts two elements of a 64-bit vector of [2 x i32] into two
1569309124Sdim///    floating point values and writes them to the lower 64-bits of the
1570309124Sdim///    destination. The remaining higher order elements of the destination are
1571309124Sdim///    copied from the corresponding elements in the first operand.
1572309124Sdim///
1573309124Sdim/// \headerfile <x86intrin.h>
1574309124Sdim///
1575314564Sdim/// This intrinsic corresponds to the <c> CVTPI2PS </c> instruction.
1576309124Sdim///
1577309124Sdim/// \param __a
1578309124Sdim///    A 128-bit vector of [4 x float].
1579309124Sdim/// \param __b
1580309124Sdim///    A 64-bit vector of [2 x i32]. The elements in this vector are converted
1581309124Sdim///    and written to the corresponding low-order elements in the destination.
1582309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the
1583309124Sdim///    converted value from the second operand. The upper 64 bits are copied
1584309124Sdim///    from the upper 64 bits of the first operand.
1585341825Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
1586249423Sdim_mm_cvt_pi2ps(__m128 __a, __m64 __b)
1587212904Sdim{
1588249423Sdim  return _mm_cvtpi32_ps(__a, __b);
1589212904Sdim}
1590212904Sdim
1591341825Sdim/// Extracts a float value contained in the lower 32 bits of a vector of
1592309124Sdim///    [4 x float].
1593309124Sdim///
1594309124Sdim/// \headerfile <x86intrin.h>
1595309124Sdim///
1596341825Sdim/// This intrinsic has no corresponding instruction.
1597309124Sdim///
1598309124Sdim/// \param __a
1599309124Sdim///    A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
1600309124Sdim///    used in the extraction.
1601309124Sdim/// \returns A 32-bit float containing the extracted value.
1602288943Sdimstatic __inline__ float __DEFAULT_FN_ATTRS
1603249423Sdim_mm_cvtss_f32(__m128 __a)
1604193326Sed{
1605249423Sdim  return __a[0];
1606193326Sed}
1607193326Sed
1608341825Sdim/// Loads two packed float values from the address \a __p into the
1609309124Sdim///     high-order bits of a 128-bit vector of [4 x float]. The low-order bits
1610309124Sdim///     are copied from the low-order bits of the first operand.
1611309124Sdim///
1612309124Sdim/// \headerfile <x86intrin.h>
1613309124Sdim///
1614314564Sdim/// This intrinsic corresponds to the <c> VMOVHPD / MOVHPD </c> instruction.
1615309124Sdim///
1616309124Sdim/// \param __a
1617309124Sdim///    A 128-bit vector of [4 x float]. Bits [63:0] are written to bits [63:0]
1618309124Sdim///    of the destination.
1619309124Sdim/// \param __p
1620309124Sdim///    A pointer to two packed float values. Bits [63:0] are written to bits
1621309124Sdim///    [127:64] of the destination.
1622309124Sdim/// \returns A 128-bit vector of [4 x float] containing the moved values.
1623288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1624249423Sdim_mm_loadh_pi(__m128 __a, const __m64 *__p)
1625193326Sed{
1626226633Sdim  typedef float __mm_loadh_pi_v2f32 __attribute__((__vector_size__(8)));
1627226633Sdim  struct __mm_loadh_pi_struct {
1628249423Sdim    __mm_loadh_pi_v2f32 __u;
1629226633Sdim  } __attribute__((__packed__, __may_alias__));
1630360784Sdim  __mm_loadh_pi_v2f32 __b = ((const struct __mm_loadh_pi_struct*)__p)->__u;
1631249423Sdim  __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
1632249423Sdim  return __builtin_shufflevector(__a, __bb, 0, 1, 4, 5);
1633193326Sed}
1634193326Sed
1635341825Sdim/// Loads two packed float values from the address \a __p into the
1636314564Sdim///    low-order bits of a 128-bit vector of [4 x float]. The high-order bits
1637314564Sdim///    are copied from the high-order bits of the first operand.
1638309124Sdim///
1639309124Sdim/// \headerfile <x86intrin.h>
1640309124Sdim///
1641314564Sdim/// This intrinsic corresponds to the <c> VMOVLPD / MOVLPD </c> instruction.
1642309124Sdim///
1643309124Sdim/// \param __a
1644309124Sdim///    A 128-bit vector of [4 x float]. Bits [127:64] are written to bits
1645309124Sdim///    [127:64] of the destination.
1646309124Sdim/// \param __p
1647309124Sdim///    A pointer to two packed float values. Bits [63:0] are written to bits
1648309124Sdim///    [63:0] of the destination.
1649309124Sdim/// \returns A 128-bit vector of [4 x float] containing the moved values.
1650288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1651249423Sdim_mm_loadl_pi(__m128 __a, const __m64 *__p)
1652193326Sed{
1653226633Sdim  typedef float __mm_loadl_pi_v2f32 __attribute__((__vector_size__(8)));
1654226633Sdim  struct __mm_loadl_pi_struct {
1655249423Sdim    __mm_loadl_pi_v2f32 __u;
1656226633Sdim  } __attribute__((__packed__, __may_alias__));
1657360784Sdim  __mm_loadl_pi_v2f32 __b = ((const struct __mm_loadl_pi_struct*)__p)->__u;
1658249423Sdim  __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
1659249423Sdim  return __builtin_shufflevector(__a, __bb, 4, 5, 2, 3);
1660193326Sed}
1661193326Sed
1662341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float]. The lower
1663309124Sdim///    32 bits of the vector are initialized with the single-precision
1664309124Sdim///    floating-point value loaded from a specified memory location. The upper
1665309124Sdim///    96 bits are set to zero.
1666309124Sdim///
1667309124Sdim/// \headerfile <x86intrin.h>
1668309124Sdim///
1669314564Sdim/// This intrinsic corresponds to the <c> VMOVSS / MOVSS </c> instruction.
1670309124Sdim///
1671309124Sdim/// \param __p
1672309124Sdim///    A pointer to a 32-bit memory location containing a single-precision
1673309124Sdim///    floating-point value.
1674309124Sdim/// \returns An initialized 128-bit floating-point vector of [4 x float]. The
1675309124Sdim///    lower 32 bits contain the value loaded from the memory location. The
1676309124Sdim///    upper 96 bits are set to zero.
1677288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1678249423Sdim_mm_load_ss(const float *__p)
1679193326Sed{
1680226633Sdim  struct __mm_load_ss_struct {
1681249423Sdim    float __u;
1682226633Sdim  } __attribute__((__packed__, __may_alias__));
1683360784Sdim  float __u = ((const struct __mm_load_ss_struct*)__p)->__u;
1684341825Sdim  return __extension__ (__m128){ __u, 0, 0, 0 };
1685193326Sed}
1686193326Sed
1687341825Sdim/// Loads a 32-bit float value and duplicates it to all four vector
1688309124Sdim///    elements of a 128-bit vector of [4 x float].
1689309124Sdim///
1690309124Sdim/// \headerfile <x86intrin.h>
1691309124Sdim///
1692341825Sdim/// This intrinsic corresponds to the <c> VBROADCASTSS / MOVSS + shuffling </c>
1693309124Sdim///    instruction.
1694309124Sdim///
1695309124Sdim/// \param __p
1696309124Sdim///    A pointer to a float value to be loaded and duplicated.
1697314564Sdim/// \returns A 128-bit vector of [4 x float] containing the loaded and
1698314564Sdim///    duplicated values.
1699288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1700249423Sdim_mm_load1_ps(const float *__p)
1701193326Sed{
1702226633Sdim  struct __mm_load1_ps_struct {
1703249423Sdim    float __u;
1704226633Sdim  } __attribute__((__packed__, __may_alias__));
1705360784Sdim  float __u = ((const struct __mm_load1_ps_struct*)__p)->__u;
1706341825Sdim  return __extension__ (__m128){ __u, __u, __u, __u };
1707193326Sed}
1708193326Sed
1709193326Sed#define        _mm_load_ps1(p) _mm_load1_ps(p)
1710193326Sed
1711341825Sdim/// Loads a 128-bit floating-point vector of [4 x float] from an aligned
1712309124Sdim///    memory location.
1713309124Sdim///
1714309124Sdim/// \headerfile <x86intrin.h>
1715309124Sdim///
1716314564Sdim/// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS </c> instruction.
1717309124Sdim///
1718309124Sdim/// \param __p
1719309124Sdim///    A pointer to a 128-bit memory location. The address of the memory
1720309124Sdim///    location has to be 128-bit aligned.
1721341825Sdim/// \returns A 128-bit vector of [4 x float] containing the loaded values.
1722288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1723249423Sdim_mm_load_ps(const float *__p)
1724193326Sed{
1725360784Sdim  return *(const __m128*)__p;
1726193326Sed}
1727193326Sed
1728341825Sdim/// Loads a 128-bit floating-point vector of [4 x float] from an
1729309124Sdim///    unaligned memory location.
1730309124Sdim///
1731309124Sdim/// \headerfile <x86intrin.h>
1732309124Sdim///
1733314564Sdim/// This intrinsic corresponds to the <c> VMOVUPS / MOVUPS </c> instruction.
1734309124Sdim///
1735309124Sdim/// \param __p
1736309124Sdim///    A pointer to a 128-bit memory location. The address of the memory
1737309124Sdim///    location does not have to be aligned.
1738309124Sdim/// \returns A 128-bit vector of [4 x float] containing the loaded values.
1739288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1740249423Sdim_mm_loadu_ps(const float *__p)
1741193326Sed{
1742223017Sdim  struct __loadu_ps {
1743353358Sdim    __m128_u __v;
1744226633Sdim  } __attribute__((__packed__, __may_alias__));
1745360784Sdim  return ((const struct __loadu_ps*)__p)->__v;
1746193326Sed}
1747193326Sed
1748341825Sdim/// Loads four packed float values, in reverse order, from an aligned
1749309124Sdim///    memory location to 32-bit elements in a 128-bit vector of [4 x float].
1750309124Sdim///
1751309124Sdim/// \headerfile <x86intrin.h>
1752309124Sdim///
1753314564Sdim/// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS + shuffling </c>
1754309124Sdim///    instruction.
1755309124Sdim///
1756309124Sdim/// \param __p
1757309124Sdim///    A pointer to a 128-bit memory location. The address of the memory
1758309124Sdim///    location has to be 128-bit aligned.
1759309124Sdim/// \returns A 128-bit vector of [4 x float] containing the moved values, loaded
1760309124Sdim///    in reverse order.
1761288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1762249423Sdim_mm_loadr_ps(const float *__p)
1763193326Sed{
1764249423Sdim  __m128 __a = _mm_load_ps(__p);
1765309124Sdim  return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 3, 2, 1, 0);
1766193326Sed}
1767193326Sed
1768341825Sdim/// Create a 128-bit vector of [4 x float] with undefined values.
1769309124Sdim///
1770309124Sdim/// \headerfile <x86intrin.h>
1771309124Sdim///
1772309124Sdim/// This intrinsic has no corresponding instruction.
1773309124Sdim///
1774309124Sdim/// \returns A 128-bit vector of [4 x float] containing undefined values.
1775288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1776309124Sdim_mm_undefined_ps(void)
1777296417Sdim{
1778296417Sdim  return (__m128)__builtin_ia32_undef128();
1779296417Sdim}
1780296417Sdim
1781341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float]. The lower
1782309124Sdim///    32 bits of the vector are initialized with the specified single-precision
1783309124Sdim///    floating-point value. The upper 96 bits are set to zero.
1784309124Sdim///
1785309124Sdim/// \headerfile <x86intrin.h>
1786309124Sdim///
1787314564Sdim/// This intrinsic corresponds to the <c> VMOVSS / MOVSS </c> instruction.
1788309124Sdim///
1789309124Sdim/// \param __w
1790309124Sdim///    A single-precision floating-point value used to initialize the lower 32
1791309124Sdim///    bits of the result.
1792309124Sdim/// \returns An initialized 128-bit floating-point vector of [4 x float]. The
1793309124Sdim///    lower 32 bits contain the value provided in the source operand. The
1794309124Sdim///    upper 96 bits are set to zero.
1795296417Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1796249423Sdim_mm_set_ss(float __w)
1797193326Sed{
1798341825Sdim  return __extension__ (__m128){ __w, 0, 0, 0 };
1799193326Sed}
1800193326Sed
1801341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float], with each
1802309124Sdim///    of the four single-precision floating-point vector elements set to the
1803309124Sdim///    specified single-precision floating-point value.
1804309124Sdim///
1805309124Sdim/// \headerfile <x86intrin.h>
1806309124Sdim///
1807314564Sdim/// This intrinsic corresponds to the <c> VPERMILPS / PERMILPS </c> instruction.
1808309124Sdim///
1809309124Sdim/// \param __w
1810309124Sdim///    A single-precision floating-point value used to initialize each vector
1811309124Sdim///    element of the result.
1812309124Sdim/// \returns An initialized 128-bit floating-point vector of [4 x float].
1813288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1814249423Sdim_mm_set1_ps(float __w)
1815193326Sed{
1816341825Sdim  return __extension__ (__m128){ __w, __w, __w, __w };
1817193326Sed}
1818193326Sed
1819276479Sdim/* Microsoft specific. */
1820341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float], with each
1821309124Sdim///    of the four single-precision floating-point vector elements set to the
1822309124Sdim///    specified single-precision floating-point value.
1823309124Sdim///
1824309124Sdim/// \headerfile <x86intrin.h>
1825309124Sdim///
1826314564Sdim/// This intrinsic corresponds to the <c> VPERMILPS / PERMILPS </c> instruction.
1827309124Sdim///
1828309124Sdim/// \param __w
1829309124Sdim///    A single-precision floating-point value used to initialize each vector
1830309124Sdim///    element of the result.
1831309124Sdim/// \returns An initialized 128-bit floating-point vector of [4 x float].
1832288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1833249423Sdim_mm_set_ps1(float __w)
1834193326Sed{
1835249423Sdim    return _mm_set1_ps(__w);
1836193326Sed}
1837193326Sed
1838341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float]
1839309124Sdim///    initialized with the specified single-precision floating-point values.
1840309124Sdim///
1841309124Sdim/// \headerfile <x86intrin.h>
1842309124Sdim///
1843309124Sdim/// This intrinsic is a utility function and does not correspond to a specific
1844309124Sdim///    instruction.
1845309124Sdim///
1846309124Sdim/// \param __z
1847309124Sdim///    A single-precision floating-point value used to initialize bits [127:96]
1848309124Sdim///    of the result.
1849309124Sdim/// \param __y
1850309124Sdim///    A single-precision floating-point value used to initialize bits [95:64]
1851309124Sdim///    of the result.
1852309124Sdim/// \param __x
1853309124Sdim///    A single-precision floating-point value used to initialize bits [63:32]
1854309124Sdim///    of the result.
1855309124Sdim/// \param __w
1856309124Sdim///    A single-precision floating-point value used to initialize bits [31:0]
1857309124Sdim///    of the result.
1858309124Sdim/// \returns An initialized 128-bit floating-point vector of [4 x float].
1859288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1860249423Sdim_mm_set_ps(float __z, float __y, float __x, float __w)
1861193326Sed{
1862341825Sdim  return __extension__ (__m128){ __w, __x, __y, __z };
1863193326Sed}
1864193326Sed
1865341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float],
1866309124Sdim///    initialized in reverse order with the specified 32-bit single-precision
1867309124Sdim///    float-point values.
1868309124Sdim///
1869309124Sdim/// \headerfile <x86intrin.h>
1870309124Sdim///
1871309124Sdim/// This intrinsic is a utility function and does not correspond to a specific
1872309124Sdim///    instruction.
1873309124Sdim///
1874309124Sdim/// \param __z
1875309124Sdim///    A single-precision floating-point value used to initialize bits [31:0]
1876309124Sdim///    of the result.
1877309124Sdim/// \param __y
1878309124Sdim///    A single-precision floating-point value used to initialize bits [63:32]
1879309124Sdim///    of the result.
1880309124Sdim/// \param __x
1881309124Sdim///    A single-precision floating-point value used to initialize bits [95:64]
1882309124Sdim///    of the result.
1883309124Sdim/// \param __w
1884309124Sdim///    A single-precision floating-point value used to initialize bits [127:96]
1885309124Sdim///    of the result.
1886309124Sdim/// \returns An initialized 128-bit floating-point vector of [4 x float].
1887288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1888249423Sdim_mm_setr_ps(float __z, float __y, float __x, float __w)
1889193326Sed{
1890341825Sdim  return __extension__ (__m128){ __z, __y, __x, __w };
1891193326Sed}
1892193326Sed
1893341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float] initialized
1894309124Sdim///    to zero.
1895309124Sdim///
1896309124Sdim/// \headerfile <x86intrin.h>
1897309124Sdim///
1898314564Sdim/// This intrinsic corresponds to the <c> VXORPS / XORPS </c> instruction.
1899309124Sdim///
1900309124Sdim/// \returns An initialized 128-bit floating-point vector of [4 x float] with
1901309124Sdim///    all elements set to zero.
1902288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
1903193326Sed_mm_setzero_ps(void)
1904193326Sed{
1905341825Sdim  return __extension__ (__m128){ 0, 0, 0, 0 };
1906193326Sed}
1907193326Sed
1908341825Sdim/// Stores the upper 64 bits of a 128-bit vector of [4 x float] to a
1909309124Sdim///    memory location.
1910309124Sdim///
1911309124Sdim/// \headerfile <x86intrin.h>
1912309124Sdim///
1913341825Sdim/// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction.
1914309124Sdim///
1915309124Sdim/// \param __p
1916309124Sdim///    A pointer to a 64-bit memory location.
1917309124Sdim/// \param __a
1918309124Sdim///    A 128-bit vector of [4 x float] containing the values to be stored.
1919288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
1920249423Sdim_mm_storeh_pi(__m64 *__p, __m128 __a)
1921193326Sed{
1922353358Sdim  typedef float __mm_storeh_pi_v2f32 __attribute__((__vector_size__(8)));
1923353358Sdim  struct __mm_storeh_pi_struct {
1924353358Sdim    __mm_storeh_pi_v2f32 __u;
1925353358Sdim  } __attribute__((__packed__, __may_alias__));
1926353358Sdim  ((struct __mm_storeh_pi_struct*)__p)->__u = __builtin_shufflevector(__a, __a, 2, 3);
1927193326Sed}
1928193326Sed
1929341825Sdim/// Stores the lower 64 bits of a 128-bit vector of [4 x float] to a
1930309124Sdim///     memory location.
1931309124Sdim///
1932309124Sdim/// \headerfile <x86intrin.h>
1933309124Sdim///
1934314564Sdim/// This intrinsic corresponds to the <c> VMOVLPS / MOVLPS </c> instruction.
1935309124Sdim///
1936309124Sdim/// \param __p
1937309124Sdim///    A pointer to a memory location that will receive the float values.
1938309124Sdim/// \param __a
1939309124Sdim///    A 128-bit vector of [4 x float] containing the values to be stored.
1940288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
1941249423Sdim_mm_storel_pi(__m64 *__p, __m128 __a)
1942193326Sed{
1943353358Sdim  typedef float __mm_storeh_pi_v2f32 __attribute__((__vector_size__(8)));
1944353358Sdim  struct __mm_storeh_pi_struct {
1945353358Sdim    __mm_storeh_pi_v2f32 __u;
1946353358Sdim  } __attribute__((__packed__, __may_alias__));
1947353358Sdim  ((struct __mm_storeh_pi_struct*)__p)->__u = __builtin_shufflevector(__a, __a, 0, 1);
1948193326Sed}
1949193326Sed
1950341825Sdim/// Stores the lower 32 bits of a 128-bit vector of [4 x float] to a
1951309124Sdim///     memory location.
1952309124Sdim///
1953309124Sdim/// \headerfile <x86intrin.h>
1954309124Sdim///
1955314564Sdim/// This intrinsic corresponds to the <c> VMOVSS / MOVSS </c> instruction.
1956309124Sdim///
1957309124Sdim/// \param __p
1958309124Sdim///    A pointer to a 32-bit memory location.
1959309124Sdim/// \param __a
1960309124Sdim///    A 128-bit vector of [4 x float] containing the value to be stored.
1961288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
1962249423Sdim_mm_store_ss(float *__p, __m128 __a)
1963193326Sed{
1964226633Sdim  struct __mm_store_ss_struct {
1965249423Sdim    float __u;
1966226633Sdim  } __attribute__((__packed__, __may_alias__));
1967249423Sdim  ((struct __mm_store_ss_struct*)__p)->__u = __a[0];
1968193326Sed}
1969193326Sed
1970341825Sdim/// Stores a 128-bit vector of [4 x float] to an unaligned memory
1971314564Sdim///    location.
1972309124Sdim///
1973309124Sdim/// \headerfile <x86intrin.h>
1974309124Sdim///
1975314564Sdim/// This intrinsic corresponds to the <c> VMOVUPS / MOVUPS </c> instruction.
1976309124Sdim///
1977309124Sdim/// \param __p
1978309124Sdim///    A pointer to a 128-bit memory location. The address of the memory
1979309124Sdim///    location does not have to be aligned.
1980309124Sdim/// \param __a
1981309124Sdim///    A 128-bit vector of [4 x float] containing the values to be stored.
1982288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
1983249423Sdim_mm_storeu_ps(float *__p, __m128 __a)
1984193326Sed{
1985309124Sdim  struct __storeu_ps {
1986353358Sdim    __m128_u __v;
1987309124Sdim  } __attribute__((__packed__, __may_alias__));
1988309124Sdim  ((struct __storeu_ps*)__p)->__v = __a;
1989193326Sed}
1990193326Sed
1991341825Sdim/// Stores a 128-bit vector of [4 x float] into an aligned memory
1992314564Sdim///    location.
1993309124Sdim///
1994309124Sdim/// \headerfile <x86intrin.h>
1995309124Sdim///
1996314564Sdim/// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS </c> instruction.
1997309124Sdim///
1998309124Sdim/// \param __p
1999314564Sdim///    A pointer to a 128-bit memory location. The address of the memory
2000314564Sdim///    location has to be 16-byte aligned.
2001309124Sdim/// \param __a
2002314564Sdim///    A 128-bit vector of [4 x float] containing the values to be stored.
2003288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
2004309124Sdim_mm_store_ps(float *__p, __m128 __a)
2005193326Sed{
2006309124Sdim  *(__m128*)__p = __a;
2007193326Sed}
2008193326Sed
2009341825Sdim/// Stores the lower 32 bits of a 128-bit vector of [4 x float] into
2010309124Sdim///    four contiguous elements in an aligned memory location.
2011309124Sdim///
2012309124Sdim/// \headerfile <x86intrin.h>
2013309124Sdim///
2014314564Sdim/// This intrinsic corresponds to <c> VMOVAPS / MOVAPS + shuffling </c>
2015309124Sdim///    instruction.
2016309124Sdim///
2017309124Sdim/// \param __p
2018309124Sdim///    A pointer to a 128-bit memory location.
2019309124Sdim/// \param __a
2020309124Sdim///    A 128-bit vector of [4 x float] whose lower 32 bits are stored to each
2021314564Sdim///    of the four contiguous elements pointed by \a __p.
2022288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
2023309124Sdim_mm_store1_ps(float *__p, __m128 __a)
2024212904Sdim{
2025309124Sdim  __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 0, 0);
2026309124Sdim  _mm_store_ps(__p, __a);
2027212904Sdim}
2028212904Sdim
2029341825Sdim/// Stores the lower 32 bits of a 128-bit vector of [4 x float] into
2030314564Sdim///    four contiguous elements in an aligned memory location.
2031309124Sdim///
2032309124Sdim/// \headerfile <x86intrin.h>
2033309124Sdim///
2034314564Sdim/// This intrinsic corresponds to <c> VMOVAPS / MOVAPS + shuffling </c>
2035314564Sdim///    instruction.
2036309124Sdim///
2037309124Sdim/// \param __p
2038314564Sdim///    A pointer to a 128-bit memory location.
2039309124Sdim/// \param __a
2040314564Sdim///    A 128-bit vector of [4 x float] whose lower 32 bits are stored to each
2041314564Sdim///    of the four contiguous elements pointed by \a __p.
2042288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
2043309124Sdim_mm_store_ps1(float *__p, __m128 __a)
2044193326Sed{
2045341825Sdim  _mm_store1_ps(__p, __a);
2046193326Sed}
2047193326Sed
2048341825Sdim/// Stores float values from a 128-bit vector of [4 x float] to an
2049309124Sdim///    aligned memory location in reverse order.
2050309124Sdim///
2051309124Sdim/// \headerfile <x86intrin.h>
2052309124Sdim///
2053314564Sdim/// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS + shuffling </c>
2054309124Sdim///    instruction.
2055309124Sdim///
2056309124Sdim/// \param __p
2057309124Sdim///    A pointer to a 128-bit memory location. The address of the memory
2058309124Sdim///    location has to be 128-bit aligned.
2059309124Sdim/// \param __a
2060309124Sdim///    A 128-bit vector of [4 x float] containing the values to be stored.
2061288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
2062249423Sdim_mm_storer_ps(float *__p, __m128 __a)
2063193326Sed{
2064309124Sdim  __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 3, 2, 1, 0);
2065249423Sdim  _mm_store_ps(__p, __a);
2066193326Sed}
2067193326Sed
2068327952Sdim#define _MM_HINT_ET0 7
2069327952Sdim#define _MM_HINT_ET1 6
2070327952Sdim#define _MM_HINT_T0  3
2071327952Sdim#define _MM_HINT_T1  2
2072327952Sdim#define _MM_HINT_T2  1
2073193326Sed#define _MM_HINT_NTA 0
2074193326Sed
2075276479Sdim#ifndef _MSC_VER
2076210299Sed/* FIXME: We have to #define this because "sel" must be a constant integer, and
2077193326Sed   Sema doesn't do any form of constant propagation yet. */
2078193326Sed
2079341825Sdim/// Loads one cache line of data from the specified address to a location
2080309124Sdim///    closer to the processor.
2081309124Sdim///
2082309124Sdim/// \headerfile <x86intrin.h>
2083309124Sdim///
2084309124Sdim/// \code
2085309124Sdim/// void _mm_prefetch(const void * a, const int sel);
2086309124Sdim/// \endcode
2087309124Sdim///
2088314564Sdim/// This intrinsic corresponds to the <c> PREFETCHNTA </c> instruction.
2089309124Sdim///
2090309124Sdim/// \param a
2091309124Sdim///    A pointer to a memory location containing a cache line of data.
2092309124Sdim/// \param sel
2093314564Sdim///    A predefined integer constant specifying the type of prefetch
2094314564Sdim///    operation: \n
2095314564Sdim///    _MM_HINT_NTA: Move data using the non-temporal access (NTA) hint. The
2096314564Sdim///    PREFETCHNTA instruction will be generated. \n
2097309124Sdim///    _MM_HINT_T0: Move data using the T0 hint. The PREFETCHT0 instruction will
2098314564Sdim///    be generated. \n
2099309124Sdim///    _MM_HINT_T1: Move data using the T1 hint. The PREFETCHT1 instruction will
2100314564Sdim///    be generated. \n
2101309124Sdim///    _MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will
2102321369Sdim///    be generated.
2103360784Sdim#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \
2104327952Sdim                                                 ((sel) >> 2) & 1, (sel) & 0x3))
2105276479Sdim#endif
2106193326Sed
2107341825Sdim/// Stores a 64-bit integer in the specified aligned memory location. To
2108309124Sdim///    minimize caching, the data is flagged as non-temporal (unlikely to be
2109309124Sdim///    used again soon).
2110309124Sdim///
2111309124Sdim/// \headerfile <x86intrin.h>
2112309124Sdim///
2113314564Sdim/// This intrinsic corresponds to the <c> MOVNTQ </c> instruction.
2114309124Sdim///
2115309124Sdim/// \param __p
2116309124Sdim///    A pointer to an aligned memory location used to store the register value.
2117309124Sdim/// \param __a
2118309124Sdim///    A 64-bit integer containing the value to be stored.
2119341825Sdimstatic __inline__ void __DEFAULT_FN_ATTRS_MMX
2120249423Sdim_mm_stream_pi(__m64 *__p, __m64 __a)
2121193326Sed{
2122249423Sdim  __builtin_ia32_movntq(__p, __a);
2123193326Sed}
2124193326Sed
2125341825Sdim/// Moves packed float values from a 128-bit vector of [4 x float] to a
2126309124Sdim///    128-bit aligned memory location. To minimize caching, the data is flagged
2127309124Sdim///    as non-temporal (unlikely to be used again soon).
2128309124Sdim///
2129309124Sdim/// \headerfile <x86intrin.h>
2130309124Sdim///
2131314564Sdim/// This intrinsic corresponds to the <c> VMOVNTPS / MOVNTPS </c> instruction.
2132309124Sdim///
2133309124Sdim/// \param __p
2134309124Sdim///    A pointer to a 128-bit aligned memory location that will receive the
2135321369Sdim///    single-precision floating-point values.
2136309124Sdim/// \param __a
2137309124Sdim///    A 128-bit vector of [4 x float] containing the values to be moved.
2138288943Sdimstatic __inline__ void __DEFAULT_FN_ATTRS
2139249423Sdim_mm_stream_ps(float *__p, __m128 __a)
2140193326Sed{
2141309124Sdim  __builtin_nontemporal_store((__v4sf)__a, (__v4sf*)__p);
2142193326Sed}
2143193326Sed
2144314564Sdim#if defined(__cplusplus)
2145314564Sdimextern "C" {
2146314564Sdim#endif
2147314564Sdim
2148341825Sdim/// Forces strong memory ordering (serialization) between store
2149309124Sdim///    instructions preceding this instruction and store instructions following
2150309124Sdim///    this instruction, ensuring the system completes all previous stores
2151309124Sdim///    before executing subsequent stores.
2152309124Sdim///
2153309124Sdim/// \headerfile <x86intrin.h>
2154309124Sdim///
2155314564Sdim/// This intrinsic corresponds to the <c> SFENCE </c> instruction.
2156309124Sdim///
2157314564Sdimvoid _mm_sfence(void);
2158193326Sed
2159314564Sdim#if defined(__cplusplus)
2160314564Sdim} // extern "C"
2161314564Sdim#endif
2162314564Sdim
2163341825Sdim/// Extracts 16-bit element from a 64-bit vector of [4 x i16] and
2164309124Sdim///    returns it, as specified by the immediate integer operand.
2165309124Sdim///
2166309124Sdim/// \headerfile <x86intrin.h>
2167309124Sdim///
2168314564Sdim/// \code
2169321369Sdim/// int _mm_extract_pi16(__m64 a, int n);
2170314564Sdim/// \endcode
2171309124Sdim///
2172314564Sdim/// This intrinsic corresponds to the <c> VPEXTRW / PEXTRW </c> instruction.
2173314564Sdim///
2174314564Sdim/// \param a
2175309124Sdim///    A 64-bit vector of [4 x i16].
2176314564Sdim/// \param n
2177314564Sdim///    An immediate integer operand that determines which bits are extracted: \n
2178314564Sdim///    0: Bits [15:0] are copied to the destination. \n
2179314564Sdim///    1: Bits [31:16] are copied to the destination. \n
2180314564Sdim///    2: Bits [47:32] are copied to the destination. \n
2181309124Sdim///    3: Bits [63:48] are copied to the destination.
2182309124Sdim/// \returns A 16-bit integer containing the extracted 16 bits of packed data.
2183341825Sdim#define _mm_extract_pi16(a, n) \
2184360784Sdim  (int)__builtin_ia32_vec_ext_v4hi((__v4hi)a, (int)n)
2185193326Sed
2186341825Sdim/// Copies data from the 64-bit vector of [4 x i16] to the destination,
2187309124Sdim///    and inserts the lower 16-bits of an integer operand at the 16-bit offset
2188314564Sdim///    specified by the immediate operand \a n.
2189309124Sdim///
2190309124Sdim/// \headerfile <x86intrin.h>
2191309124Sdim///
2192314564Sdim/// \code
2193321369Sdim/// __m64 _mm_insert_pi16(__m64 a, int d, int n);
2194314564Sdim/// \endcode
2195309124Sdim///
2196341825Sdim/// This intrinsic corresponds to the <c> PINSRW </c> instruction.
2197314564Sdim///
2198314564Sdim/// \param a
2199309124Sdim///    A 64-bit vector of [4 x i16].
2200314564Sdim/// \param d
2201309124Sdim///    An integer. The lower 16-bit value from this operand is written to the
2202314564Sdim///    destination at the offset specified by operand \a n.
2203314564Sdim/// \param n
2204309124Sdim///    An immediate integer operant that determines which the bits to be used
2205314564Sdim///    in the destination. \n
2206314564Sdim///    0: Bits [15:0] are copied to the destination. \n
2207314564Sdim///    1: Bits [31:16] are copied to the destination. \n
2208314564Sdim///    2: Bits [47:32] are copied to the destination. \n
2209314564Sdim///    3: Bits [63:48] are copied to the destination.  \n
2210309124Sdim///    The remaining bits in the destination are copied from the corresponding
2211314564Sdim///    bits in operand \a a.
2212309124Sdim/// \returns A 64-bit integer vector containing the copied packed data from the
2213309124Sdim///    operands.
2214341825Sdim#define _mm_insert_pi16(a, d, n) \
2215360784Sdim  (__m64)__builtin_ia32_vec_set_v4hi((__v4hi)a, (int)d, (int)n)
2216193326Sed
2217341825Sdim/// Compares each of the corresponding packed 16-bit integer values of
2218309124Sdim///    the 64-bit integer vectors, and writes the greater value to the
2219309124Sdim///    corresponding bits in the destination.
2220309124Sdim///
2221309124Sdim/// \headerfile <x86intrin.h>
2222309124Sdim///
2223314564Sdim/// This intrinsic corresponds to the <c> PMAXSW </c> instruction.
2224309124Sdim///
2225309124Sdim/// \param __a
2226309124Sdim///    A 64-bit integer vector containing one of the source operands.
2227309124Sdim/// \param __b
2228309124Sdim///    A 64-bit integer vector containing one of the source operands.
2229309124Sdim/// \returns A 64-bit integer vector containing the comparison results.
2230341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2231249423Sdim_mm_max_pi16(__m64 __a, __m64 __b)
2232193326Sed{
2233249423Sdim  return (__m64)__builtin_ia32_pmaxsw((__v4hi)__a, (__v4hi)__b);
2234193326Sed}
2235193326Sed
2236341825Sdim/// Compares each of the corresponding packed 8-bit unsigned integer
2237309124Sdim///    values of the 64-bit integer vectors, and writes the greater value to the
2238309124Sdim///    corresponding bits in the destination.
2239309124Sdim///
2240309124Sdim/// \headerfile <x86intrin.h>
2241309124Sdim///
2242314564Sdim/// This intrinsic corresponds to the <c> PMAXUB </c> instruction.
2243309124Sdim///
2244309124Sdim/// \param __a
2245309124Sdim///    A 64-bit integer vector containing one of the source operands.
2246309124Sdim/// \param __b
2247309124Sdim///    A 64-bit integer vector containing one of the source operands.
2248309124Sdim/// \returns A 64-bit integer vector containing the comparison results.
2249341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2250249423Sdim_mm_max_pu8(__m64 __a, __m64 __b)
2251193326Sed{
2252249423Sdim  return (__m64)__builtin_ia32_pmaxub((__v8qi)__a, (__v8qi)__b);
2253193326Sed}
2254193326Sed
2255341825Sdim/// Compares each of the corresponding packed 16-bit integer values of
2256309124Sdim///    the 64-bit integer vectors, and writes the lesser value to the
2257309124Sdim///    corresponding bits in the destination.
2258309124Sdim///
2259309124Sdim/// \headerfile <x86intrin.h>
2260309124Sdim///
2261314564Sdim/// This intrinsic corresponds to the <c> PMINSW </c> instruction.
2262309124Sdim///
2263309124Sdim/// \param __a
2264309124Sdim///    A 64-bit integer vector containing one of the source operands.
2265309124Sdim/// \param __b
2266309124Sdim///    A 64-bit integer vector containing one of the source operands.
2267309124Sdim/// \returns A 64-bit integer vector containing the comparison results.
2268341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2269249423Sdim_mm_min_pi16(__m64 __a, __m64 __b)
2270193326Sed{
2271249423Sdim  return (__m64)__builtin_ia32_pminsw((__v4hi)__a, (__v4hi)__b);
2272193326Sed}
2273193326Sed
2274341825Sdim/// Compares each of the corresponding packed 8-bit unsigned integer
2275309124Sdim///    values of the 64-bit integer vectors, and writes the lesser value to the
2276309124Sdim///    corresponding bits in the destination.
2277309124Sdim///
2278309124Sdim/// \headerfile <x86intrin.h>
2279309124Sdim///
2280314564Sdim/// This intrinsic corresponds to the <c> PMINUB </c> instruction.
2281309124Sdim///
2282309124Sdim/// \param __a
2283309124Sdim///    A 64-bit integer vector containing one of the source operands.
2284309124Sdim/// \param __b
2285309124Sdim///    A 64-bit integer vector containing one of the source operands.
2286309124Sdim/// \returns A 64-bit integer vector containing the comparison results.
2287341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2288249423Sdim_mm_min_pu8(__m64 __a, __m64 __b)
2289193326Sed{
2290249423Sdim  return (__m64)__builtin_ia32_pminub((__v8qi)__a, (__v8qi)__b);
2291193326Sed}
2292193326Sed
2293341825Sdim/// Takes the most significant bit from each 8-bit element in a 64-bit
2294341825Sdim///    integer vector to create an 8-bit mask value. Zero-extends the value to
2295309124Sdim///    32-bit integer and writes it to the destination.
2296309124Sdim///
2297309124Sdim/// \headerfile <x86intrin.h>
2298309124Sdim///
2299314564Sdim/// This intrinsic corresponds to the <c> PMOVMSKB </c> instruction.
2300309124Sdim///
2301309124Sdim/// \param __a
2302309124Sdim///    A 64-bit integer vector containing the values with bits to be extracted.
2303341825Sdim/// \returns The most significant bit from each 8-bit element in \a __a,
2304341825Sdim///    written to bits [7:0].
2305341825Sdimstatic __inline__ int __DEFAULT_FN_ATTRS_MMX
2306249423Sdim_mm_movemask_pi8(__m64 __a)
2307193326Sed{
2308249423Sdim  return __builtin_ia32_pmovmskb((__v8qi)__a);
2309193326Sed}
2310193326Sed
2311341825Sdim/// Multiplies packed 16-bit unsigned integer values and writes the
2312309124Sdim///    high-order 16 bits of each 32-bit product to the corresponding bits in
2313309124Sdim///    the destination.
2314309124Sdim///
2315309124Sdim/// \headerfile <x86intrin.h>
2316309124Sdim///
2317314564Sdim/// This intrinsic corresponds to the <c> PMULHUW </c> instruction.
2318309124Sdim///
2319309124Sdim/// \param __a
2320309124Sdim///    A 64-bit integer vector containing one of the source operands.
2321309124Sdim/// \param __b
2322309124Sdim///    A 64-bit integer vector containing one of the source operands.
2323309124Sdim/// \returns A 64-bit integer vector containing the products of both operands.
2324341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2325249423Sdim_mm_mulhi_pu16(__m64 __a, __m64 __b)
2326193326Sed{
2327249423Sdim  return (__m64)__builtin_ia32_pmulhuw((__v4hi)__a, (__v4hi)__b);
2328193326Sed}
2329193326Sed
2330341825Sdim/// Shuffles the 4 16-bit integers from a 64-bit integer vector to the
2331309124Sdim///    destination, as specified by the immediate value operand.
2332309124Sdim///
2333309124Sdim/// \headerfile <x86intrin.h>
2334309124Sdim///
2335309124Sdim/// \code
2336309124Sdim/// __m64 _mm_shuffle_pi16(__m64 a, const int n);
2337309124Sdim/// \endcode
2338309124Sdim///
2339314564Sdim/// This intrinsic corresponds to the <c> PSHUFW </c> instruction.
2340314564Sdim///
2341309124Sdim/// \param a
2342309124Sdim///    A 64-bit integer vector containing the values to be shuffled.
2343309124Sdim/// \param n
2344309124Sdim///    An immediate value containing an 8-bit value specifying which elements to
2345314564Sdim///    copy from \a a. The destinations within the 64-bit destination are
2346314564Sdim///    assigned values as follows: \n
2347314564Sdim///    Bits [1:0] are used to assign values to bits [15:0] in the
2348314564Sdim///    destination. \n
2349314564Sdim///    Bits [3:2] are used to assign values to bits [31:16] in the
2350314564Sdim///    destination. \n
2351314564Sdim///    Bits [5:4] are used to assign values to bits [47:32] in the
2352314564Sdim///    destination. \n
2353314564Sdim///    Bits [7:6] are used to assign values to bits [63:48] in the
2354314564Sdim///    destination. \n
2355314564Sdim///    Bit value assignments: \n
2356314564Sdim///    00: assigned from bits [15:0] of \a a. \n
2357314564Sdim///    01: assigned from bits [31:16] of \a a. \n
2358314564Sdim///    10: assigned from bits [47:32] of \a a. \n
2359314564Sdim///    11: assigned from bits [63:48] of \a a.
2360309124Sdim/// \returns A 64-bit integer vector containing the shuffled values.
2361341825Sdim#define _mm_shuffle_pi16(a, n) \
2362341825Sdim  (__m64)__builtin_ia32_pshufw((__v4hi)(__m64)(a), (n))
2363193326Sed
2364341825Sdim/// Conditionally copies the values from each 8-bit element in the first
2365309124Sdim///    64-bit integer vector operand to the specified memory location, as
2366309124Sdim///    specified by the most significant bit in the corresponding element in the
2367321369Sdim///    second 64-bit integer vector operand.
2368309124Sdim///
2369321369Sdim///    To minimize caching, the data is flagged as non-temporal
2370321369Sdim///    (unlikely to be used again soon).
2371321369Sdim///
2372309124Sdim/// \headerfile <x86intrin.h>
2373309124Sdim///
2374314564Sdim/// This intrinsic corresponds to the <c> MASKMOVQ </c> instruction.
2375309124Sdim///
2376309124Sdim/// \param __d
2377309124Sdim///    A 64-bit integer vector containing the values with elements to be copied.
2378309124Sdim/// \param __n
2379309124Sdim///    A 64-bit integer vector operand. The most significant bit from each 8-bit
2380314564Sdim///    element determines whether the corresponding element in operand \a __d
2381314564Sdim///    is copied. If the most significant bit of a given element is 1, the
2382314564Sdim///    corresponding element in operand \a __d is copied.
2383309124Sdim/// \param __p
2384309124Sdim///    A pointer to a 64-bit memory location that will receive the conditionally
2385309124Sdim///    copied integer values. The address of the memory location does not have
2386309124Sdim///    to be aligned.
2387341825Sdimstatic __inline__ void __DEFAULT_FN_ATTRS_MMX
2388249423Sdim_mm_maskmove_si64(__m64 __d, __m64 __n, char *__p)
2389193326Sed{
2390249423Sdim  __builtin_ia32_maskmovq((__v8qi)__d, (__v8qi)__n, __p);
2391193326Sed}
2392193326Sed
2393341825Sdim/// Computes the rounded averages of the packed unsigned 8-bit integer
2394309124Sdim///    values and writes the averages to the corresponding bits in the
2395309124Sdim///    destination.
2396309124Sdim///
2397309124Sdim/// \headerfile <x86intrin.h>
2398309124Sdim///
2399314564Sdim/// This intrinsic corresponds to the <c> PAVGB </c> instruction.
2400309124Sdim///
2401309124Sdim/// \param __a
2402309124Sdim///    A 64-bit integer vector containing one of the source operands.
2403309124Sdim/// \param __b
2404309124Sdim///    A 64-bit integer vector containing one of the source operands.
2405309124Sdim/// \returns A 64-bit integer vector containing the averages of both operands.
2406341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2407249423Sdim_mm_avg_pu8(__m64 __a, __m64 __b)
2408193326Sed{
2409249423Sdim  return (__m64)__builtin_ia32_pavgb((__v8qi)__a, (__v8qi)__b);
2410193326Sed}
2411193326Sed
2412341825Sdim/// Computes the rounded averages of the packed unsigned 16-bit integer
2413309124Sdim///    values and writes the averages to the corresponding bits in the
2414309124Sdim///    destination.
2415309124Sdim///
2416309124Sdim/// \headerfile <x86intrin.h>
2417309124Sdim///
2418314564Sdim/// This intrinsic corresponds to the <c> PAVGW </c> instruction.
2419309124Sdim///
2420309124Sdim/// \param __a
2421309124Sdim///    A 64-bit integer vector containing one of the source operands.
2422309124Sdim/// \param __b
2423309124Sdim///    A 64-bit integer vector containing one of the source operands.
2424309124Sdim/// \returns A 64-bit integer vector containing the averages of both operands.
2425341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2426249423Sdim_mm_avg_pu16(__m64 __a, __m64 __b)
2427193326Sed{
2428249423Sdim  return (__m64)__builtin_ia32_pavgw((__v4hi)__a, (__v4hi)__b);
2429193326Sed}
2430193326Sed
2431341825Sdim/// Subtracts the corresponding 8-bit unsigned integer values of the two
2432309124Sdim///    64-bit vector operands and computes the absolute value for each of the
2433309124Sdim///    difference. Then sum of the 8 absolute differences is written to the
2434309124Sdim///    bits [15:0] of the destination; the remaining bits [63:16] are cleared.
2435309124Sdim///
2436309124Sdim/// \headerfile <x86intrin.h>
2437309124Sdim///
2438314564Sdim/// This intrinsic corresponds to the <c> PSADBW </c> instruction.
2439309124Sdim///
2440309124Sdim/// \param __a
2441309124Sdim///    A 64-bit integer vector containing one of the source operands.
2442309124Sdim/// \param __b
2443309124Sdim///    A 64-bit integer vector containing one of the source operands.
2444309124Sdim/// \returns A 64-bit integer vector whose lower 16 bits contain the sums of the
2445309124Sdim///    sets of absolute differences between both operands. The upper bits are
2446309124Sdim///    cleared.
2447341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2448249423Sdim_mm_sad_pu8(__m64 __a, __m64 __b)
2449193326Sed{
2450249423Sdim  return (__m64)__builtin_ia32_psadbw((__v8qi)__a, (__v8qi)__b);
2451193326Sed}
2452193326Sed
2453314564Sdim#if defined(__cplusplus)
2454314564Sdimextern "C" {
2455314564Sdim#endif
2456314564Sdim
2457341825Sdim/// Returns the contents of the MXCSR register as a 32-bit unsigned
2458314564Sdim///    integer value.
2459314564Sdim///
2460314564Sdim///    There are several groups of macros associated with this
2461309124Sdim///    intrinsic, including:
2462314564Sdim///    <ul>
2463314564Sdim///    <li>
2464314564Sdim///      For checking exception states: _MM_EXCEPT_INVALID, _MM_EXCEPT_DIV_ZERO,
2465309124Sdim///      _MM_EXCEPT_DENORM, _MM_EXCEPT_OVERFLOW, _MM_EXCEPT_UNDERFLOW,
2466309124Sdim///      _MM_EXCEPT_INEXACT. There is a convenience wrapper
2467309124Sdim///      _MM_GET_EXCEPTION_STATE().
2468314564Sdim///    </li>
2469314564Sdim///    <li>
2470314564Sdim///      For checking exception masks: _MM_MASK_UNDERFLOW, _MM_MASK_OVERFLOW,
2471309124Sdim///      _MM_MASK_INVALID, _MM_MASK_DENORM, _MM_MASK_DIV_ZERO, _MM_MASK_INEXACT.
2472309124Sdim///      There is a convenience wrapper _MM_GET_EXCEPTION_MASK().
2473321369Sdim///    </li>
2474314564Sdim///    <li>
2475314564Sdim///      For checking rounding modes: _MM_ROUND_NEAREST, _MM_ROUND_DOWN,
2476309124Sdim///      _MM_ROUND_UP, _MM_ROUND_TOWARD_ZERO. There is a convenience wrapper
2477341825Sdim///      _MM_GET_ROUNDING_MODE().
2478314564Sdim///    </li>
2479321369Sdim///    <li>
2480314564Sdim///      For checking flush-to-zero mode: _MM_FLUSH_ZERO_ON, _MM_FLUSH_ZERO_OFF.
2481309124Sdim///      There is a convenience wrapper _MM_GET_FLUSH_ZERO_MODE().
2482314564Sdim///    </li>
2483321369Sdim///    <li>
2484314564Sdim///      For checking denormals-are-zero mode: _MM_DENORMALS_ZERO_ON,
2485309124Sdim///      _MM_DENORMALS_ZERO_OFF. There is a convenience wrapper
2486309124Sdim///      _MM_GET_DENORMALS_ZERO_MODE().
2487314564Sdim///    </li>
2488314564Sdim///    </ul>
2489309124Sdim///
2490341825Sdim///    For example, the following expression checks if an overflow exception has
2491309124Sdim///    occurred:
2492341825Sdim///    \code
2493309124Sdim///      ( _mm_getcsr() & _MM_EXCEPT_OVERFLOW )
2494341825Sdim///    \endcode
2495309124Sdim///
2496341825Sdim///    The following expression gets the current rounding mode:
2497341825Sdim///    \code
2498309124Sdim///      _MM_GET_ROUNDING_MODE()
2499341825Sdim///    \endcode
2500309124Sdim///
2501309124Sdim/// \headerfile <x86intrin.h>
2502309124Sdim///
2503314564Sdim/// This intrinsic corresponds to the <c> VSTMXCSR / STMXCSR </c> instruction.
2504309124Sdim///
2505309124Sdim/// \returns A 32-bit unsigned integer containing the contents of the MXCSR
2506309124Sdim///    register.
2507314564Sdimunsigned int _mm_getcsr(void);
2508193326Sed
2509341825Sdim/// Sets the MXCSR register with the 32-bit unsigned integer value.
2510321369Sdim///
2511314564Sdim///    There are several groups of macros associated with this intrinsic,
2512314564Sdim///    including:
2513314564Sdim///    <ul>
2514321369Sdim///    <li>
2515314564Sdim///      For setting exception states: _MM_EXCEPT_INVALID, _MM_EXCEPT_DIV_ZERO,
2516309124Sdim///      _MM_EXCEPT_DENORM, _MM_EXCEPT_OVERFLOW, _MM_EXCEPT_UNDERFLOW,
2517309124Sdim///      _MM_EXCEPT_INEXACT. There is a convenience wrapper
2518309124Sdim///      _MM_SET_EXCEPTION_STATE(x) where x is one of these macros.
2519314564Sdim///    </li>
2520314564Sdim///    <li>
2521314564Sdim///      For setting exception masks: _MM_MASK_UNDERFLOW, _MM_MASK_OVERFLOW,
2522309124Sdim///      _MM_MASK_INVALID, _MM_MASK_DENORM, _MM_MASK_DIV_ZERO, _MM_MASK_INEXACT.
2523309124Sdim///      There is a convenience wrapper _MM_SET_EXCEPTION_MASK(x) where x is one
2524309124Sdim///      of these macros.
2525314564Sdim///    </li>
2526314564Sdim///    <li>
2527314564Sdim///      For setting rounding modes: _MM_ROUND_NEAREST, _MM_ROUND_DOWN,
2528309124Sdim///      _MM_ROUND_UP, _MM_ROUND_TOWARD_ZERO. There is a convenience wrapper
2529309124Sdim///      _MM_SET_ROUNDING_MODE(x) where x is one of these macros.
2530314564Sdim///    </li>
2531314564Sdim///    <li>
2532314564Sdim///      For setting flush-to-zero mode: _MM_FLUSH_ZERO_ON, _MM_FLUSH_ZERO_OFF.
2533309124Sdim///      There is a convenience wrapper _MM_SET_FLUSH_ZERO_MODE(x) where x is
2534309124Sdim///      one of these macros.
2535314564Sdim///    </li>
2536314564Sdim///    <li>
2537314564Sdim///      For setting denormals-are-zero mode: _MM_DENORMALS_ZERO_ON,
2538309124Sdim///      _MM_DENORMALS_ZERO_OFF. There is a convenience wrapper
2539309124Sdim///      _MM_SET_DENORMALS_ZERO_MODE(x) where x is one of these macros.
2540314564Sdim///    </li>
2541314564Sdim///    </ul>
2542309124Sdim///
2543309124Sdim///    For example, the following expression causes subsequent floating-point
2544309124Sdim///    operations to round up:
2545309124Sdim///      _mm_setcsr(_mm_getcsr() | _MM_ROUND_UP)
2546309124Sdim///
2547309124Sdim///    The following example sets the DAZ and FTZ flags:
2548341825Sdim///    \code
2549341825Sdim///    void setFlags() {
2550341825Sdim///      _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
2551341825Sdim///      _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
2552341825Sdim///    }
2553341825Sdim///    \endcode
2554309124Sdim///
2555309124Sdim/// \headerfile <x86intrin.h>
2556309124Sdim///
2557314564Sdim/// This intrinsic corresponds to the <c> VLDMXCSR / LDMXCSR </c> instruction.
2558309124Sdim///
2559309124Sdim/// \param __i
2560309124Sdim///    A 32-bit unsigned integer value to be written to the MXCSR register.
2561321369Sdimvoid _mm_setcsr(unsigned int __i);
2562193326Sed
2563314564Sdim#if defined(__cplusplus)
2564314564Sdim} // extern "C"
2565314564Sdim#endif
2566314564Sdim
2567341825Sdim/// Selects 4 float values from the 128-bit operands of [4 x float], as
2568309124Sdim///    specified by the immediate value operand.
2569309124Sdim///
2570309124Sdim/// \headerfile <x86intrin.h>
2571309124Sdim///
2572309124Sdim/// \code
2573309124Sdim/// __m128 _mm_shuffle_ps(__m128 a, __m128 b, const int mask);
2574309124Sdim/// \endcode
2575309124Sdim///
2576314564Sdim/// This intrinsic corresponds to the <c> VSHUFPS / SHUFPS </c> instruction.
2577309124Sdim///
2578309124Sdim/// \param a
2579309124Sdim///    A 128-bit vector of [4 x float].
2580309124Sdim/// \param b
2581309124Sdim///    A 128-bit vector of [4 x float].
2582309124Sdim/// \param mask
2583309124Sdim///    An immediate value containing an 8-bit value specifying which elements to
2584321369Sdim///    copy from \a a and \a b. \n
2585314564Sdim///    Bits [3:0] specify the values copied from operand \a a. \n
2586314564Sdim///    Bits [7:4] specify the values copied from operand \a b. \n
2587314564Sdim///    The destinations within the 128-bit destination are assigned values as
2588314564Sdim///    follows: \n
2589314564Sdim///    Bits [1:0] are used to assign values to bits [31:0] in the
2590314564Sdim///    destination. \n
2591314564Sdim///    Bits [3:2] are used to assign values to bits [63:32] in the
2592314564Sdim///    destination. \n
2593314564Sdim///    Bits [5:4] are used to assign values to bits [95:64] in the
2594314564Sdim///    destination. \n
2595314564Sdim///    Bits [7:6] are used to assign values to bits [127:96] in the
2596314564Sdim///    destination. \n
2597314564Sdim///    Bit value assignments: \n
2598314564Sdim///    00: Bits [31:0] copied from the specified operand. \n
2599314564Sdim///    01: Bits [63:32] copied from the specified operand. \n
2600314564Sdim///    10: Bits [95:64] copied from the specified operand. \n
2601309124Sdim///    11: Bits [127:96] copied from the specified operand.
2602309124Sdim/// \returns A 128-bit vector of [4 x float] containing the shuffled values.
2603341825Sdim#define _mm_shuffle_ps(a, b, mask) \
2604341825Sdim  (__m128)__builtin_ia32_shufps((__v4sf)(__m128)(a), (__v4sf)(__m128)(b), \
2605341825Sdim                                (int)(mask))
2606193326Sed
2607341825Sdim/// Unpacks the high-order (index 2,3) values from two 128-bit vectors of
2608314564Sdim///    [4 x float] and interleaves them into a 128-bit vector of [4 x float].
2609309124Sdim///
2610309124Sdim/// \headerfile <x86intrin.h>
2611309124Sdim///
2612314564Sdim/// This intrinsic corresponds to the <c> VUNPCKHPS / UNPCKHPS </c> instruction.
2613309124Sdim///
2614309124Sdim/// \param __a
2615314564Sdim///    A 128-bit vector of [4 x float]. \n
2616314564Sdim///    Bits [95:64] are written to bits [31:0] of the destination. \n
2617309124Sdim///    Bits [127:96] are written to bits [95:64] of the destination.
2618309124Sdim/// \param __b
2619309124Sdim///    A 128-bit vector of [4 x float].
2620314564Sdim///    Bits [95:64] are written to bits [63:32] of the destination. \n
2621309124Sdim///    Bits [127:96] are written to bits [127:96] of the destination.
2622309124Sdim/// \returns A 128-bit vector of [4 x float] containing the interleaved values.
2623288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
2624249423Sdim_mm_unpackhi_ps(__m128 __a, __m128 __b)
2625193326Sed{
2626309124Sdim  return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 2, 6, 3, 7);
2627193326Sed}
2628193326Sed
2629341825Sdim/// Unpacks the low-order (index 0,1) values from two 128-bit vectors of
2630314564Sdim///    [4 x float] and interleaves them into a 128-bit vector of [4 x float].
2631309124Sdim///
2632309124Sdim/// \headerfile <x86intrin.h>
2633309124Sdim///
2634314564Sdim/// This intrinsic corresponds to the <c> VUNPCKLPS / UNPCKLPS </c> instruction.
2635309124Sdim///
2636309124Sdim/// \param __a
2637314564Sdim///    A 128-bit vector of [4 x float]. \n
2638314564Sdim///    Bits [31:0] are written to bits [31:0] of the destination.  \n
2639309124Sdim///    Bits [63:32] are written to bits [95:64] of the destination.
2640309124Sdim/// \param __b
2641314564Sdim///    A 128-bit vector of [4 x float]. \n
2642314564Sdim///    Bits [31:0] are written to bits [63:32] of the destination. \n
2643309124Sdim///    Bits [63:32] are written to bits [127:96] of the destination.
2644309124Sdim/// \returns A 128-bit vector of [4 x float] containing the interleaved values.
2645288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
2646249423Sdim_mm_unpacklo_ps(__m128 __a, __m128 __b)
2647193326Sed{
2648309124Sdim  return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 0, 4, 1, 5);
2649193326Sed}
2650193326Sed
2651341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float]. The lower
2652309124Sdim///    32 bits are set to the lower 32 bits of the second parameter. The upper
2653309124Sdim///    96 bits are set to the upper 96 bits of the first parameter.
2654309124Sdim///
2655309124Sdim/// \headerfile <x86intrin.h>
2656309124Sdim///
2657341825Sdim/// This intrinsic corresponds to the <c> VBLENDPS / BLENDPS / MOVSS </c>
2658341825Sdim///    instruction.
2659309124Sdim///
2660309124Sdim/// \param __a
2661309124Sdim///    A 128-bit floating-point vector of [4 x float]. The upper 96 bits are
2662309124Sdim///    written to the upper 96 bits of the result.
2663309124Sdim/// \param __b
2664309124Sdim///    A 128-bit floating-point vector of [4 x float]. The lower 32 bits are
2665309124Sdim///    written to the lower 32 bits of the result.
2666309124Sdim/// \returns A 128-bit floating-point vector of [4 x float].
2667288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
2668249423Sdim_mm_move_ss(__m128 __a, __m128 __b)
2669193326Sed{
2670341825Sdim  __a[0] = __b[0];
2671341825Sdim  return __a;
2672193326Sed}
2673193326Sed
2674341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float]. The lower
2675309124Sdim///    64 bits are set to the upper 64 bits of the second parameter. The upper
2676309124Sdim///    64 bits are set to the upper 64 bits of the first parameter.
2677309124Sdim///
2678309124Sdim/// \headerfile <x86intrin.h>
2679309124Sdim///
2680314564Sdim/// This intrinsic corresponds to the <c> VUNPCKHPD / UNPCKHPD </c> instruction.
2681309124Sdim///
2682309124Sdim/// \param __a
2683309124Sdim///    A 128-bit floating-point vector of [4 x float]. The upper 64 bits are
2684309124Sdim///    written to the upper 64 bits of the result.
2685309124Sdim/// \param __b
2686309124Sdim///    A 128-bit floating-point vector of [4 x float]. The upper 64 bits are
2687309124Sdim///    written to the lower 64 bits of the result.
2688309124Sdim/// \returns A 128-bit floating-point vector of [4 x float].
2689288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
2690249423Sdim_mm_movehl_ps(__m128 __a, __m128 __b)
2691193326Sed{
2692309124Sdim  return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 6, 7, 2, 3);
2693193326Sed}
2694193326Sed
2695341825Sdim/// Constructs a 128-bit floating-point vector of [4 x float]. The lower
2696309124Sdim///    64 bits are set to the lower 64 bits of the first parameter. The upper
2697309124Sdim///    64 bits are set to the lower 64 bits of the second parameter.
2698309124Sdim///
2699309124Sdim/// \headerfile <x86intrin.h>
2700309124Sdim///
2701314564Sdim/// This intrinsic corresponds to the <c> VUNPCKLPD / UNPCKLPD </c> instruction.
2702309124Sdim///
2703309124Sdim/// \param __a
2704309124Sdim///    A 128-bit floating-point vector of [4 x float]. The lower 64 bits are
2705309124Sdim///    written to the lower 64 bits of the result.
2706309124Sdim/// \param __b
2707309124Sdim///    A 128-bit floating-point vector of [4 x float]. The lower 64 bits are
2708309124Sdim///    written to the upper 64 bits of the result.
2709309124Sdim/// \returns A 128-bit floating-point vector of [4 x float].
2710288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
2711249423Sdim_mm_movelh_ps(__m128 __a, __m128 __b)
2712193326Sed{
2713309124Sdim  return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 0, 1, 4, 5);
2714193326Sed}
2715193326Sed
2716341825Sdim/// Converts a 64-bit vector of [4 x i16] into a 128-bit vector of [4 x
2717309124Sdim///    float].
2718309124Sdim///
2719309124Sdim/// \headerfile <x86intrin.h>
2720309124Sdim///
2721321369Sdim/// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
2722309124Sdim///
2723309124Sdim/// \param __a
2724309124Sdim///    A 64-bit vector of [4 x i16]. The elements of the destination are copied
2725309124Sdim///    from the corresponding elements in this operand.
2726309124Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and converted
2727309124Sdim///    values from the operand.
2728341825Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
2729249423Sdim_mm_cvtpi16_ps(__m64 __a)
2730193326Sed{
2731249423Sdim  __m64 __b, __c;
2732249423Sdim  __m128 __r;
2733193326Sed
2734249423Sdim  __b = _mm_setzero_si64();
2735249423Sdim  __b = _mm_cmpgt_pi16(__b, __a);
2736249423Sdim  __c = _mm_unpackhi_pi16(__a, __b);
2737249423Sdim  __r = _mm_setzero_ps();
2738249423Sdim  __r = _mm_cvtpi32_ps(__r, __c);
2739249423Sdim  __r = _mm_movelh_ps(__r, __r);
2740249423Sdim  __c = _mm_unpacklo_pi16(__a, __b);
2741249423Sdim  __r = _mm_cvtpi32_ps(__r, __c);
2742193326Sed
2743249423Sdim  return __r;
2744193326Sed}
2745193326Sed
2746341825Sdim/// Converts a 64-bit vector of 16-bit unsigned integer values into a
2747309124Sdim///    128-bit vector of [4 x float].
2748309124Sdim///
2749309124Sdim/// \headerfile <x86intrin.h>
2750309124Sdim///
2751321369Sdim/// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
2752309124Sdim///
2753309124Sdim/// \param __a
2754309124Sdim///    A 64-bit vector of 16-bit unsigned integer values. The elements of the
2755309124Sdim///    destination are copied from the corresponding elements in this operand.
2756309124Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and converted
2757309124Sdim///    values from the operand.
2758341825Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
2759249423Sdim_mm_cvtpu16_ps(__m64 __a)
2760193326Sed{
2761249423Sdim  __m64 __b, __c;
2762249423Sdim  __m128 __r;
2763193326Sed
2764249423Sdim  __b = _mm_setzero_si64();
2765249423Sdim  __c = _mm_unpackhi_pi16(__a, __b);
2766249423Sdim  __r = _mm_setzero_ps();
2767249423Sdim  __r = _mm_cvtpi32_ps(__r, __c);
2768249423Sdim  __r = _mm_movelh_ps(__r, __r);
2769249423Sdim  __c = _mm_unpacklo_pi16(__a, __b);
2770249423Sdim  __r = _mm_cvtpi32_ps(__r, __c);
2771193326Sed
2772249423Sdim  return __r;
2773193326Sed}
2774193326Sed
2775341825Sdim/// Converts the lower four 8-bit values from a 64-bit vector of [8 x i8]
2776309124Sdim///    into a 128-bit vector of [4 x float].
2777309124Sdim///
2778309124Sdim/// \headerfile <x86intrin.h>
2779309124Sdim///
2780321369Sdim/// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
2781309124Sdim///
2782309124Sdim/// \param __a
2783309124Sdim///    A 64-bit vector of [8 x i8]. The elements of the destination are copied
2784309124Sdim///    from the corresponding lower 4 elements in this operand.
2785309124Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and converted
2786309124Sdim///    values from the operand.
2787341825Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
2788249423Sdim_mm_cvtpi8_ps(__m64 __a)
2789193326Sed{
2790249423Sdim  __m64 __b;
2791296417Sdim
2792249423Sdim  __b = _mm_setzero_si64();
2793249423Sdim  __b = _mm_cmpgt_pi8(__b, __a);
2794249423Sdim  __b = _mm_unpacklo_pi8(__a, __b);
2795193326Sed
2796249423Sdim  return _mm_cvtpi16_ps(__b);
2797193326Sed}
2798193326Sed
2799341825Sdim/// Converts the lower four unsigned 8-bit integer values from a 64-bit
2800309124Sdim///    vector of [8 x u8] into a 128-bit vector of [4 x float].
2801309124Sdim///
2802309124Sdim/// \headerfile <x86intrin.h>
2803309124Sdim///
2804321369Sdim/// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
2805309124Sdim///
2806309124Sdim/// \param __a
2807309124Sdim///    A 64-bit vector of unsigned 8-bit integer values. The elements of the
2808309124Sdim///    destination are copied from the corresponding lower 4 elements in this
2809309124Sdim///    operand.
2810309124Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and converted
2811309124Sdim///    values from the source operand.
2812341825Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
2813249423Sdim_mm_cvtpu8_ps(__m64 __a)
2814193326Sed{
2815249423Sdim  __m64 __b;
2816296417Sdim
2817249423Sdim  __b = _mm_setzero_si64();
2818249423Sdim  __b = _mm_unpacklo_pi8(__a, __b);
2819193326Sed
2820249423Sdim  return _mm_cvtpi16_ps(__b);
2821193326Sed}
2822193326Sed
2823341825Sdim/// Converts the two 32-bit signed integer values from each 64-bit vector
2824309124Sdim///    operand of [2 x i32] into a 128-bit vector of [4 x float].
2825309124Sdim///
2826309124Sdim/// \headerfile <x86intrin.h>
2827309124Sdim///
2828321369Sdim/// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
2829309124Sdim///
2830309124Sdim/// \param __a
2831309124Sdim///    A 64-bit vector of [2 x i32]. The lower elements of the destination are
2832309124Sdim///    copied from the elements in this operand.
2833309124Sdim/// \param __b
2834309124Sdim///    A 64-bit vector of [2 x i32]. The upper elements of the destination are
2835309124Sdim///    copied from the elements in this operand.
2836309124Sdim/// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the
2837309124Sdim///    copied and converted values from the first operand. The upper 64 bits
2838309124Sdim///    contain the copied and converted values from the second operand.
2839341825Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
2840249423Sdim_mm_cvtpi32x2_ps(__m64 __a, __m64 __b)
2841193326Sed{
2842249423Sdim  __m128 __c;
2843296417Sdim
2844249423Sdim  __c = _mm_setzero_ps();
2845249423Sdim  __c = _mm_cvtpi32_ps(__c, __b);
2846249423Sdim  __c = _mm_movelh_ps(__c, __c);
2847193326Sed
2848249423Sdim  return _mm_cvtpi32_ps(__c, __a);
2849193326Sed}
2850193326Sed
2851341825Sdim/// Converts each single-precision floating-point element of a 128-bit
2852309124Sdim///    floating-point vector of [4 x float] into a 16-bit signed integer, and
2853321369Sdim///    packs the results into a 64-bit integer vector of [4 x i16].
2854309124Sdim///
2855321369Sdim///    If the floating-point element is NaN or infinity, or if the
2856321369Sdim///    floating-point element is greater than 0x7FFFFFFF or less than -0x8000,
2857321369Sdim///    it is converted to 0x8000. Otherwise if the floating-point element is
2858321369Sdim///    greater than 0x7FFF, it is converted to 0x7FFF.
2859321369Sdim///
2860309124Sdim/// \headerfile <x86intrin.h>
2861309124Sdim///
2862321369Sdim/// This intrinsic corresponds to the <c> CVTPS2PI + COMPOSITE </c> instruction.
2863309124Sdim///
2864309124Sdim/// \param __a
2865309124Sdim///    A 128-bit floating-point vector of [4 x float].
2866309124Sdim/// \returns A 64-bit integer vector of [4 x i16] containing the converted
2867309124Sdim///    values.
2868341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2869249423Sdim_mm_cvtps_pi16(__m128 __a)
2870193326Sed{
2871249423Sdim  __m64 __b, __c;
2872296417Sdim
2873249423Sdim  __b = _mm_cvtps_pi32(__a);
2874249423Sdim  __a = _mm_movehl_ps(__a, __a);
2875249423Sdim  __c = _mm_cvtps_pi32(__a);
2876296417Sdim
2877266674Sdim  return _mm_packs_pi32(__b, __c);
2878193326Sed}
2879193326Sed
2880341825Sdim/// Converts each single-precision floating-point element of a 128-bit
2881309124Sdim///    floating-point vector of [4 x float] into an 8-bit signed integer, and
2882309124Sdim///    packs the results into the lower 32 bits of a 64-bit integer vector of
2883321369Sdim///    [8 x i8]. The upper 32 bits of the vector are set to 0.
2884309124Sdim///
2885321369Sdim///    If the floating-point element is NaN or infinity, or if the
2886321369Sdim///    floating-point element is greater than 0x7FFFFFFF or less than -0x80, it
2887321369Sdim///    is converted to 0x80. Otherwise if the floating-point element is greater
2888321369Sdim///    than 0x7F, it is converted to 0x7F.
2889321369Sdim///
2890309124Sdim/// \headerfile <x86intrin.h>
2891309124Sdim///
2892321369Sdim/// This intrinsic corresponds to the <c> CVTPS2PI + COMPOSITE </c> instruction.
2893309124Sdim///
2894309124Sdim/// \param __a
2895309124Sdim///    128-bit floating-point vector of [4 x float].
2896309124Sdim/// \returns A 64-bit integer vector of [8 x i8]. The lower 32 bits contain the
2897309124Sdim///    converted values and the uppper 32 bits are set to zero.
2898341825Sdimstatic __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
2899249423Sdim_mm_cvtps_pi8(__m128 __a)
2900193326Sed{
2901249423Sdim  __m64 __b, __c;
2902296417Sdim
2903249423Sdim  __b = _mm_cvtps_pi16(__a);
2904249423Sdim  __c = _mm_setzero_si64();
2905296417Sdim
2906249423Sdim  return _mm_packs_pi16(__b, __c);
2907193326Sed}
2908193326Sed
2909341825Sdim/// Extracts the sign bits from each single-precision floating-point
2910309124Sdim///    element of a 128-bit floating-point vector of [4 x float] and returns the
2911309124Sdim///    sign bits in bits [0:3] of the result. Bits [31:4] of the result are set
2912309124Sdim///    to zero.
2913309124Sdim///
2914309124Sdim/// \headerfile <x86intrin.h>
2915309124Sdim///
2916314564Sdim/// This intrinsic corresponds to the <c> VMOVMSKPS / MOVMSKPS </c> instruction.
2917309124Sdim///
2918309124Sdim/// \param __a
2919309124Sdim///    A 128-bit floating-point vector of [4 x float].
2920309124Sdim/// \returns A 32-bit integer value. Bits [3:0] contain the sign bits from each
2921309124Sdim///    single-precision floating-point element of the parameter. Bits [31:4] are
2922309124Sdim///    set to zero.
2923288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
2924249423Sdim_mm_movemask_ps(__m128 __a)
2925193326Sed{
2926309124Sdim  return __builtin_ia32_movmskps((__v4sf)__a);
2927193326Sed}
2928193326Sed
2929296417Sdim
2930309124Sdim#define _MM_ALIGN16 __attribute__((aligned(16)))
2931296417Sdim
2932193326Sed#define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
2933193326Sed
2934193326Sed#define _MM_EXCEPT_INVALID    (0x0001)
2935193326Sed#define _MM_EXCEPT_DENORM     (0x0002)
2936193326Sed#define _MM_EXCEPT_DIV_ZERO   (0x0004)
2937193326Sed#define _MM_EXCEPT_OVERFLOW   (0x0008)
2938193326Sed#define _MM_EXCEPT_UNDERFLOW  (0x0010)
2939193326Sed#define _MM_EXCEPT_INEXACT    (0x0020)
2940193326Sed#define _MM_EXCEPT_MASK       (0x003f)
2941193326Sed
2942193326Sed#define _MM_MASK_INVALID      (0x0080)
2943193326Sed#define _MM_MASK_DENORM       (0x0100)
2944193326Sed#define _MM_MASK_DIV_ZERO     (0x0200)
2945193326Sed#define _MM_MASK_OVERFLOW     (0x0400)
2946193326Sed#define _MM_MASK_UNDERFLOW    (0x0800)
2947193326Sed#define _MM_MASK_INEXACT      (0x1000)
2948193326Sed#define _MM_MASK_MASK         (0x1f80)
2949193326Sed
2950193326Sed#define _MM_ROUND_NEAREST     (0x0000)
2951193326Sed#define _MM_ROUND_DOWN        (0x2000)
2952193326Sed#define _MM_ROUND_UP          (0x4000)
2953193326Sed#define _MM_ROUND_TOWARD_ZERO (0x6000)
2954193326Sed#define _MM_ROUND_MASK        (0x6000)
2955193326Sed
2956193326Sed#define _MM_FLUSH_ZERO_MASK   (0x8000)
2957193326Sed#define _MM_FLUSH_ZERO_ON     (0x8000)
2958234353Sdim#define _MM_FLUSH_ZERO_OFF    (0x0000)
2959193326Sed
2960193326Sed#define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK)
2961193326Sed#define _MM_GET_EXCEPTION_STATE() (_mm_getcsr() & _MM_EXCEPT_MASK)
2962193326Sed#define _MM_GET_FLUSH_ZERO_MODE() (_mm_getcsr() & _MM_FLUSH_ZERO_MASK)
2963193326Sed#define _MM_GET_ROUNDING_MODE() (_mm_getcsr() & _MM_ROUND_MASK)
2964193326Sed
2965193326Sed#define _MM_SET_EXCEPTION_MASK(x) (_mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | (x)))
2966193326Sed#define _MM_SET_EXCEPTION_STATE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | (x)))
2967193326Sed#define _MM_SET_FLUSH_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | (x)))
2968193326Sed#define _MM_SET_ROUNDING_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | (x)))
2969193326Sed
2970193326Sed#define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) \
2971193326Seddo { \
2972193326Sed  __m128 tmp3, tmp2, tmp1, tmp0; \
2973193326Sed  tmp0 = _mm_unpacklo_ps((row0), (row1)); \
2974193326Sed  tmp2 = _mm_unpacklo_ps((row2), (row3)); \
2975193326Sed  tmp1 = _mm_unpackhi_ps((row0), (row1)); \
2976193326Sed  tmp3 = _mm_unpackhi_ps((row2), (row3)); \
2977193326Sed  (row0) = _mm_movelh_ps(tmp0, tmp2); \
2978193326Sed  (row1) = _mm_movehl_ps(tmp2, tmp0); \
2979193326Sed  (row2) = _mm_movelh_ps(tmp1, tmp3); \
2980203955Srdivacky  (row3) = _mm_movehl_ps(tmp3, tmp1); \
2981193326Sed} while (0)
2982193326Sed
2983212904Sdim/* Aliases for compatibility. */
2984212904Sdim#define _m_pextrw _mm_extract_pi16
2985212904Sdim#define _m_pinsrw _mm_insert_pi16
2986212904Sdim#define _m_pmaxsw _mm_max_pi16
2987212904Sdim#define _m_pmaxub _mm_max_pu8
2988212904Sdim#define _m_pminsw _mm_min_pi16
2989212904Sdim#define _m_pminub _mm_min_pu8
2990212904Sdim#define _m_pmovmskb _mm_movemask_pi8
2991212904Sdim#define _m_pmulhuw _mm_mulhi_pu16
2992212904Sdim#define _m_pshufw _mm_shuffle_pi16
2993212904Sdim#define _m_maskmovq _mm_maskmove_si64
2994212904Sdim#define _m_pavgb _mm_avg_pu8
2995212904Sdim#define _m_pavgw _mm_avg_pu16
2996212904Sdim#define _m_psadbw _mm_sad_pu8
2997212904Sdim#define _m_ _mm_
2998212904Sdim#define _m_ _mm_
2999212904Sdim
3000288943Sdim#undef __DEFAULT_FN_ATTRS
3001341825Sdim#undef __DEFAULT_FN_ATTRS_MMX
3002288943Sdim
3003194179Sed/* Ugly hack for backwards-compatibility (compatible with gcc) */
3004309124Sdim#if defined(__SSE2__) && !__building_module(_Builtin_intrinsics)
3005193326Sed#include <emmintrin.h>
3006194179Sed#endif
3007193326Sed
3008193326Sed#endif /* __XMMINTRIN_H */
3009