rust-lang / miri

An interpreter for Rust's mid-level intermediate representation
Apache License 2.0
4.16k stars 318 forks source link

Use apfloat for full-precision sqrt #3534

Open RalfJung opened 2 months ago

RalfJung commented 2 months ago

With https://github.com/rust-lang/rust/pull/121793 and https://github.com/rust-lang/rust/pull/118217, most float functions are now documented to have varying precision, so using host floats for them in Miri is actually fine. The only exceptions are mul_add (tracked at https://github.com/rust-lang/miri/issues/2995) and sqrt -- those guarantee an infinite-precision result, so we should ideally use softfloats. (That said, using host floats is not wrong here since the host functions are in fact guaranteeing the infinite-precision result we are supposed to be emulating. Still, it seems cleaner to use softfloats for everything where precision is guaranteed.)

This is blocked on https://github.com/rust-lang/rustc_apfloat/issues/14.