| 1 | /*===---- avx512vpopcntdqintrin.h - AVX512VPOPCNTDQ intrinsics -------------=== |
| 2 | * |
| 3 | * |
| 4 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | * See https://llvm.org/LICENSE.txt for license information. |
| 6 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | * |
| 8 | *===-----------------------------------------------------------------------=== |
| 9 | */ |
| 10 | #ifndef __IMMINTRIN_H |
| 11 | #error \ |
| 12 | "Never use <avx512vpopcntdqvlintrin.h> directly; include <immintrin.h> instead." |
| 13 | #endif |
| 14 | |
| 15 | #ifndef __AVX512VPOPCNTDQVLINTRIN_H |
| 16 | #define __AVX512VPOPCNTDQVLINTRIN_H |
| 17 | |
| 18 | /* Define the default attributes for the functions in this file. */ |
| 19 | |
| 20 | #if defined(__cplusplus) && (__cplusplus >= 201103L) |
| 21 | #define __DEFAULT_FN_ATTRS128 \ |
| 22 | __attribute__((__always_inline__, __nodebug__, \ |
| 23 | __target__("avx512vpopcntdq,avx512vl"), \ |
| 24 | __min_vector_width__(128))) constexpr |
| 25 | #define __DEFAULT_FN_ATTRS256 \ |
| 26 | __attribute__((__always_inline__, __nodebug__, \ |
| 27 | __target__("avx512vpopcntdq,avx512vl"), \ |
| 28 | __min_vector_width__(256))) constexpr |
| 29 | #else |
| 30 | #define __DEFAULT_FN_ATTRS128 \ |
| 31 | __attribute__((__always_inline__, __nodebug__, \ |
| 32 | __target__("avx512vpopcntdq,avx512vl"), \ |
| 33 | __min_vector_width__(128))) |
| 34 | #define __DEFAULT_FN_ATTRS256 \ |
| 35 | __attribute__((__always_inline__, __nodebug__, \ |
| 36 | __target__("avx512vpopcntdq,avx512vl"), \ |
| 37 | __min_vector_width__(256))) |
| 38 | #endif |
| 39 | |
| 40 | static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_popcnt_epi64(__m128i __A) { |
| 41 | return (__m128i)__builtin_elementwise_popcount((__v2du)__A); |
| 42 | } |
| 43 | |
| 44 | static __inline__ __m128i __DEFAULT_FN_ATTRS128 |
| 45 | _mm_mask_popcnt_epi64(__m128i __W, __mmask8 __U, __m128i __A) { |
| 46 | return (__m128i)__builtin_ia32_selectq_128( |
| 47 | (__mmask8)__U, (__v2di)_mm_popcnt_epi64(__A), (__v2di)__W); |
| 48 | } |
| 49 | |
| 50 | static __inline__ __m128i __DEFAULT_FN_ATTRS128 |
| 51 | _mm_maskz_popcnt_epi64(__mmask8 __U, __m128i __A) { |
| 52 | return _mm_mask_popcnt_epi64((__m128i)_mm_setzero_si128(), __U, __A); |
| 53 | } |
| 54 | |
| 55 | static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_popcnt_epi32(__m128i __A) { |
| 56 | return (__m128i)__builtin_elementwise_popcount((__v4su)__A); |
| 57 | } |
| 58 | |
| 59 | static __inline__ __m128i __DEFAULT_FN_ATTRS128 |
| 60 | _mm_mask_popcnt_epi32(__m128i __W, __mmask8 __U, __m128i __A) { |
| 61 | return (__m128i)__builtin_ia32_selectd_128( |
| 62 | (__mmask8)__U, (__v4si)_mm_popcnt_epi32(__A), (__v4si)__W); |
| 63 | } |
| 64 | |
| 65 | static __inline__ __m128i __DEFAULT_FN_ATTRS128 |
| 66 | _mm_maskz_popcnt_epi32(__mmask8 __U, __m128i __A) { |
| 67 | return _mm_mask_popcnt_epi32((__m128i)_mm_setzero_si128(), __U, __A); |
| 68 | } |
| 69 | |
| 70 | static __inline__ __m256i __DEFAULT_FN_ATTRS256 |
| 71 | _mm256_popcnt_epi64(__m256i __A) { |
| 72 | return (__m256i)__builtin_elementwise_popcount((__v4du)__A); |
| 73 | } |
| 74 | |
| 75 | static __inline__ __m256i __DEFAULT_FN_ATTRS256 |
| 76 | _mm256_mask_popcnt_epi64(__m256i __W, __mmask8 __U, __m256i __A) { |
| 77 | return (__m256i)__builtin_ia32_selectq_256( |
| 78 | (__mmask8)__U, (__v4di)_mm256_popcnt_epi64(__A), (__v4di)__W); |
| 79 | } |
| 80 | |
| 81 | static __inline__ __m256i __DEFAULT_FN_ATTRS256 |
| 82 | _mm256_maskz_popcnt_epi64(__mmask8 __U, __m256i __A) { |
| 83 | return _mm256_mask_popcnt_epi64((__m256i)_mm256_setzero_si256(), __U, __A); |
| 84 | } |
| 85 | |
| 86 | static __inline__ __m256i __DEFAULT_FN_ATTRS256 |
| 87 | _mm256_popcnt_epi32(__m256i __A) { |
| 88 | return (__m256i)__builtin_elementwise_popcount((__v8su)__A); |
| 89 | } |
| 90 | |
| 91 | static __inline__ __m256i __DEFAULT_FN_ATTRS256 |
| 92 | _mm256_mask_popcnt_epi32(__m256i __W, __mmask8 __U, __m256i __A) { |
| 93 | return (__m256i)__builtin_ia32_selectd_256( |
| 94 | (__mmask8)__U, (__v8si)_mm256_popcnt_epi32(__A), (__v8si)__W); |
| 95 | } |
| 96 | |
| 97 | static __inline__ __m256i __DEFAULT_FN_ATTRS256 |
| 98 | _mm256_maskz_popcnt_epi32(__mmask8 __U, __m256i __A) { |
| 99 | return _mm256_mask_popcnt_epi32((__m256i)_mm256_setzero_si256(), __U, __A); |
| 100 | } |
| 101 | |
| 102 | #undef __DEFAULT_FN_ATTRS128 |
| 103 | #undef __DEFAULT_FN_ATTRS256 |
| 104 | |
| 105 | #endif |