1 /* Copyright (C) 2017-2018 Free Software Foundation, Inc.
2 
3    This file is part of GCC.
4 
5    GCC is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3, or (at your option)
8    any later version.
9 
10    GCC is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    Under Section 7 of GPL version 3, you are granted additional
16    permissions described in the GCC Runtime Library Exception, version
17    3.1, as published by the Free Software Foundation.
18 
19    You should have received a copy of the GNU General Public License and
20    a copy of the GCC Runtime Library Exception along with this program;
21    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
22    <http://www.gnu.org/licenses/>.  */
23 
24 #if !defined _IMMINTRIN_H_INCLUDED
25 # error "Never use <avx512vpopcntdqvlintrin.h> directly; include <immintrin.h> instead."
26 #endif
27 
28 #ifndef _AVX512VPOPCNTDQVLINTRIN_H_INCLUDED
29 #define _AVX512VPOPCNTDQVLINTRIN_H_INCLUDED
30 
31 #if !defined(__AVX512VPOPCNTDQ__) || !defined(__AVX512VL__)
32 #pragma GCC push_options
33 #pragma GCC target("avx512vpopcntdq,avx512vl")
34 #define __DISABLE_AVX512VPOPCNTDQVL__
35 #endif /* __AVX512VPOPCNTDQVL__ */
36 
37 extern __inline __m128i
38 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_popcnt_epi32(__m128i __A)39 _mm_popcnt_epi32 (__m128i __A)
40 {
41   return (__m128i) __builtin_ia32_vpopcountd_v4si ((__v4si) __A);
42 }
43 
44 extern __inline __m128i
45 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_popcnt_epi32(__m128i __W,__mmask16 __U,__m128i __A)46 _mm_mask_popcnt_epi32 (__m128i __W, __mmask16 __U, __m128i __A)
47 {
48   return (__m128i) __builtin_ia32_vpopcountd_v4si_mask ((__v4si) __A,
49 							 (__v4si) __W,
50 							 (__mmask16) __U);
51 }
52 
53 extern __inline __m128i
54 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_popcnt_epi32(__mmask16 __U,__m128i __A)55 _mm_maskz_popcnt_epi32 (__mmask16 __U, __m128i __A)
56 {
57   return (__m128i) __builtin_ia32_vpopcountd_v4si_mask ((__v4si) __A,
58 							 (__v4si)
59 							 _mm_setzero_si128 (),
60 							 (__mmask16) __U);
61 }
62 
63 extern __inline __m256i
64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_popcnt_epi32(__m256i __A)65 _mm256_popcnt_epi32 (__m256i __A)
66 {
67   return (__m256i) __builtin_ia32_vpopcountd_v8si ((__v8si) __A);
68 }
69 
70 extern __inline __m256i
71 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_mask_popcnt_epi32(__m256i __W,__mmask16 __U,__m256i __A)72 _mm256_mask_popcnt_epi32 (__m256i __W, __mmask16 __U, __m256i __A)
73 {
74   return (__m256i) __builtin_ia32_vpopcountd_v8si_mask ((__v8si) __A,
75 							 (__v8si) __W,
76 							 (__mmask16) __U);
77 }
78 
79 extern __inline __m256i
80 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maskz_popcnt_epi32(__mmask16 __U,__m256i __A)81 _mm256_maskz_popcnt_epi32 (__mmask16 __U, __m256i __A)
82 {
83   return (__m256i) __builtin_ia32_vpopcountd_v8si_mask ((__v8si) __A,
84 						(__v8si)
85 						_mm256_setzero_si256 (),
86 						(__mmask16) __U);
87 }
88 
89 extern __inline __m128i
90 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_popcnt_epi64(__m128i __A)91 _mm_popcnt_epi64 (__m128i __A)
92 {
93   return (__m128i) __builtin_ia32_vpopcountq_v2di ((__v2di) __A);
94 }
95 
96 extern __inline __m128i
97 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_popcnt_epi64(__m128i __W,__mmask8 __U,__m128i __A)98 _mm_mask_popcnt_epi64 (__m128i __W, __mmask8 __U, __m128i __A)
99 {
100   return (__m128i) __builtin_ia32_vpopcountq_v2di_mask ((__v2di) __A,
101 							(__v2di) __W,
102 							(__mmask8) __U);
103 }
104 
105 extern __inline __m128i
106 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_popcnt_epi64(__mmask8 __U,__m128i __A)107 _mm_maskz_popcnt_epi64 (__mmask8 __U, __m128i __A)
108 {
109   return (__m128i) __builtin_ia32_vpopcountq_v2di_mask ((__v2di) __A,
110 							(__v2di)
111 							_mm_setzero_si128 (),
112 							(__mmask8) __U);
113 }
114 
115 extern __inline __m256i
116 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_popcnt_epi64(__m256i __A)117 _mm256_popcnt_epi64 (__m256i __A)
118 {
119   return (__m256i) __builtin_ia32_vpopcountq_v4di ((__v4di) __A);
120 }
121 
122 extern __inline __m256i
123 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_mask_popcnt_epi64(__m256i __W,__mmask8 __U,__m256i __A)124 _mm256_mask_popcnt_epi64 (__m256i __W, __mmask8 __U, __m256i __A)
125 {
126   return (__m256i) __builtin_ia32_vpopcountq_v4di_mask ((__v4di) __A,
127 							(__v4di) __W,
128 							(__mmask8) __U);
129 }
130 
131 extern __inline __m256i
132 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maskz_popcnt_epi64(__mmask8 __U,__m256i __A)133 _mm256_maskz_popcnt_epi64 (__mmask8 __U, __m256i __A)
134 {
135   return (__m256i) __builtin_ia32_vpopcountq_v4di_mask ((__v4di) __A,
136 						(__v4di)
137 						_mm256_setzero_si256 (),
138 						(__mmask8) __U);
139 }
140 
141 #ifdef __DISABLE_AVX512VPOPCNTDQVL__
142 #undef __DISABLE_AVX512VPOPCNTDQVL__
143 #pragma GCC pop_options
144 #endif /* __DISABLE_AVX512VPOPCNTDQVL__ */
145 
146 #endif /* _AVX512VPOPCNTDQVLINTRIN_H_INCLUDED */
147