On Mon, Oct 23, 2023, at 14:10, Jason Gunthorpe wrote: > On Mon, Oct 23, 2023 at 10:28:13AM +0100, Joao Martins wrote: >> > so it's probably >> > best to add a range check plus type cast, rather than an >> > expensive div_u64() here. >> >> OK > > Just keep it simple, we don't need to optimize for 32 bit. div_u64 > will make the compiler happy. Fair enough. FWIW, I tried adding just the range check to see if that would make the compiler turn it into a 32-bit division, but that didn't work. Some type of range check might still be good to have for unrelated reasons. Arnd