fmaintrin.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /* Copyright (C) 2011-2019 Free Software Foundation, Inc.
  2. This file is part of GCC.
  3. GCC is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. GCC is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. Under Section 7 of GPL version 3, you are granted additional
  12. permissions described in the GCC Runtime Library Exception, version
  13. 3.1, as published by the Free Software Foundation.
  14. You should have received a copy of the GNU General Public License and
  15. a copy of the GCC Runtime Library Exception along with this program;
  16. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  17. <http://www.gnu.org/licenses/>. */
  18. #ifndef _IMMINTRIN_H_INCLUDED
  19. # error "Never use <fmaintrin.h> directly; include <immintrin.h> instead."
  20. #endif
  21. #ifndef _FMAINTRIN_H_INCLUDED
  22. #define _FMAINTRIN_H_INCLUDED
  23. #ifndef __FMA__
  24. #pragma GCC push_options
  25. #pragma GCC target("fma")
  26. #define __DISABLE_FMA__
  27. #endif /* __FMA__ */
  28. extern __inline __m128d
  29. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  30. _mm_fmadd_pd (__m128d __A, __m128d __B, __m128d __C)
  31. {
  32. return (__m128d)__builtin_ia32_vfmaddpd ((__v2df)__A, (__v2df)__B,
  33. (__v2df)__C);
  34. }
  35. extern __inline __m256d
  36. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  37. _mm256_fmadd_pd (__m256d __A, __m256d __B, __m256d __C)
  38. {
  39. return (__m256d)__builtin_ia32_vfmaddpd256 ((__v4df)__A, (__v4df)__B,
  40. (__v4df)__C);
  41. }
  42. extern __inline __m128
  43. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  44. _mm_fmadd_ps (__m128 __A, __m128 __B, __m128 __C)
  45. {
  46. return (__m128)__builtin_ia32_vfmaddps ((__v4sf)__A, (__v4sf)__B,
  47. (__v4sf)__C);
  48. }
  49. extern __inline __m256
  50. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  51. _mm256_fmadd_ps (__m256 __A, __m256 __B, __m256 __C)
  52. {
  53. return (__m256)__builtin_ia32_vfmaddps256 ((__v8sf)__A, (__v8sf)__B,
  54. (__v8sf)__C);
  55. }
  56. extern __inline __m128d
  57. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  58. _mm_fmadd_sd (__m128d __A, __m128d __B, __m128d __C)
  59. {
  60. return (__m128d) __builtin_ia32_vfmaddsd3 ((__v2df)__A, (__v2df)__B,
  61. (__v2df)__C);
  62. }
  63. extern __inline __m128
  64. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  65. _mm_fmadd_ss (__m128 __A, __m128 __B, __m128 __C)
  66. {
  67. return (__m128) __builtin_ia32_vfmaddss3 ((__v4sf)__A, (__v4sf)__B,
  68. (__v4sf)__C);
  69. }
  70. extern __inline __m128d
  71. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  72. _mm_fmsub_pd (__m128d __A, __m128d __B, __m128d __C)
  73. {
  74. return (__m128d)__builtin_ia32_vfmsubpd ((__v2df)__A, (__v2df)__B,
  75. (__v2df)__C);
  76. }
  77. extern __inline __m256d
  78. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  79. _mm256_fmsub_pd (__m256d __A, __m256d __B, __m256d __C)
  80. {
  81. return (__m256d)__builtin_ia32_vfmsubpd256 ((__v4df)__A, (__v4df)__B,
  82. (__v4df)__C);
  83. }
  84. extern __inline __m128
  85. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  86. _mm_fmsub_ps (__m128 __A, __m128 __B, __m128 __C)
  87. {
  88. return (__m128)__builtin_ia32_vfmsubps ((__v4sf)__A, (__v4sf)__B,
  89. (__v4sf)__C);
  90. }
  91. extern __inline __m256
  92. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  93. _mm256_fmsub_ps (__m256 __A, __m256 __B, __m256 __C)
  94. {
  95. return (__m256)__builtin_ia32_vfmsubps256 ((__v8sf)__A, (__v8sf)__B,
  96. (__v8sf)__C);
  97. }
  98. extern __inline __m128d
  99. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  100. _mm_fmsub_sd (__m128d __A, __m128d __B, __m128d __C)
  101. {
  102. return (__m128d)__builtin_ia32_vfmsubsd3 ((__v2df)__A, (__v2df)__B,
  103. (__v2df)__C);
  104. }
  105. extern __inline __m128
  106. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  107. _mm_fmsub_ss (__m128 __A, __m128 __B, __m128 __C)
  108. {
  109. return (__m128)__builtin_ia32_vfmsubss3 ((__v4sf)__A, (__v4sf)__B,
  110. (__v4sf)__C);
  111. }
  112. extern __inline __m128d
  113. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  114. _mm_fnmadd_pd (__m128d __A, __m128d __B, __m128d __C)
  115. {
  116. return (__m128d)__builtin_ia32_vfnmaddpd ((__v2df)__A, (__v2df)__B,
  117. (__v2df)__C);
  118. }
  119. extern __inline __m256d
  120. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  121. _mm256_fnmadd_pd (__m256d __A, __m256d __B, __m256d __C)
  122. {
  123. return (__m256d)__builtin_ia32_vfnmaddpd256 ((__v4df)__A, (__v4df)__B,
  124. (__v4df)__C);
  125. }
  126. extern __inline __m128
  127. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  128. _mm_fnmadd_ps (__m128 __A, __m128 __B, __m128 __C)
  129. {
  130. return (__m128)__builtin_ia32_vfnmaddps ((__v4sf)__A, (__v4sf)__B,
  131. (__v4sf)__C);
  132. }
  133. extern __inline __m256
  134. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  135. _mm256_fnmadd_ps (__m256 __A, __m256 __B, __m256 __C)
  136. {
  137. return (__m256)__builtin_ia32_vfnmaddps256 ((__v8sf)__A, (__v8sf)__B,
  138. (__v8sf)__C);
  139. }
  140. extern __inline __m128d
  141. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  142. _mm_fnmadd_sd (__m128d __A, __m128d __B, __m128d __C)
  143. {
  144. return (__m128d)__builtin_ia32_vfnmaddsd3 ((__v2df)__A, (__v2df)__B,
  145. (__v2df)__C);
  146. }
  147. extern __inline __m128
  148. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  149. _mm_fnmadd_ss (__m128 __A, __m128 __B, __m128 __C)
  150. {
  151. return (__m128)__builtin_ia32_vfnmaddss3 ((__v4sf)__A, (__v4sf)__B,
  152. (__v4sf)__C);
  153. }
  154. extern __inline __m128d
  155. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  156. _mm_fnmsub_pd (__m128d __A, __m128d __B, __m128d __C)
  157. {
  158. return (__m128d)__builtin_ia32_vfnmsubpd ((__v2df)__A, (__v2df)__B,
  159. (__v2df)__C);
  160. }
  161. extern __inline __m256d
  162. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  163. _mm256_fnmsub_pd (__m256d __A, __m256d __B, __m256d __C)
  164. {
  165. return (__m256d)__builtin_ia32_vfnmsubpd256 ((__v4df)__A, (__v4df)__B,
  166. (__v4df)__C);
  167. }
  168. extern __inline __m128
  169. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  170. _mm_fnmsub_ps (__m128 __A, __m128 __B, __m128 __C)
  171. {
  172. return (__m128)__builtin_ia32_vfnmsubps ((__v4sf)__A, (__v4sf)__B,
  173. (__v4sf)__C);
  174. }
  175. extern __inline __m256
  176. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  177. _mm256_fnmsub_ps (__m256 __A, __m256 __B, __m256 __C)
  178. {
  179. return (__m256)__builtin_ia32_vfnmsubps256 ((__v8sf)__A, (__v8sf)__B,
  180. (__v8sf)__C);
  181. }
  182. extern __inline __m128d
  183. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  184. _mm_fnmsub_sd (__m128d __A, __m128d __B, __m128d __C)
  185. {
  186. return (__m128d)__builtin_ia32_vfnmsubsd3 ((__v2df)__A, (__v2df)__B,
  187. (__v2df)__C);
  188. }
  189. extern __inline __m128
  190. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  191. _mm_fnmsub_ss (__m128 __A, __m128 __B, __m128 __C)
  192. {
  193. return (__m128)__builtin_ia32_vfnmsubss3 ((__v4sf)__A, (__v4sf)__B,
  194. (__v4sf)__C);
  195. }
  196. extern __inline __m128d
  197. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  198. _mm_fmaddsub_pd (__m128d __A, __m128d __B, __m128d __C)
  199. {
  200. return (__m128d)__builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B,
  201. (__v2df)__C);
  202. }
  203. extern __inline __m256d
  204. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  205. _mm256_fmaddsub_pd (__m256d __A, __m256d __B, __m256d __C)
  206. {
  207. return (__m256d)__builtin_ia32_vfmaddsubpd256 ((__v4df)__A,
  208. (__v4df)__B,
  209. (__v4df)__C);
  210. }
  211. extern __inline __m128
  212. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  213. _mm_fmaddsub_ps (__m128 __A, __m128 __B, __m128 __C)
  214. {
  215. return (__m128)__builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B,
  216. (__v4sf)__C);
  217. }
  218. extern __inline __m256
  219. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  220. _mm256_fmaddsub_ps (__m256 __A, __m256 __B, __m256 __C)
  221. {
  222. return (__m256)__builtin_ia32_vfmaddsubps256 ((__v8sf)__A,
  223. (__v8sf)__B,
  224. (__v8sf)__C);
  225. }
  226. extern __inline __m128d
  227. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  228. _mm_fmsubadd_pd (__m128d __A, __m128d __B, __m128d __C)
  229. {
  230. return (__m128d)__builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B,
  231. -(__v2df)__C);
  232. }
  233. extern __inline __m256d
  234. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  235. _mm256_fmsubadd_pd (__m256d __A, __m256d __B, __m256d __C)
  236. {
  237. return (__m256d)__builtin_ia32_vfmaddsubpd256 ((__v4df)__A,
  238. (__v4df)__B,
  239. -(__v4df)__C);
  240. }
  241. extern __inline __m128
  242. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  243. _mm_fmsubadd_ps (__m128 __A, __m128 __B, __m128 __C)
  244. {
  245. return (__m128)__builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B,
  246. -(__v4sf)__C);
  247. }
  248. extern __inline __m256
  249. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  250. _mm256_fmsubadd_ps (__m256 __A, __m256 __B, __m256 __C)
  251. {
  252. return (__m256)__builtin_ia32_vfmaddsubps256 ((__v8sf)__A,
  253. (__v8sf)__B,
  254. -(__v8sf)__C);
  255. }
  256. #ifdef __DISABLE_FMA__
  257. #undef __DISABLE_FMA__
  258. #pragma GCC pop_options
  259. #endif /* __DISABLE_FMA__ */
  260. #endif