Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc: Use LLVM's new saturating float-to-int intrinsics #84339

Merged
merged 3 commits into from
Apr 23, 2021

Commits on Apr 21, 2021

  1. rustc: Use LLVM's new saturating float-to-int intrinsics

    This commit updates rustc, with an applicable LLVM version, to use
    LLVM's new `llvm.fpto{u,s}i.sat.*.*` intrinsics to implement saturating
    floating-point-to-int conversions. This results in a little bit tighter
    codegen for x86/x86_64, but the main purpose of this is to prepare for
    upcoming changes to the WebAssembly backend in LLVM where wasm's
    saturating float-to-int instructions will now be implemented with these
    intrinsics.
    
    This change allows simplifying a good deal of surrounding code, namely
    removing a lot of wasm-specific behavior. WebAssembly no longer has any
    special-casing of saturating arithmetic instructions and the need for
    `fptoint_may_trap` is gone and all handling code for that is now
    removed. This means that the only wasm-specific logic is in the
    `fpto{s,u}i` instructions which only get used for "out of bounds is
    undefined behavior". This does mean that for the WebAssembly target
    specifically the Rust compiler will no longer be 100% compatible with
    pre-LLVM 12 versions, but it seems like that's unlikely to be relied on
    by too many folks.
    
    Note that this change does immediately regress the codegen of saturating
    float-to-int casts on WebAssembly due to the specialization of the LLVM
    intrinsic not being present in our LLVM fork just yet. I'll be following
    up with an LLVM update to pull in those patches, but affects a few other
    SIMD things in flight for WebAssembly so I wanted to separate this change.
    
    Eventually the entire `cast_float_to_int` function can be removed when
    LLVM 12 is the minimum version, but that will require sinking the
    complexity of it into other backends such as Cranelfit.
    alexcrichton committed Apr 21, 2021
    Configuration menu
    Copy the full SHA
    de2a460 View commit details
    Browse the repository at this point in the history

Commits on Apr 23, 2021

  1. Disable LLVM's new fptoint intrinsics on riscv64

    Looks like this platform still isn't quite working yet due to
    https://bugs.llvm.org/show_bug.cgi?id=50083
    alexcrichton committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    35ae752 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ed6dd40 View commit details
    Browse the repository at this point in the history