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

require simd_insert, simd_extract indices to be constants #121225

Merged
merged 3 commits into from Feb 22, 2024

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Feb 17, 2024

As discussed in #77477 (see in particular here). This PR doesn't touch codegen yet -- the first step is to ensure that the indices are always constants; the second step is to then make use of this fact in backends.

Blocked on rust-lang/stdarch#1530 propagating to the rustc repo.

@rustbot
Copy link
Collaborator

rustbot commented Feb 17, 2024

r? @oli-obk

rustbot has assigned @oli-obk.
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. labels Feb 17, 2024
@RalfJung RalfJung added the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label Feb 17, 2024
@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the simd-extract-insert-const-idx branch from 26cf1c7 to 6dbe813 Compare February 17, 2024 09:06
@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 17, 2024

I should investigate whether I can do the same trick as #115933 for insert and extract

@RalfJung
Copy link
Member Author

RalfJung commented Feb 17, 2024

Which trick?
Const-generic versions of simd_extract / simd_insert are definitely possible. But with the current status of const generics, stdarch couldn't use them, just like it can't use simd_shuffle_generic. I asked @lcnr about this recently but can't find the link right now...

@oli-obk
Copy link
Contributor

oli-obk commented Feb 17, 2024

Ah, they wanna do math on their own const generics. Yea, that won't work

@RalfJung
Copy link
Member Author

RalfJung commented Feb 17, 2024

I think all they want to do is as casts.^^ (Though I didn't do an exhaustive check to see if that covers everything. And for simd_shuffle, they also need to construct a slice.)

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

r=me when stdsimd has been synced

@RalfJung
Copy link
Member Author

That should be soon hopefully: #121185

@RalfJung RalfJung force-pushed the simd-extract-insert-const-idx branch from 6dbe813 to 396cf1e Compare February 20, 2024 06:50
@RalfJung RalfJung removed the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label Feb 20, 2024
@RalfJung
Copy link
Member Author

RalfJung commented Feb 20, 2024

We had a codegen that that consisted only of calls to simd_insert / simd_extract with variable arguments for the index. @workingjubilee @Amanieu @calebzulawski what are we supposed to do with that, given that we said we want these functions to be like simd_shuffle and only support constant indices? I don't know what the test was actually supposed to test, it had "generic" in the name. See the last commit of this PR.

@RalfJung
Copy link
Member Author

Looks like the test was added in #78863, Cc @KodrAus @gnzlbg

@calebzulawski
Copy link
Member

I think changing those arguments to const generics is appropriate. Typeck or similar should probably have rejected the non-const argument (which is what shuffles do, I think?) It seems packed_simd is really the only consumer of those intrinsics, if std::arch doesn't use them.

@RalfJung
Copy link
Member Author

RalfJung commented Feb 20, 2024

stdarch uses them as well, but since rust-lang/stdarch#1530 it makes all arguments constants. It also had one non-constant use in a test only, somewhat similar to this codegen test.

But if we don't want to support non-constant simd_insert/extract, it makes little sense to have a codegen test for it.

Note that this does not quite make the arguments const generics, instead it makes them special magic arguments that must be const. Moving to const generics is tracked at #85229, but not currently possible yet.

@Amanieu
Copy link
Member

Amanieu commented Feb 20, 2024

I also think it's fine to make these require constants.

@RalfJung
Copy link
Member Author

RalfJung commented Feb 20, 2024 via email

@Amanieu
Copy link
Member

Amanieu commented Feb 21, 2024

It's fine to just remove it. We're changing the definition of simd_insert/simd_extract to only accept constants, which is fine since this is an unstable internal API. That test is no longer relevant.

@RalfJung
Copy link
Member Author

Okay, thanks. :)
@bors r=oli-obk,Amanieu

@bors
Copy link
Contributor

bors commented Feb 21, 2024

📌 Commit e19f89b has been approved by oli-obk,Amanieu

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 Feb 21, 2024
@bors
Copy link
Contributor

bors commented Feb 22, 2024

⌛ Testing commit e19f89b with merge 52dba5f...

@bors
Copy link
Contributor

bors commented Feb 22, 2024

☀️ Test successful - checks-actions
Approved by: oli-obk,Amanieu
Pushing 52dba5f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 22, 2024
@bors bors merged commit 52dba5f into rust-lang:master Feb 22, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 22, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (52dba5f): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.5% [1.5%, 1.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
3.5% [3.5%, 3.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.1% [3.1%, 3.1%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 649.949s -> 649.986s (0.01%)
Artifact size: 310.94 MiB -> 310.96 MiB (0.01%)

@RalfJung RalfJung deleted the simd-extract-insert-const-idx branch February 24, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants