Re: [PATCH v3 next 09/10] lib: mul_u64_u64_div_u64() Optimise the divide code
From: Nicolas Pitre
Date: Wed Jun 18 2025 - 12:43:00 EST
On Wed, 18 Jun 2025, Nicolas Pitre wrote:
> On Wed, 18 Jun 2025, David Laight wrote:
>
> > If the low divisor bits are zero an alternative simpler divide
> > can be used (you want to detect it before the left align).
> > I deleted that because it complicates things and probably doesn't
> > happen often enough outside the tests cases.
>
> Depends. On 32-bit systems that might be worth it. Something like:
>
> if (unlikely(sizeof(long) == 4 && !(u32)d))
> return div_u64(n_hi, d >> 32);
Well scratch that. Won't work obviously.
Nicolas