1*f4a2713aSLionel Sambuc /*===---- fma4intrin.h - FMA4 intrinsics -----------------------------------===
2*f4a2713aSLionel Sambuc *
3*f4a2713aSLionel Sambuc * Permission is hereby granted, free of charge, to any person obtaining a copy
4*f4a2713aSLionel Sambuc * of this software and associated documentation files (the "Software"), to deal
5*f4a2713aSLionel Sambuc * in the Software without restriction, including without limitation the rights
6*f4a2713aSLionel Sambuc * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7*f4a2713aSLionel Sambuc * copies of the Software, and to permit persons to whom the Software is
8*f4a2713aSLionel Sambuc * furnished to do so, subject to the following conditions:
9*f4a2713aSLionel Sambuc *
10*f4a2713aSLionel Sambuc * The above copyright notice and this permission notice shall be included in
11*f4a2713aSLionel Sambuc * all copies or substantial portions of the Software.
12*f4a2713aSLionel Sambuc *
13*f4a2713aSLionel Sambuc * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14*f4a2713aSLionel Sambuc * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15*f4a2713aSLionel Sambuc * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16*f4a2713aSLionel Sambuc * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17*f4a2713aSLionel Sambuc * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18*f4a2713aSLionel Sambuc * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19*f4a2713aSLionel Sambuc * THE SOFTWARE.
20*f4a2713aSLionel Sambuc *
21*f4a2713aSLionel Sambuc *===-----------------------------------------------------------------------===
22*f4a2713aSLionel Sambuc */
23*f4a2713aSLionel Sambuc
24*f4a2713aSLionel Sambuc #ifndef __IMMINTRIN_H
25*f4a2713aSLionel Sambuc #error "Never use <fmaintrin.h> directly; include <immintrin.h> instead."
26*f4a2713aSLionel Sambuc #endif
27*f4a2713aSLionel Sambuc
28*f4a2713aSLionel Sambuc #ifndef __FMAINTRIN_H
29*f4a2713aSLionel Sambuc #define __FMAINTRIN_H
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc #ifndef __FMA__
32*f4a2713aSLionel Sambuc # error "FMA instruction set is not enabled"
33*f4a2713aSLionel Sambuc #else
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fmadd_ps(__m128 __A,__m128 __B,__m128 __C)36*f4a2713aSLionel Sambuc _mm_fmadd_ps(__m128 __A, __m128 __B, __m128 __C)
37*f4a2713aSLionel Sambuc {
38*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfmaddps(__A, __B, __C);
39*f4a2713aSLionel Sambuc }
40*f4a2713aSLionel Sambuc
41*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fmadd_pd(__m128d __A,__m128d __B,__m128d __C)42*f4a2713aSLionel Sambuc _mm_fmadd_pd(__m128d __A, __m128d __B, __m128d __C)
43*f4a2713aSLionel Sambuc {
44*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfmaddpd(__A, __B, __C);
45*f4a2713aSLionel Sambuc }
46*f4a2713aSLionel Sambuc
47*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fmadd_ss(__m128 __A,__m128 __B,__m128 __C)48*f4a2713aSLionel Sambuc _mm_fmadd_ss(__m128 __A, __m128 __B, __m128 __C)
49*f4a2713aSLionel Sambuc {
50*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfmaddss(__A, __B, __C);
51*f4a2713aSLionel Sambuc }
52*f4a2713aSLionel Sambuc
53*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fmadd_sd(__m128d __A,__m128d __B,__m128d __C)54*f4a2713aSLionel Sambuc _mm_fmadd_sd(__m128d __A, __m128d __B, __m128d __C)
55*f4a2713aSLionel Sambuc {
56*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfmaddsd(__A, __B, __C);
57*f4a2713aSLionel Sambuc }
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fmsub_ps(__m128 __A,__m128 __B,__m128 __C)60*f4a2713aSLionel Sambuc _mm_fmsub_ps(__m128 __A, __m128 __B, __m128 __C)
61*f4a2713aSLionel Sambuc {
62*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfmsubps(__A, __B, __C);
63*f4a2713aSLionel Sambuc }
64*f4a2713aSLionel Sambuc
65*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fmsub_pd(__m128d __A,__m128d __B,__m128d __C)66*f4a2713aSLionel Sambuc _mm_fmsub_pd(__m128d __A, __m128d __B, __m128d __C)
67*f4a2713aSLionel Sambuc {
68*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfmsubpd(__A, __B, __C);
69*f4a2713aSLionel Sambuc }
70*f4a2713aSLionel Sambuc
71*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fmsub_ss(__m128 __A,__m128 __B,__m128 __C)72*f4a2713aSLionel Sambuc _mm_fmsub_ss(__m128 __A, __m128 __B, __m128 __C)
73*f4a2713aSLionel Sambuc {
74*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfmsubss(__A, __B, __C);
75*f4a2713aSLionel Sambuc }
76*f4a2713aSLionel Sambuc
77*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fmsub_sd(__m128d __A,__m128d __B,__m128d __C)78*f4a2713aSLionel Sambuc _mm_fmsub_sd(__m128d __A, __m128d __B, __m128d __C)
79*f4a2713aSLionel Sambuc {
80*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfmsubsd(__A, __B, __C);
81*f4a2713aSLionel Sambuc }
82*f4a2713aSLionel Sambuc
83*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fnmadd_ps(__m128 __A,__m128 __B,__m128 __C)84*f4a2713aSLionel Sambuc _mm_fnmadd_ps(__m128 __A, __m128 __B, __m128 __C)
85*f4a2713aSLionel Sambuc {
86*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfnmaddps(__A, __B, __C);
87*f4a2713aSLionel Sambuc }
88*f4a2713aSLionel Sambuc
89*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fnmadd_pd(__m128d __A,__m128d __B,__m128d __C)90*f4a2713aSLionel Sambuc _mm_fnmadd_pd(__m128d __A, __m128d __B, __m128d __C)
91*f4a2713aSLionel Sambuc {
92*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfnmaddpd(__A, __B, __C);
93*f4a2713aSLionel Sambuc }
94*f4a2713aSLionel Sambuc
95*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fnmadd_ss(__m128 __A,__m128 __B,__m128 __C)96*f4a2713aSLionel Sambuc _mm_fnmadd_ss(__m128 __A, __m128 __B, __m128 __C)
97*f4a2713aSLionel Sambuc {
98*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfnmaddss(__A, __B, __C);
99*f4a2713aSLionel Sambuc }
100*f4a2713aSLionel Sambuc
101*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fnmadd_sd(__m128d __A,__m128d __B,__m128d __C)102*f4a2713aSLionel Sambuc _mm_fnmadd_sd(__m128d __A, __m128d __B, __m128d __C)
103*f4a2713aSLionel Sambuc {
104*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfnmaddsd(__A, __B, __C);
105*f4a2713aSLionel Sambuc }
106*f4a2713aSLionel Sambuc
107*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fnmsub_ps(__m128 __A,__m128 __B,__m128 __C)108*f4a2713aSLionel Sambuc _mm_fnmsub_ps(__m128 __A, __m128 __B, __m128 __C)
109*f4a2713aSLionel Sambuc {
110*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfnmsubps(__A, __B, __C);
111*f4a2713aSLionel Sambuc }
112*f4a2713aSLionel Sambuc
113*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fnmsub_pd(__m128d __A,__m128d __B,__m128d __C)114*f4a2713aSLionel Sambuc _mm_fnmsub_pd(__m128d __A, __m128d __B, __m128d __C)
115*f4a2713aSLionel Sambuc {
116*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfnmsubpd(__A, __B, __C);
117*f4a2713aSLionel Sambuc }
118*f4a2713aSLionel Sambuc
119*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fnmsub_ss(__m128 __A,__m128 __B,__m128 __C)120*f4a2713aSLionel Sambuc _mm_fnmsub_ss(__m128 __A, __m128 __B, __m128 __C)
121*f4a2713aSLionel Sambuc {
122*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfnmsubss(__A, __B, __C);
123*f4a2713aSLionel Sambuc }
124*f4a2713aSLionel Sambuc
125*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fnmsub_sd(__m128d __A,__m128d __B,__m128d __C)126*f4a2713aSLionel Sambuc _mm_fnmsub_sd(__m128d __A, __m128d __B, __m128d __C)
127*f4a2713aSLionel Sambuc {
128*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfnmsubsd(__A, __B, __C);
129*f4a2713aSLionel Sambuc }
130*f4a2713aSLionel Sambuc
131*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fmaddsub_ps(__m128 __A,__m128 __B,__m128 __C)132*f4a2713aSLionel Sambuc _mm_fmaddsub_ps(__m128 __A, __m128 __B, __m128 __C)
133*f4a2713aSLionel Sambuc {
134*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfmaddsubps(__A, __B, __C);
135*f4a2713aSLionel Sambuc }
136*f4a2713aSLionel Sambuc
137*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fmaddsub_pd(__m128d __A,__m128d __B,__m128d __C)138*f4a2713aSLionel Sambuc _mm_fmaddsub_pd(__m128d __A, __m128d __B, __m128d __C)
139*f4a2713aSLionel Sambuc {
140*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfmaddsubpd(__A, __B, __C);
141*f4a2713aSLionel Sambuc }
142*f4a2713aSLionel Sambuc
143*f4a2713aSLionel Sambuc static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_fmsubadd_ps(__m128 __A,__m128 __B,__m128 __C)144*f4a2713aSLionel Sambuc _mm_fmsubadd_ps(__m128 __A, __m128 __B, __m128 __C)
145*f4a2713aSLionel Sambuc {
146*f4a2713aSLionel Sambuc return (__m128)__builtin_ia32_vfmsubaddps(__A, __B, __C);
147*f4a2713aSLionel Sambuc }
148*f4a2713aSLionel Sambuc
149*f4a2713aSLionel Sambuc static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
_mm_fmsubadd_pd(__m128d __A,__m128d __B,__m128d __C)150*f4a2713aSLionel Sambuc _mm_fmsubadd_pd(__m128d __A, __m128d __B, __m128d __C)
151*f4a2713aSLionel Sambuc {
152*f4a2713aSLionel Sambuc return (__m128d)__builtin_ia32_vfmsubaddpd(__A, __B, __C);
153*f4a2713aSLionel Sambuc }
154*f4a2713aSLionel Sambuc
155*f4a2713aSLionel Sambuc static __inline__ __m256 __attribute__((__always_inline__, __nodebug__))
_mm256_fmadd_ps(__m256 __A,__m256 __B,__m256 __C)156*f4a2713aSLionel Sambuc _mm256_fmadd_ps(__m256 __A, __m256 __B, __m256 __C)
157*f4a2713aSLionel Sambuc {
158*f4a2713aSLionel Sambuc return (__m256)__builtin_ia32_vfmaddps256(__A, __B, __C);
159*f4a2713aSLionel Sambuc }
160*f4a2713aSLionel Sambuc
161*f4a2713aSLionel Sambuc static __inline__ __m256d __attribute__((__always_inline__, __nodebug__))
_mm256_fmadd_pd(__m256d __A,__m256d __B,__m256d __C)162*f4a2713aSLionel Sambuc _mm256_fmadd_pd(__m256d __A, __m256d __B, __m256d __C)
163*f4a2713aSLionel Sambuc {
164*f4a2713aSLionel Sambuc return (__m256d)__builtin_ia32_vfmaddpd256(__A, __B, __C);
165*f4a2713aSLionel Sambuc }
166*f4a2713aSLionel Sambuc
167*f4a2713aSLionel Sambuc static __inline__ __m256 __attribute__((__always_inline__, __nodebug__))
_mm256_fmsub_ps(__m256 __A,__m256 __B,__m256 __C)168*f4a2713aSLionel Sambuc _mm256_fmsub_ps(__m256 __A, __m256 __B, __m256 __C)
169*f4a2713aSLionel Sambuc {
170*f4a2713aSLionel Sambuc return (__m256)__builtin_ia32_vfmsubps256(__A, __B, __C);
171*f4a2713aSLionel Sambuc }
172*f4a2713aSLionel Sambuc
173*f4a2713aSLionel Sambuc static __inline__ __m256d __attribute__((__always_inline__, __nodebug__))
_mm256_fmsub_pd(__m256d __A,__m256d __B,__m256d __C)174*f4a2713aSLionel Sambuc _mm256_fmsub_pd(__m256d __A, __m256d __B, __m256d __C)
175*f4a2713aSLionel Sambuc {
176*f4a2713aSLionel Sambuc return (__m256d)__builtin_ia32_vfmsubpd256(__A, __B, __C);
177*f4a2713aSLionel Sambuc }
178*f4a2713aSLionel Sambuc
179*f4a2713aSLionel Sambuc static __inline__ __m256 __attribute__((__always_inline__, __nodebug__))
_mm256_fnmadd_ps(__m256 __A,__m256 __B,__m256 __C)180*f4a2713aSLionel Sambuc _mm256_fnmadd_ps(__m256 __A, __m256 __B, __m256 __C)
181*f4a2713aSLionel Sambuc {
182*f4a2713aSLionel Sambuc return (__m256)__builtin_ia32_vfnmaddps256(__A, __B, __C);
183*f4a2713aSLionel Sambuc }
184*f4a2713aSLionel Sambuc
185*f4a2713aSLionel Sambuc static __inline__ __m256d __attribute__((__always_inline__, __nodebug__))
_mm256_fnmadd_pd(__m256d __A,__m256d __B,__m256d __C)186*f4a2713aSLionel Sambuc _mm256_fnmadd_pd(__m256d __A, __m256d __B, __m256d __C)
187*f4a2713aSLionel Sambuc {
188*f4a2713aSLionel Sambuc return (__m256d)__builtin_ia32_vfnmaddpd256(__A, __B, __C);
189*f4a2713aSLionel Sambuc }
190*f4a2713aSLionel Sambuc
191*f4a2713aSLionel Sambuc static __inline__ __m256 __attribute__((__always_inline__, __nodebug__))
_mm256_fnmsub_ps(__m256 __A,__m256 __B,__m256 __C)192*f4a2713aSLionel Sambuc _mm256_fnmsub_ps(__m256 __A, __m256 __B, __m256 __C)
193*f4a2713aSLionel Sambuc {
194*f4a2713aSLionel Sambuc return (__m256)__builtin_ia32_vfnmsubps256(__A, __B, __C);
195*f4a2713aSLionel Sambuc }
196*f4a2713aSLionel Sambuc
197*f4a2713aSLionel Sambuc static __inline__ __m256d __attribute__((__always_inline__, __nodebug__))
_mm256_fnmsub_pd(__m256d __A,__m256d __B,__m256d __C)198*f4a2713aSLionel Sambuc _mm256_fnmsub_pd(__m256d __A, __m256d __B, __m256d __C)
199*f4a2713aSLionel Sambuc {
200*f4a2713aSLionel Sambuc return (__m256d)__builtin_ia32_vfnmsubpd256(__A, __B, __C);
201*f4a2713aSLionel Sambuc }
202*f4a2713aSLionel Sambuc
203*f4a2713aSLionel Sambuc static __inline__ __m256 __attribute__((__always_inline__, __nodebug__))
_mm256_fmaddsub_ps(__m256 __A,__m256 __B,__m256 __C)204*f4a2713aSLionel Sambuc _mm256_fmaddsub_ps(__m256 __A, __m256 __B, __m256 __C)
205*f4a2713aSLionel Sambuc {
206*f4a2713aSLionel Sambuc return (__m256)__builtin_ia32_vfmaddsubps256(__A, __B, __C);
207*f4a2713aSLionel Sambuc }
208*f4a2713aSLionel Sambuc
209*f4a2713aSLionel Sambuc static __inline__ __m256d __attribute__((__always_inline__, __nodebug__))
_mm256_fmaddsub_pd(__m256d __A,__m256d __B,__m256d __C)210*f4a2713aSLionel Sambuc _mm256_fmaddsub_pd(__m256d __A, __m256d __B, __m256d __C)
211*f4a2713aSLionel Sambuc {
212*f4a2713aSLionel Sambuc return (__m256d)__builtin_ia32_vfmaddsubpd256(__A, __B, __C);
213*f4a2713aSLionel Sambuc }
214*f4a2713aSLionel Sambuc
215*f4a2713aSLionel Sambuc static __inline__ __m256 __attribute__((__always_inline__, __nodebug__))
_mm256_fmsubadd_ps(__m256 __A,__m256 __B,__m256 __C)216*f4a2713aSLionel Sambuc _mm256_fmsubadd_ps(__m256 __A, __m256 __B, __m256 __C)
217*f4a2713aSLionel Sambuc {
218*f4a2713aSLionel Sambuc return (__m256)__builtin_ia32_vfmsubaddps256(__A, __B, __C);
219*f4a2713aSLionel Sambuc }
220*f4a2713aSLionel Sambuc
221*f4a2713aSLionel Sambuc static __inline__ __m256d __attribute__((__always_inline__, __nodebug__))
_mm256_fmsubadd_pd(__m256d __A,__m256d __B,__m256d __C)222*f4a2713aSLionel Sambuc _mm256_fmsubadd_pd(__m256d __A, __m256d __B, __m256d __C)
223*f4a2713aSLionel Sambuc {
224*f4a2713aSLionel Sambuc return (__m256d)__builtin_ia32_vfmsubaddpd256(__A, __B, __C);
225*f4a2713aSLionel Sambuc }
226*f4a2713aSLionel Sambuc
227*f4a2713aSLionel Sambuc #endif /* __FMA__ */
228*f4a2713aSLionel Sambuc
229*f4a2713aSLionel Sambuc #endif /* __FMAINTRIN_H */
230