avx512bitalgintrin.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /* Copyright (C) 2017-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. #if !defined _IMMINTRIN_H_INCLUDED
  19. # error "Never use <avx512bitalgintrin.h> directly; include <x86intrin.h> instead."
  20. #endif
  21. #ifndef _AVX512BITALGINTRIN_H_INCLUDED
  22. #define _AVX512BITALGINTRIN_H_INCLUDED
  23. #ifndef __AVX512BITALG__
  24. #pragma GCC push_options
  25. #pragma GCC target("avx512bitalg")
  26. #define __DISABLE_AVX512BITALG__
  27. #endif /* __AVX512BITALG__ */
  28. extern __inline __m512i
  29. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  30. _mm512_popcnt_epi8 (__m512i __A)
  31. {
  32. return (__m512i) __builtin_ia32_vpopcountb_v64qi ((__v64qi) __A);
  33. }
  34. extern __inline __m512i
  35. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  36. _mm512_popcnt_epi16 (__m512i __A)
  37. {
  38. return (__m512i) __builtin_ia32_vpopcountw_v32hi ((__v32hi) __A);
  39. }
  40. #ifdef __DISABLE_AVX512BITALG__
  41. #undef __DISABLE_AVX512BITALG__
  42. #pragma GCC pop_options
  43. #endif /* __DISABLE_AVX512BITALG__ */
  44. #if !defined(__AVX512BITALG__) || !defined(__AVX512BW__)
  45. #pragma GCC push_options
  46. #pragma GCC target("avx512bitalg,avx512bw")
  47. #define __DISABLE_AVX512BITALGBW__
  48. #endif /* __AVX512VLBW__ */
  49. extern __inline __m512i
  50. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  51. _mm512_mask_popcnt_epi8 (__m512i __W, __mmask64 __U, __m512i __A)
  52. {
  53. return (__m512i) __builtin_ia32_vpopcountb_v64qi_mask ((__v64qi) __A,
  54. (__v64qi) __W,
  55. (__mmask64) __U);
  56. }
  57. extern __inline __m512i
  58. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  59. _mm512_maskz_popcnt_epi8 (__mmask64 __U, __m512i __A)
  60. {
  61. return (__m512i) __builtin_ia32_vpopcountb_v64qi_mask ((__v64qi) __A,
  62. (__v64qi)
  63. _mm512_setzero_si512 (),
  64. (__mmask64) __U);
  65. }
  66. extern __inline __m512i
  67. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  68. _mm512_mask_popcnt_epi16 (__m512i __W, __mmask32 __U, __m512i __A)
  69. {
  70. return (__m512i) __builtin_ia32_vpopcountw_v32hi_mask ((__v32hi) __A,
  71. (__v32hi) __W,
  72. (__mmask32) __U);
  73. }
  74. extern __inline __m512i
  75. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  76. _mm512_maskz_popcnt_epi16 (__mmask32 __U, __m512i __A)
  77. {
  78. return (__m512i) __builtin_ia32_vpopcountw_v32hi_mask ((__v32hi) __A,
  79. (__v32hi)
  80. _mm512_setzero_si512 (),
  81. (__mmask32) __U);
  82. }
  83. extern __inline __mmask64
  84. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  85. _mm512_bitshuffle_epi64_mask (__m512i __A, __m512i __B)
  86. {
  87. return (__mmask64) __builtin_ia32_vpshufbitqmb512_mask ((__v64qi) __A,
  88. (__v64qi) __B,
  89. (__mmask64) -1);
  90. }
  91. extern __inline __mmask64
  92. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  93. _mm512_mask_bitshuffle_epi64_mask (__mmask64 __M, __m512i __A, __m512i __B)
  94. {
  95. return (__mmask64) __builtin_ia32_vpshufbitqmb512_mask ((__v64qi) __A,
  96. (__v64qi) __B,
  97. (__mmask64) __M);
  98. }
  99. #ifdef __DISABLE_AVX512BITALGBW__
  100. #undef __DISABLE_AVX512BITALGBW__
  101. #pragma GCC pop_options
  102. #endif /* __DISABLE_AVX512BITALGBW__ */
  103. #if !defined(__AVX512BITALG__) || !defined(__AVX512VL__) || !defined(__AVX512BW__)
  104. #pragma GCC push_options
  105. #pragma GCC target("avx512bitalg,avx512vl,avx512bw")
  106. #define __DISABLE_AVX512BITALGVLBW__
  107. #endif /* __AVX512VLBW__ */
  108. extern __inline __m256i
  109. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  110. _mm256_mask_popcnt_epi8 (__m256i __W, __mmask32 __U, __m256i __A)
  111. {
  112. return (__m256i) __builtin_ia32_vpopcountb_v32qi_mask ((__v32qi) __A,
  113. (__v32qi) __W,
  114. (__mmask32) __U);
  115. }
  116. extern __inline __m256i
  117. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  118. _mm256_maskz_popcnt_epi8 (__mmask32 __U, __m256i __A)
  119. {
  120. return (__m256i) __builtin_ia32_vpopcountb_v32qi_mask ((__v32qi) __A,
  121. (__v32qi)
  122. _mm256_setzero_si256 (),
  123. (__mmask32) __U);
  124. }
  125. extern __inline __mmask32
  126. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  127. _mm256_bitshuffle_epi64_mask (__m256i __A, __m256i __B)
  128. {
  129. return (__mmask32) __builtin_ia32_vpshufbitqmb256_mask ((__v32qi) __A,
  130. (__v32qi) __B,
  131. (__mmask32) -1);
  132. }
  133. extern __inline __mmask32
  134. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  135. _mm256_mask_bitshuffle_epi64_mask (__mmask32 __M, __m256i __A, __m256i __B)
  136. {
  137. return (__mmask32) __builtin_ia32_vpshufbitqmb256_mask ((__v32qi) __A,
  138. (__v32qi) __B,
  139. (__mmask32) __M);
  140. }
  141. #ifdef __DISABLE_AVX512BITALGVLBW__
  142. #undef __DISABLE_AVX512BITALGVLBW__
  143. #pragma GCC pop_options
  144. #endif /* __DISABLE_AVX512BITALGVLBW__ */
  145. #if !defined(__AVX512BITALG__) || !defined(__AVX512VL__)
  146. #pragma GCC push_options
  147. #pragma GCC target("avx512bitalg,avx512vl")
  148. #define __DISABLE_AVX512BITALGVL__
  149. #endif /* __AVX512VLBW__ */
  150. extern __inline __mmask16
  151. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  152. _mm_bitshuffle_epi64_mask (__m128i __A, __m128i __B)
  153. {
  154. return (__mmask16) __builtin_ia32_vpshufbitqmb128_mask ((__v16qi) __A,
  155. (__v16qi) __B,
  156. (__mmask16) -1);
  157. }
  158. extern __inline __mmask16
  159. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  160. _mm_mask_bitshuffle_epi64_mask (__mmask16 __M, __m128i __A, __m128i __B)
  161. {
  162. return (__mmask16) __builtin_ia32_vpshufbitqmb128_mask ((__v16qi) __A,
  163. (__v16qi) __B,
  164. (__mmask16) __M);
  165. }
  166. extern __inline __m256i
  167. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  168. _mm256_popcnt_epi8 (__m256i __A)
  169. {
  170. return (__m256i) __builtin_ia32_vpopcountb_v32qi ((__v32qi) __A);
  171. }
  172. extern __inline __m256i
  173. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  174. _mm256_popcnt_epi16 (__m256i __A)
  175. {
  176. return (__m256i) __builtin_ia32_vpopcountw_v16hi ((__v16hi) __A);
  177. }
  178. extern __inline __m128i
  179. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  180. _mm_popcnt_epi8 (__m128i __A)
  181. {
  182. return (__m128i) __builtin_ia32_vpopcountb_v16qi ((__v16qi) __A);
  183. }
  184. extern __inline __m128i
  185. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  186. _mm_popcnt_epi16 (__m128i __A)
  187. {
  188. return (__m128i) __builtin_ia32_vpopcountw_v8hi ((__v8hi) __A);
  189. }
  190. extern __inline __m256i
  191. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  192. _mm256_mask_popcnt_epi16 (__m256i __W, __mmask16 __U, __m256i __A)
  193. {
  194. return (__m256i) __builtin_ia32_vpopcountw_v16hi_mask ((__v16hi) __A,
  195. (__v16hi) __W,
  196. (__mmask16) __U);
  197. }
  198. extern __inline __m256i
  199. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  200. _mm256_maskz_popcnt_epi16 (__mmask16 __U, __m256i __A)
  201. {
  202. return (__m256i) __builtin_ia32_vpopcountw_v16hi_mask ((__v16hi) __A,
  203. (__v16hi)
  204. _mm256_setzero_si256 (),
  205. (__mmask16) __U);
  206. }
  207. extern __inline __m128i
  208. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  209. _mm_mask_popcnt_epi8 (__m128i __W, __mmask16 __U, __m128i __A)
  210. {
  211. return (__m128i) __builtin_ia32_vpopcountb_v16qi_mask ((__v16qi) __A,
  212. (__v16qi) __W,
  213. (__mmask16) __U);
  214. }
  215. extern __inline __m128i
  216. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  217. _mm_maskz_popcnt_epi8 (__mmask16 __U, __m128i __A)
  218. {
  219. return (__m128i) __builtin_ia32_vpopcountb_v16qi_mask ((__v16qi) __A,
  220. (__v16qi)
  221. _mm_setzero_si128 (),
  222. (__mmask16) __U);
  223. }
  224. extern __inline __m128i
  225. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  226. _mm_mask_popcnt_epi16 (__m128i __W, __mmask8 __U, __m128i __A)
  227. {
  228. return (__m128i) __builtin_ia32_vpopcountw_v8hi_mask ((__v8hi) __A,
  229. (__v8hi) __W,
  230. (__mmask8) __U);
  231. }
  232. extern __inline __m128i
  233. __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  234. _mm_maskz_popcnt_epi16 (__mmask8 __U, __m128i __A)
  235. {
  236. return (__m128i) __builtin_ia32_vpopcountw_v8hi_mask ((__v8hi) __A,
  237. (__v8hi)
  238. _mm_setzero_si128 (),
  239. (__mmask8) __U);
  240. }
  241. #ifdef __DISABLE_AVX512BITALGVL__
  242. #undef __DISABLE_AVX512BITALGVL__
  243. #pragma GCC pop_options
  244. #endif /* __DISABLE_AVX512BITALGBW__ */
  245. #endif /* _AVX512BITALGINTRIN_H_INCLUDED */