You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Math operations for f16 incorrectly implemented #1622
Those are real functions in C23 and are available with some libms, e.g. https://github.com/llvm/llvm-project/blob/ddb706bbb04a460fb2741268039c69787dc8b2fc/libc/src/math/roundf16.h#L17. I think LLVM will eventually start using them in some lowerings, there are legit usecases (e.g. fmaf16 currently lowers to extend f64 -> fmaf64 -> trunc f16 to get the right precision, but fmaf16 is way cheaper if you don't have hardware f64). So IMO cranelift doesn't need to change anything here, we can just add wrappers in libm that forward to the f32 versions.
Activity
tgross35 commentedon Jan 9, 2026
Those are real functions in C23 and are available with some
libms, e.g. https://github.com/llvm/llvm-project/blob/ddb706bbb04a460fb2741268039c69787dc8b2fc/libc/src/math/roundf16.h#L17. I think LLVM will eventually start using them in some lowerings, there are legit usecases (e.g. fmaf16 currently lowers toextend f64 -> fmaf64 -> trunc f16to get the right precision, but fmaf16 is way cheaper if you don't have hardware f64). So IMO cranelift doesn't need to change anything here, we can just add wrappers in libm that forward to the f32 versions.bjorn3 commentedon Jan 9, 2026
Compiler-builtins doesn't have
logf16at least.tgross35 commentedon Jan 9, 2026
Right, currently - that's why I said we we can just add wrappers there.
tgross35 commentedon Jan 10, 2026
Actually, even easier; we can just add fallbacks to the intrinsics that go via the f32 implementations.
tgross35 commentedon Jan 10, 2026
rust-lang/rust#150946