avx512vpopcntdqvlintrin.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*===---- avx512vpopcntdqintrin.h - AVX512VPOPCNTDQ intrinsics -------------===
  2. *
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. *
  22. *===-----------------------------------------------------------------------===
  23. */
  24. #ifndef __IMMINTRIN_H
  25. #error \
  26. "Never use <avx512vpopcntdqvlintrin.h> directly; include <immintrin.h> instead."
  27. #endif
  28. #ifndef __AVX512VPOPCNTDQVLINTRIN_H
  29. #define __AVX512VPOPCNTDQVLINTRIN_H
  30. /* Define the default attributes for the functions in this file. */
  31. #define __DEFAULT_FN_ATTRS128 \
  32. __attribute__((__always_inline__, __nodebug__, __target__("avx512vpopcntdq,avx512vl"), __min_vector_width__(128)))
  33. #define __DEFAULT_FN_ATTRS256 \
  34. __attribute__((__always_inline__, __nodebug__, __target__("avx512vpopcntdq,avx512vl"), __min_vector_width__(256)))
  35. static __inline__ __m128i __DEFAULT_FN_ATTRS128
  36. _mm_popcnt_epi64(__m128i __A) {
  37. return (__m128i)__builtin_ia32_vpopcntq_128((__v2di)__A);
  38. }
  39. static __inline__ __m128i __DEFAULT_FN_ATTRS128
  40. _mm_mask_popcnt_epi64(__m128i __W, __mmask8 __U, __m128i __A) {
  41. return (__m128i)__builtin_ia32_selectq_128(
  42. (__mmask8)__U, (__v2di)_mm_popcnt_epi64(__A), (__v2di)__W);
  43. }
  44. static __inline__ __m128i __DEFAULT_FN_ATTRS128
  45. _mm_maskz_popcnt_epi64(__mmask8 __U, __m128i __A) {
  46. return _mm_mask_popcnt_epi64((__m128i)_mm_setzero_si128(), __U, __A);
  47. }
  48. static __inline__ __m128i __DEFAULT_FN_ATTRS128
  49. _mm_popcnt_epi32(__m128i __A) {
  50. return (__m128i)__builtin_ia32_vpopcntd_128((__v4si)__A);
  51. }
  52. static __inline__ __m128i __DEFAULT_FN_ATTRS128
  53. _mm_mask_popcnt_epi32(__m128i __W, __mmask8 __U, __m128i __A) {
  54. return (__m128i)__builtin_ia32_selectd_128(
  55. (__mmask8)__U, (__v4si)_mm_popcnt_epi32(__A), (__v4si)__W);
  56. }
  57. static __inline__ __m128i __DEFAULT_FN_ATTRS128
  58. _mm_maskz_popcnt_epi32(__mmask8 __U, __m128i __A) {
  59. return _mm_mask_popcnt_epi32((__m128i)_mm_setzero_si128(), __U, __A);
  60. }
  61. static __inline__ __m256i __DEFAULT_FN_ATTRS256
  62. _mm256_popcnt_epi64(__m256i __A) {
  63. return (__m256i)__builtin_ia32_vpopcntq_256((__v4di)__A);
  64. }
  65. static __inline__ __m256i __DEFAULT_FN_ATTRS256
  66. _mm256_mask_popcnt_epi64(__m256i __W, __mmask8 __U, __m256i __A) {
  67. return (__m256i)__builtin_ia32_selectq_256(
  68. (__mmask8)__U, (__v4di)_mm256_popcnt_epi64(__A), (__v4di)__W);
  69. }
  70. static __inline__ __m256i __DEFAULT_FN_ATTRS256
  71. _mm256_maskz_popcnt_epi64(__mmask8 __U, __m256i __A) {
  72. return _mm256_mask_popcnt_epi64((__m256i)_mm256_setzero_si256(), __U, __A);
  73. }
  74. static __inline__ __m256i __DEFAULT_FN_ATTRS256
  75. _mm256_popcnt_epi32(__m256i __A) {
  76. return (__m256i)__builtin_ia32_vpopcntd_256((__v8si)__A);
  77. }
  78. static __inline__ __m256i __DEFAULT_FN_ATTRS256
  79. _mm256_mask_popcnt_epi32(__m256i __W, __mmask8 __U, __m256i __A) {
  80. return (__m256i)__builtin_ia32_selectd_256(
  81. (__mmask8)__U, (__v8si)_mm256_popcnt_epi32(__A), (__v8si)__W);
  82. }
  83. static __inline__ __m256i __DEFAULT_FN_ATTRS256
  84. _mm256_maskz_popcnt_epi32(__mmask8 __U, __m256i __A) {
  85. return _mm256_mask_popcnt_epi32((__m256i)_mm256_setzero_si256(), __U, __A);
  86. }
  87. #undef __DEFAULT_FN_ATTRS128
  88. #undef __DEFAULT_FN_ATTRS256
  89. #endif