> From: Tyler Retzlaff [mailto:roret...@linux.microsoft.com]
> Sent: Wednesday, 8 November 2023 00.38
> 
> Use rte_popcount64 instead of __builtin_popcountl where the argument
> type passed to the intrinsic was 64-bits.

Can someone please explain why our CI test system accepted passing a 64-bit 
value to __builtin_popcountl(unsigned long) when building for 32-bit 
architectures, where an unsigned long is 32 bit? The 32 most significant bits 
were blindly truncated here.

It looks like this patch also fixes a bug (which should have been caught by the 
CI system) for 32-bit architectures.

> 
> Signed-off-by: Tyler Retzlaff <roret...@linux.microsoft.com>
> ---
>  lib/hash/rte_cuckoo_hash.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 19ee53a..ccdc3b9 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -2357,7 +2357,7 @@ struct rte_hash *
>       __rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask,
> data);
> 
>       /* Return number of hits */
> -     return __builtin_popcountl(*hit_mask);
> +     return rte_popcount64(*hit_mask);
>  }
> 
> 
> @@ -2474,7 +2474,7 @@ struct rte_hash *
>                       positions, hit_mask, data);
> 
>       /* Return number of hits */
> -     return __builtin_popcountl(*hit_mask);
> +     return rte_popcount64(*hit_mask);
>  }
> 
>  int32_t
> --
> 1.8.3.1

Reply via email to