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
Simplify u128->f32 casts thanks to LLVM r334777 #51872
This issue tracks two improvements we can make to our codegen after some LLVM updates, to avoid them being buried in a closed issue.
As @nikic pointed out, https://reviews.llvm.org/D47807 defines overflow in u128->f32 casts as resulting in infinity. With that patch, we don't need to manually emit the "is the u128 >= f32::MAX + 0.5 ULP?" check as we currently do and can go back to just emitting a simple uitofp (as we have always done for {u8,u16,u32,u64} -> float casts). However, because of our policy of supporting older LLVM versions, there are actually two steps we can take here at different times:
At any time we can backport the patch to our LLVM fork, and skip emitting the check only if compiling with our fork
Once we drop support for all LLVM versions that don't have this patch (if I'm not mistaken, it would first be released in LLVM 7), remove our special handling of u128->f32 casts altogether
The latter is honestly the more important step. I doubt there is any significant code size or performance impact from the extra check, but it would be nice to get rid of the tricky code in rustc that is required to implement it.
Reacted by kennytm, est31, gnzlbg, LifeIsStrange, Esteban Kuber, Bernardo Meurer and scottmcm
Activity
bjorn3 commentedon Sep 7, 2019
Is it already defined on the lowest supported LLVM version?
hanna-kruppe commentedon Sep 7, 2019
It's in LLVM 7 but we still support LLVM 6 right now.
hanna-kruppe commentedon Dec 3, 2019
#66973 bumps our minimum LLVM version to 7 so once that's landed we can do this.
Remove now-redundant range check on u128 -> f32 casts
Rollup merge of rust-lang#67328 - rkruppe:simplify-u128-f32-cast, r=m…
Rollup merge of rust-lang#67328 - rkruppe:simplify-u128-f32-cast, r=m…
Rollup merge of rust-lang#67328 - rkruppe:simplify-u128-f32-cast, r=m…
Rollup merge of rust-lang#67328 - rkruppe:simplify-u128-f32-cast, r=m…
Rollup merge of rust-lang#67328 - rkruppe:simplify-u128-f32-cast, r=m…