Skip to content

Fix some more uses of LLVM intrinsics #1820

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

Merged
merged 5 commits into from
Jun 2, 2025

Conversation

sayantn
Copy link
Contributor

@sayantn sayantn commented Jun 2, 2025

  • Use rust intrinsics for more ARM intrinsics
  • Fix incorrect intrinsic names (these were autoupgraded by LLVM, so didn't result in invalid IR)
  • Remove uses of deprecated type-specific pointers, LLVM only supports opaque pointers now.

@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
Copy link
Collaborator

rustbot commented Jun 2, 2025

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
Copy link
Contributor

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.

@sayantn sayantn force-pushed the intrinsic-fixes branch from c7826a7 to 10c7473 Compare June 2, 2025 18:28
@Amanieu
Copy link
Member

Amanieu commented Jun 2, 2025

@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
Copy link
Contributor

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

@Amanieu
Copy link
Member

Amanieu commented Jun 2, 2025

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 sayantn force-pushed the intrinsic-fixes branch from 10c7473 to b232fc6 Compare June 2, 2025 18:41
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants