[llvm-dev] Saturating float-to-int casts

Thomas Lively via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 7 21:23:57 PDT 2020


I would be happy to be able to replace the WebAssembly-specific saturating
float-to-int intrinsics with target-independent versions if they were
available. I have a patch up implementing constant folding for the
WebAssembly intrinsics at https://reviews.llvm.org/D85392. They're more
limited than the proposed target-independent intrinsics, but perhaps the
tests from that patch would be helpful, at least.

On Fri, Aug 7, 2020 at 5:54 PM Josh Stone via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> 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...
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200807/3a75c8b1/attachment-0001.html>


More information about the llvm-dev mailing list