[llvm-dev] Saturating float-to-int casts
Josh Stone via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 7 17:54:30 PDT 2020
On 8/7/20 7:19 AM, David Lloyd via llvm-dev wrote:
> I have encountered a need for float-to-int casts that saturate to
> min/max when the value is out of the range of the target type. It
> seems that there is no intrinsic to do this, currently, but on IRC it
> was pointed out that a patch [1] has been proposed to implement this
> functionality in exactly the way that I was looking for.
>
> It looks like the discussion has died out but I was hoping maybe to
> kick it off again.
>
> [1] https://reviews.llvm.org/D54749
FWIW, Rust 1.45 just enabled saturation by default for float-to-int
casts, implemented above LLVM IR -- you can find that here:
https://github.com/rust-lang/rust/blob/c2d1b0d9800d922b0451921d2ce17e6ae665d5b4/src/librustc_codegen_ssa/mir/rvalue.rs#L769
And there are intrinsics for WebAssembly, at least, seen here:
https://github.com/rust-lang/rust/blob/c2d1b0d9800d922b0451921d2ce17e6ae665d5b4/src/librustc_codegen_llvm/builder.rs#L656-L704
Target-neutral intrinsics would be nice though...
More information about the llvm-dev
mailing list