add popcount32x4, popcount64x4 helper functions

This commit is contained in:
Konstantinos Margaritis
2022-09-02 15:12:56 +03:00
parent 361e9be4a0
commit 27dbdcf122
2 changed files with 19 additions and 4 deletions

View File

@@ -52,6 +52,15 @@ u32 popcount32(u32 x) {
// #endif
}
static really_inline
u32 popcount32x4(u32 const *x) {
u32 sum = popcount32(x[0]);
sum += popcount32(x[1]);
sum += popcount32(x[2]);
sum += popcount32(x[3]);
return sum;
}
static really_inline
u32 popcount64(u64a x) {
return __builtin_popcountll(x);
@@ -73,5 +82,14 @@ u32 popcount64(u64a x) {
// #endif
}
static really_inline
u32 popcount64x4(u64a const *x) {
volatile u32 sum = popcount64(x[0]);
sum += popcount64(x[1]);
sum += popcount64(x[2]);
sum += popcount64(x[3]);
return sum;
}
#endif /* UTIL_POPCOUNT_H_ */