5

Let codegen decide when to `mem::swap` with immediates by scottmcm · Pull Reques...

 1 month ago
source link: https://github.com/rust-lang/rust/pull/122582
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.

Let codegen decide when to mem::swap with immediates #122582

Conversation

Member

Making libcore decide this is silly; the backend has so much better information about when it's a good idea.

Thus this PR introduces a new typed_swap intrinsic with a fallback body, and replaces that fallback implementation when swapping immediates or scalar pairs.

r? oli-obk

Replaces #111744, and means we'll never need more libs PRs like #111803 or #107140

coolreader18 reacted with heart emoji

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

Mar 16, 2024

This comment has been minimized.

scottmcm

marked this pull request as draft

March 16, 2024 05:45

scottmcm

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-review Status: Awaiting review from the assignee but also interested parties.

labels

Mar 16, 2024

scottmcm

marked this pull request as ready for review

March 16, 2024 09:23

Collaborator

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

The Miri subtree was changed

cc @rust-lang/miri

scottmcm

added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

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

labels

Mar 16, 2024

Member

Author

This comment has been minimized.

Contributor

⌛ Trying commit e583c57 with merge 3f68c63...

Contributor

☀️ Try build successful - checks-actions
Build commit: 3f68c63 (3f68c63f114f4d57b01ae74bc549e4b68f955eee)

This comment has been minimized.

This comment was marked as outdated.

rustbot

added perf-regression Performance regressions

and removed S-waiting-on-perf Status: Waiting on a perf run to be completed.

labels

Mar 16, 2024

@@ -954,6 +954,23 @@ pub const unsafe fn swap<T>(x: *mut T, y: *mut T) {

}

}

/// Non-overlapping *typed* swap of a single value.

Should it be called typed_swap_nonoverlapping?

Member

Author

I went back and forth multiple times on this. typed_swap_nonoverlapping sounds to me like ptr::swap_nonoverlapping, just typed. So that would make this typed_swap_nonoverlapping_one or something, and now that's just seeming really long.

So since it's internal, I think I'm inclined to leave it as-is for now unless someone feels particularly strongly about it.

I feel like the "nonoverlapping" distinction is way more fundamental than the "one" distinction. And since it is internal, consistency with ptr::swap_nonoverlapping isn't very important IMO.

This comment has been minimized.

Contributor

💔 Test failed - checks-actions

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

Mar 23, 2024

Member

Author

@bors r=oli-obk

Contributor

📌 Commit 75d2e5b has been approved by oli-obk

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-review Status: Awaiting review from the assignee but also interested parties.

labels

Mar 23, 2024

Contributor

⌛ Testing commit 75d2e5b with merge ea4d0e9044c417ec9df5b45620f316879fd179c2...

Contributor

💥 Test timed out

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

Mar 23, 2024

Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

Member

@bors retry

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

Mar 23, 2024

Contributor

⌛ Testing commit 75d2e5b with merge d6eb0f5...

Contributor

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing d6eb0f5 to master...

Collaborator

Finished benchmarking commit (d6eb0f5): comparison URL.

Overall result: ✅ improvements - 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)
- - 0
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 1

Max RSS (memory usage)

Results

Cycles

Results

Binary size

Results

Bootstrap: 669.588s -> 671.198s (0.24%)
Artifact size: 315.05 MiB -> 314.95 MiB (-0.03%)

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

Reviewers

RalfJung

RalfJung left review comments

oli-obk

oli-obk left review comments

the8472

the8472 left review comments
Assignees

oli-obk

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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects

None yet

Milestone

1.79.0

Development

Successfully merging this pull request may close these issues.

None yet

9 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK