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

simd_shuffle: require index argument to be a vector #130268

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

RalfJung
Copy link
Member

Remove some codegen hacks by forcing the SIMD shuffle index argument to be a vector, which means (thanks to #128537) that it will automatically be passed as an immediate in LLVM. The only special-casing we still have is for the extra sanity-checks we add that ensure that the indices are all in-bounds. (And the GCC backend needs to do a bunch of work since the Rust intrinsic is modeled after what LLVM expects, which seems to be quite different from what GCC expects.)

Fixes #128738, see that issue for more context.

@rustbot
Copy link
Collaborator

rustbot commented Sep 12, 2024

r? @petrochenkov

rustbot has assigned @petrochenkov.
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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 12, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 12, 2024

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Portable SIMD is developed in its own repository. If possible, consider making this change to rust-lang/portable-simd instead.

cc @calebzulawski, @programmerjake

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

Some changes occurred to the platform-builtins intrinsics. Make sure the
LLVM backend as well as portable-simd gets adapted for the changes.

cc @antoyo, @GuillaumeGomez, @bjorn3, @calebzulawski, @programmerjake

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool work

mask_elements
};
let mask_num_units = mask_elements.len();
let vector_type = mask.get_type().dyncast_vector().unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect here?

// third argument must be constant. This is
// checked by the type-checker.
if i == 2 && intrinsic.name == sym::simd_shuffle {
// FIXME: the simd_shuffle argument is actually an array,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ glad to see this hack go away lol

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah me too :D

@compiler-errors
Copy link
Member

i left a nit but whatever, probably not worth fixing

@bors r+

@bors
Copy link
Contributor

bors commented Sep 13, 2024

📌 Commit 45872e8 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 13, 2024
@RalfJung
Copy link
Member Author

Too late, nit is fixed now. ;)

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Sep 13, 2024

📌 Commit 5287fa3 has been approved by compiler-errors

It is now in the queue for this repository.

@RalfJung
Copy link
Member Author

And another conflict.

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Sep 13, 2024

📌 Commit 7a1b5e5 has been approved by compiler-errors

It is now in the queue for this repository.

Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 14, 2024
…r=compiler-errors

simd_shuffle: require index argument to be a vector

Remove some codegen hacks by forcing the SIMD shuffle `index` argument to be a vector, which means (thanks to rust-lang#128537) that it will automatically be passed as an immediate in LLVM. The only special-casing we still have is for the extra sanity-checks we add that ensure that the indices are all in-bounds. (And the GCC backend needs to do a bunch of work since the Rust intrinsic is modeled after what LLVM expects, which seems to be quite different from what GCC expects.)

Fixes rust-lang#128738, see that issue for more context.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 14, 2024
Rollup of 3 pull requests

Successful merges:

 - rust-lang#130053 (fix doc comments for Peekable::next_if(_eq))
 - rust-lang#130268 (simd_shuffle: require index argument to be a vector)
 - rust-lang#130334 (Fix `SDKROOT` ignore on macOS)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Sep 14, 2024

⌛ Testing commit 7a1b5e5 with merge 6390091...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 14, 2024
…compiler-errors

simd_shuffle: require index argument to be a vector

Remove some codegen hacks by forcing the SIMD shuffle `index` argument to be a vector, which means (thanks to rust-lang#128537) that it will automatically be passed as an immediate in LLVM. The only special-casing we still have is for the extra sanity-checks we add that ensure that the indices are all in-bounds. (And the GCC backend needs to do a bunch of work since the Rust intrinsic is modeled after what LLVM expects, which seems to be quite different from what GCC expects.)

Fixes rust-lang#128738, see that issue for more context.
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Sep 14, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 14, 2024
@RalfJung
Copy link
Member Author

Seems like I have to make sure to not emit an intrinsic when the index is OOB. Makes sense. The last patch should fix that.

@compiler-errors does that seem right to you?

@compiler-errors
Copy link
Member

Yeah, makes sense.

@bors r+

@bors
Copy link
Contributor

bors commented Sep 14, 2024

📌 Commit 60ee1b7 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 14, 2024
Rollup of 6 pull requests

Successful merges:

 - rust-lang#130017 (coverage: Extract `executor::block_on` from several async coverage tests)
 - rust-lang#130268 (simd_shuffle: require index argument to be a vector)
 - rust-lang#130290 (Stabilize entry_insert)
 - rust-lang#130294 (Lifetime cleanups)
 - rust-lang#130343 (docs: Enable required feature for 'closure_returning_async_block' lint)
 - rust-lang#130349 (Fix `Parser::break_up_float`'s right span)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a9dcd7f into rust-lang:master Sep 14, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 14, 2024
Rollup merge of rust-lang#130268 - RalfJung:simd-shuffle-idx-vector, r=compiler-errors

simd_shuffle: require index argument to be a vector

Remove some codegen hacks by forcing the SIMD shuffle `index` argument to be a vector, which means (thanks to rust-lang#128537) that it will automatically be passed as an immediate in LLVM. The only special-casing we still have is for the extra sanity-checks we add that ensure that the indices are all in-bounds. (And the GCC backend needs to do a bunch of work since the Rust intrinsic is modeled after what LLVM expects, which seems to be quite different from what GCC expects.)

Fixes rust-lang#128738, see that issue for more context.
@RalfJung RalfJung deleted the simd-shuffle-idx-vector branch September 15, 2024 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

simd_shuffle cleanup: make the mask argument a vector (instead of an array)
7 participants