Re: [PATCH] math64: Provide an uprounding variant of mul_u64_u64_div_u64()

From: Nicolas Pitre
Date: Tue Apr 01 2025 - 16:30:43 EST


On Tue, 1 Apr 2025, Nicolas Pitre wrote:

> On Tue, 1 Apr 2025, David Laight wrote:
>
> > Looking at the C version, I wonder if the two ilog2() calls are needed.
> > They may not be cheap, and are the same as checking 'n_hi == 0'.
>
> Which two calls? I see only one.

Hmmm, sorry. If by ilog2() you mean the clz's then those are cheap. Most
CPUs have a dedicated instruction for that. The ctz, though, is more
expensive (unless it is ARMv7 and above with an RBIT instruction).

> And please explain how it can be the same as checking 'n_hi == 0'.

This question still stands.


Nicolas