fma4intrin.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /* Copyright (C) 2007-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 _X86INTRIN_H_INCLUDED
  19. # error "Never use <fma4intrin.h> directly; include <x86intrin.h> instead."
  20. #endif
  21. #ifndef _FMA4INTRIN_H_INCLUDED
  22. #define _FMA4INTRIN_H_INCLUDED
  23. /* We need definitions from the SSE4A, SSE3, SSE2 and SSE header files. */
  24. #include <ammintrin.h>
  25. #ifndef __FMA4__
  26. #pragma GCC push_options
  27. #pragma GCC target("fma4")
  28. #define __DISABLE_FMA4__
  29. #endif /* __FMA4__ */
  30. /* 128b Floating point multiply/add type instructions. */
  31. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  32. _mm_macc_ps (__m128 __A, __m128 __B, __m128 __C)
  33. {
  34. return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
  35. }
  36. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  37. _mm_macc_pd (__m128d __A, __m128d __B, __m128d __C)
  38. {
  39. return (__m128d) __builtin_ia32_vfmaddpd ((__v2df)__A, (__v2df)__B, (__v2df)__C);
  40. }
  41. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  42. _mm_macc_ss (__m128 __A, __m128 __B, __m128 __C)
  43. {
  44. return (__m128) __builtin_ia32_vfmaddss ((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
  45. }
  46. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  47. _mm_macc_sd (__m128d __A, __m128d __B, __m128d __C)
  48. {
  49. return (__m128d) __builtin_ia32_vfmaddsd ((__v2df)__A, (__v2df)__B, (__v2df)__C);
  50. }
  51. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  52. _mm_msub_ps (__m128 __A, __m128 __B, __m128 __C)
  53. {
  54. return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
  55. }
  56. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  57. _mm_msub_pd (__m128d __A, __m128d __B, __m128d __C)
  58. {
  59. return (__m128d) __builtin_ia32_vfmaddpd ((__v2df)__A, (__v2df)__B, -(__v2df)__C);
  60. }
  61. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  62. _mm_msub_ss (__m128 __A, __m128 __B, __m128 __C)
  63. {
  64. return (__m128) __builtin_ia32_vfmaddss ((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
  65. }
  66. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  67. _mm_msub_sd (__m128d __A, __m128d __B, __m128d __C)
  68. {
  69. return (__m128d) __builtin_ia32_vfmaddsd ((__v2df)__A, (__v2df)__B, -(__v2df)__C);
  70. }
  71. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  72. _mm_nmacc_ps (__m128 __A, __m128 __B, __m128 __C)
  73. {
  74. return (__m128) __builtin_ia32_vfmaddps (-(__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
  75. }
  76. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  77. _mm_nmacc_pd (__m128d __A, __m128d __B, __m128d __C)
  78. {
  79. return (__m128d) __builtin_ia32_vfmaddpd (-(__v2df)__A, (__v2df)__B, (__v2df)__C);
  80. }
  81. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  82. _mm_nmacc_ss (__m128 __A, __m128 __B, __m128 __C)
  83. {
  84. return (__m128) __builtin_ia32_vfmaddss (-(__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
  85. }
  86. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  87. _mm_nmacc_sd (__m128d __A, __m128d __B, __m128d __C)
  88. {
  89. return (__m128d) __builtin_ia32_vfmaddsd (-(__v2df)__A, (__v2df)__B, (__v2df)__C);
  90. }
  91. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  92. _mm_nmsub_ps (__m128 __A, __m128 __B, __m128 __C)
  93. {
  94. return (__m128) __builtin_ia32_vfmaddps (-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
  95. }
  96. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  97. _mm_nmsub_pd (__m128d __A, __m128d __B, __m128d __C)
  98. {
  99. return (__m128d) __builtin_ia32_vfmaddpd (-(__v2df)__A, (__v2df)__B, -(__v2df)__C);
  100. }
  101. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  102. _mm_nmsub_ss (__m128 __A, __m128 __B, __m128 __C)
  103. {
  104. return (__m128) __builtin_ia32_vfmaddss (-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
  105. }
  106. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  107. _mm_nmsub_sd (__m128d __A, __m128d __B, __m128d __C)
  108. {
  109. return (__m128d) __builtin_ia32_vfmaddsd (-(__v2df)__A, (__v2df)__B, -(__v2df)__C);
  110. }
  111. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  112. _mm_maddsub_ps (__m128 __A, __m128 __B, __m128 __C)
  113. {
  114. return (__m128) __builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
  115. }
  116. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  117. _mm_maddsub_pd (__m128d __A, __m128d __B, __m128d __C)
  118. {
  119. return (__m128d) __builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B, (__v2df)__C);
  120. }
  121. extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  122. _mm_msubadd_ps (__m128 __A, __m128 __B, __m128 __C)
  123. {
  124. return (__m128) __builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
  125. }
  126. extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  127. _mm_msubadd_pd (__m128d __A, __m128d __B, __m128d __C)
  128. {
  129. return (__m128d) __builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B, -(__v2df)__C);
  130. }
  131. /* 256b Floating point multiply/add type instructions. */
  132. extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  133. _mm256_macc_ps (__m256 __A, __m256 __B, __m256 __C)
  134. {
  135. return (__m256) __builtin_ia32_vfmaddps256 ((__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
  136. }
  137. extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  138. _mm256_macc_pd (__m256d __A, __m256d __B, __m256d __C)
  139. {
  140. return (__m256d) __builtin_ia32_vfmaddpd256 ((__v4df)__A, (__v4df)__B, (__v4df)__C);
  141. }
  142. extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  143. _mm256_msub_ps (__m256 __A, __m256 __B, __m256 __C)
  144. {
  145. return (__m256) __builtin_ia32_vfmaddps256 ((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
  146. }
  147. extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  148. _mm256_msub_pd (__m256d __A, __m256d __B, __m256d __C)
  149. {
  150. return (__m256d) __builtin_ia32_vfmaddpd256 ((__v4df)__A, (__v4df)__B, -(__v4df)__C);
  151. }
  152. extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  153. _mm256_nmacc_ps (__m256 __A, __m256 __B, __m256 __C)
  154. {
  155. return (__m256) __builtin_ia32_vfmaddps256 (-(__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
  156. }
  157. extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  158. _mm256_nmacc_pd (__m256d __A, __m256d __B, __m256d __C)
  159. {
  160. return (__m256d) __builtin_ia32_vfmaddpd256 (-(__v4df)__A, (__v4df)__B, (__v4df)__C);
  161. }
  162. extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  163. _mm256_nmsub_ps (__m256 __A, __m256 __B, __m256 __C)
  164. {
  165. return (__m256) __builtin_ia32_vfmaddps256 (-(__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
  166. }
  167. extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  168. _mm256_nmsub_pd (__m256d __A, __m256d __B, __m256d __C)
  169. {
  170. return (__m256d) __builtin_ia32_vfmaddpd256 (-(__v4df)__A, (__v4df)__B, -(__v4df)__C);
  171. }
  172. extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  173. _mm256_maddsub_ps (__m256 __A, __m256 __B, __m256 __C)
  174. {
  175. return (__m256) __builtin_ia32_vfmaddsubps256 ((__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
  176. }
  177. extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  178. _mm256_maddsub_pd (__m256d __A, __m256d __B, __m256d __C)
  179. {
  180. return (__m256d) __builtin_ia32_vfmaddsubpd256 ((__v4df)__A, (__v4df)__B, (__v4df)__C);
  181. }
  182. extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  183. _mm256_msubadd_ps (__m256 __A, __m256 __B, __m256 __C)
  184. {
  185. return (__m256) __builtin_ia32_vfmaddsubps256 ((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
  186. }
  187. extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  188. _mm256_msubadd_pd (__m256d __A, __m256d __B, __m256d __C)
  189. {
  190. return (__m256d) __builtin_ia32_vfmaddsubpd256 ((__v4df)__A, (__v4df)__B, -(__v4df)__C);
  191. }
  192. #ifdef __DISABLE_FMA4__
  193. #undef __DISABLE_FMA4__
  194. #pragma GCC pop_options
  195. #endif /* __DISABLE_FMA4__ */
  196. #endif