[dpdk-dev] [PATCH 2/2] eal: add u64 bit variant for reciprocal

Stephen Hemminger stephen at networkplumber.org
Tue Aug 29 21:38:00 CEST 2017


On Wed, 30 Aug 2017 00:16:18 +0530
Pavan Nikhilesh <pbhagavatula at caviumnetworks.com> wrote:

> +static inline uint64_t
> +mullhi_u64(uint64_t x, uint64_t y)
>  {
> -	uint32_t t = (uint32_t)(((uint64_t)a * R.m) >> 32);
> +	__uint128_t xl = x;
> +	__uint128_t yl = y;
> +	__uint128_t rl = xl * yl;
> +	return (uint64_t)(rl >> 64);
> +}

Cast in return not necessary. And cast when setting t not necessary.
Please blank line after declarations.

Also you don't need to cast both sides of multiply. Some compilers maybe
able to optimize 128 bit * 64 bit.


More information about the dev mailing list