Description
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.