avx512vpopcntdqvlintrin.h 3.9 KB

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