5

Fix simd_bswap for i8/u8 by calebzulawski · Pull Request #114266 · rust-lang/rus...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/114266
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Fix simd_bswap for i8/u8 #114266

Conversation

Collaborator

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

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

Jul 30, 2023

Member

@compiler-errors compiler-errors

left a comment

Do we expect people to be calling this intrinsic on i8xN? This seems like a misuse of the intrinsic, or at least for LLVM, since llvm.bswap.* says the element needs an even number of bytes.

Contributor

indeed, what are we actually trying to achieve here?

Member

Author

This mirrors the scalar bswap intrinsic:

It would be a bit of a pain to special-case i8/u8 vectors in std::simd.

workingjubilee reacted with eyes emoji

Contributor

or more precisely, what is the current behavior we're trying to avoid?

Member

Author

or more precisely, what is the current behavior we're trying to avoid?

I thought LLVM would handle a no-op, but instead the compiler crashes:

warning: build failed, waiting for other jobs to finish...
bswap must be an even number of bytes
  %4 = call <32 x i8> @llvm.bswap.v32i8(<32 x i8> %3), !dbg !858
in function _ZN113_$LT$core_simd..core_simd..vector..Simd$LT$i8$C$_$GT$$u20$as$u20$core_simd..core_simd..elements..int..SimdInt$GT$10swap_bytes17h00fedc46e657fc9cE
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `core_simd` (test "i8_ops")

Member

@compiler-errors compiler-errors

left a comment

I guess r=me if @workingjubilee thinks that this is worthwhile -- the fact that we're special-casing i8 in both the simd and non-simd bswap intrinsics is a tiny bit odd, but I could believe it makes sense with like... macro-generated code or something. Still kinda sus, though.

Contributor

lmao llvm

Member

Author

Both scalar integers and std::simd integer vectors are macro-generated upside_down_face No users should be seeing these intrinsics.

To be fair to LLVM, it says very clearly that the intrinsic is only defined when BitWidth % 16 == 0.

calebzulawski reacted with thumbs up emoji

Contributor

I guess r=me if @workingjubilee thinks that this is worthwhile

yeaaaaah, I guess.

but I could believe it makes sense with like... macro-generated code or something

that describes all of std's integer impls, baby!

@bors r=compiler-errors

compiler-errors reacted with laugh emoji

Contributor

pushpin Commit 77ed437 has been approved by compiler-errors

It is now in the queue for this repository.

Contributor

@bors r- rollup=iffy
cc #114270

I have no idea but I'm almost certain it's this PR.

bors

added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

labels

Jul 31, 2023

Member

Author

The failed test is tests/ui/lint/must_not_suspend/handled.rs, I don't see any way this PR could affect that. Maybe spurious?

Contributor

...hm yeah you're right, I misread the logs at-a-glance.

Probably is spurious then.

@bors r=compiler-errors

Contributor

pushpin Commit 77ed437 has been approved by compiler-errors

It is now in the queue for this repository.

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-author Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jul 31, 2023

Contributor

hourglass Testing commit 77ed437 with merge 3be07c1...

Contributor

sunny Test successful - checks-actions
Approved by: compiler-errors
Pushing 3be07c1 to master...

bors

added the merged-by-bors This PR was explicitly merged by bors label

Jul 31, 2023

bors

merged commit 3be07c1 into

rust-lang:master

Jul 31, 2023

12 checks passed

Collaborator

Finished benchmarking commit (3be07c1): comparison URL.

Overall result: x regressions - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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 x
(secondary)
5.8% [5.8%, 5.8%] 1
Improvements ✅
(primary)
- - 0
Improvements white_check_mark
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

Cycles

Results

Binary size

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

Bootstrap: 652.418s -> 653.862s (0.22%)

rustbot

added the perf-regression Performance regressions label

Jul 31, 2023

Contributor

One possible, marginal regression, nothing to worry about.

@rustbot label: +perf-regression-triaged

rustbot

added the perf-regression-triaged The performance regression has been triaged. label

Jul 31, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

compiler-errors

compiler-errors left review comments
Labels
merged-by-bors This PR was explicitly merged by bors perf-regression Performance regressions perf-regression-triaged The performance regression has been triaged. 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

Milestone

1.73.0

Development

Successfully merging this pull request may close these issues.

None yet

7 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK