[libc-commits] [libc] [libc][stdfix] Implement divifx functions in LLVM libc (PR #206115)

via libc-commits libc-commits at lists.llvm.org
Mon Jul 13 11:02:03 PDT 2026


PiJoules wrote:

> @PiJoules Do we want to add the variants that aren't in the TR (divifx for unsigned/signed short fract/accum) to LLVM libc or stick to the TR document? Are there any targets with native 16 bit arithmetic that might use these routines?
> 
> I imagine for most targets that have 32 bit wide registers or anything wider than that, directly using the routines for fract/accum or long fract/accum would perform better because that would only require a typecast before the function call and another one after return rather than the compiler emitting extra emulation sequences (sign extensions and narrowing) to preserve 16 bit semantics while doing 32 or 64 bit arithmetic. Since this uses an integer division after widening instead of newton raphson or some other approximation method I think the result should be identical in both cases.

Yeah I could see that though I don't know of any hardware we could check this with. I think going by what we have in the standard now is good then if we see use cases for those other functions we could add them later.

https://github.com/llvm/llvm-project/pull/206115


More information about the libc-commits mailing list