Fix some more uses of LLVM intrinsics by sayantn · Pull Request #1820 · rust-lang/stdarch (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation6 Commits5 Checks62 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@sayantn

@folkertdev is it okay to replace the llvm.{u,s}{max,min} calls with something like simd_select(simd_gt(a, b), a, b))? I am just worried if it will optimize well

edit: seems like it is not a problem actually https://godbolt.org/z/6r1javWc6

@rustbot

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@folkertdev

Just try it, you can check whether that works by running the docker container. We should be testing for the specific instruction (adjust for your target):

TARGET=aarch64-unknown-linux-gnu sh ci/run-docker.sh aarch64-unknown-linux-gnu

If it doesn't work, let me know because we should get that fixed in LLVM.

@Amanieu

@folkertdev is it okay to replace the llvm.{u,s}{max,min} calls with something like simd_select(simd_gt(a, b), a, b))? I am just worried if it will optimize well

No, those 2 are not equivalent, specifically with regards to negative zero and NaN.

@folkertdev

umax and smax are only for integers right? For floats the expressions are indeed not equivalent in some nasty ways.

@Amanieu

The fact that LLVM generates the same code for both suggests a bug in the LLVM backend.

Nevermind, it's fine if this is only for integers.

@sayantn

This comment was marked as resolved.

@Amanieu Amanieu added this pull request to the merge queue

Jun 2, 2025

Merged via the queue into rust-lang:master with commit 86c8496

Jun 2, 2025

62 checks passed

bors added a commit to rust-lang/rust that referenced this pull request

Jun 7, 2025

@bors

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request

Jun 8, 2025

@bors

bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request

Jun 8, 2025

@bors

github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request

Jun 9, 2025

@bors

lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request

Jun 9, 2025

@bors

tautschnig pushed a commit to model-checking/verify-rust-std that referenced this pull request

Jun 17, 2025

@bors