pub const fn div_u64_by_u32(hi: u32, lo: u32, divisor: u32) -> u32Expand description
floor((hi * 2^32 + lo) / divisor) for a quotient that fits u32, in
32-bit operations only.
Requires divisor != 0 and hi < divisor, which is exactly the shape of
a Q12 fraction (numerator <= denominator) or a segment interpolation
(|delta| * fraction_numerator / denominator with the numerator at most
the denominator). The R3000A divides 32 by 32 in hardware but has no
64-by-32 form. This normalizes the divisor and produces the quotient as
two base-65536 digits, each from one native divu plus at most two
corrections (Hollow Knight’s quotient32). On the emulator microbench it
costs 178 cycles a call against 510 for the 32-step restoring loop it
replaced (random divisors of every magnitude). The generic
compiler-builtins u64_div_rem before that was 1,412 bytes of branchy
code and the only 64-bit divide reachable from runtime code.