| 1 | /*===------------- avx512bitalgintrin.h - BITALG 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 "Never use <avx512bitalgintrin.h> directly; include <immintrin.h> instead." |
| 12 | #endif |
| 13 | |
| 14 | #ifndef __AVX512BITALGINTRIN_H |
| 15 | #define __AVX512BITALGINTRIN_H |
| 16 | |
| 17 | /* Define the default attributes for the functions in this file. */ |
| 18 | #if defined(__cplusplus) && (__cplusplus >= 201103L) |
| 19 | #define __DEFAULT_FN_ATTRS \ |
| 20 | __attribute__((__always_inline__, __nodebug__, __target__("avx512bitalg"), \ |
| 21 | __min_vector_width__(512))) constexpr |
| 22 | #else |
| 23 | #define __DEFAULT_FN_ATTRS \ |
| 24 | __attribute__((__always_inline__, __nodebug__, __target__("avx512bitalg"), \ |
| 25 | __min_vector_width__(512))) |
| 26 | #endif |
| 27 | |
| 28 | static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_popcnt_epi16(__m512i __A) { |
| 29 | return (__m512i)__builtin_elementwise_popcount((__v32hu)__A); |
| 30 | } |
| 31 | |
| 32 | static __inline__ __m512i __DEFAULT_FN_ATTRS |
| 33 | _mm512_mask_popcnt_epi16(__m512i __A, __mmask32 __U, __m512i __B) { |
| 34 | return (__m512i)__builtin_ia32_selectw_512( |
| 35 | (__mmask32)__U, (__v32hi)_mm512_popcnt_epi16(__B), (__v32hi)__A); |
| 36 | } |
| 37 | |
| 38 | static __inline__ __m512i __DEFAULT_FN_ATTRS |
| 39 | _mm512_maskz_popcnt_epi16(__mmask32 __U, __m512i __B) { |
| 40 | return _mm512_mask_popcnt_epi16((__m512i)_mm512_setzero_si512(), __U, __B); |
| 41 | } |
| 42 | |
| 43 | static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_popcnt_epi8(__m512i __A) { |
| 44 | return (__m512i)__builtin_elementwise_popcount((__v64qu)__A); |
| 45 | } |
| 46 | |
| 47 | static __inline__ __m512i __DEFAULT_FN_ATTRS |
| 48 | _mm512_mask_popcnt_epi8(__m512i __A, __mmask64 __U, __m512i __B) { |
| 49 | return (__m512i)__builtin_ia32_selectb_512( |
| 50 | (__mmask64)__U, (__v64qi)_mm512_popcnt_epi8(__B), (__v64qi)__A); |
| 51 | } |
| 52 | |
| 53 | static __inline__ __m512i __DEFAULT_FN_ATTRS |
| 54 | _mm512_maskz_popcnt_epi8(__mmask64 __U, __m512i __B) { |
| 55 | return _mm512_mask_popcnt_epi8((__m512i)_mm512_setzero_si512(), __U, __B); |
| 56 | } |
| 57 | |
| 58 | static __inline__ __mmask64 __DEFAULT_FN_ATTRS |
| 59 | _mm512_mask_bitshuffle_epi64_mask(__mmask64 __U, __m512i __A, __m512i __B) |
| 60 | { |
| 61 | return (__mmask64) __builtin_ia32_vpshufbitqmb512_mask((__v64qi) __A, |
| 62 | (__v64qi) __B, |
| 63 | __U); |
| 64 | } |
| 65 | |
| 66 | static __inline__ __mmask64 __DEFAULT_FN_ATTRS |
| 67 | _mm512_bitshuffle_epi64_mask(__m512i __A, __m512i __B) |
| 68 | { |
| 69 | return _mm512_mask_bitshuffle_epi64_mask((__mmask64) -1, |
| 70 | __A, |
| 71 | __B); |
| 72 | } |
| 73 | |
| 74 | #undef __DEFAULT_FN_ATTRS |
| 75 | #endif |