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

Allow optimizing u32::from::<char>. #124905

Merged
merged 6 commits into from
Jul 27, 2024
Merged

Conversation

reitermarkus
Copy link
Contributor

Extracted from #124307.

This allows optimizing the panicking branch in the escape_unicode function, see https://rust.godbolt.org/z/61YhKrhvP.

@rustbot
Copy link
Collaborator

rustbot commented May 8, 2024

r? @workingjubilee

rustbot has assigned @workingjubilee.
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-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 8, 2024
@reitermarkus reitermarkus changed the title https://rust.godbolt.org/z/61YhKrhvP Allow optimizing u32::from::<char>. May 8, 2024
@reitermarkus
Copy link
Contributor Author

r? @joboet

@rustbot rustbot assigned joboet and unassigned workingjubilee May 8, 2024
@the8472
Copy link
Member

the8472 commented May 9, 2024

You could use a transmute, it already emits the right assume in optimized builds

https://rust.godbolt.org/z/r7sqdcdzh

@joboet
Copy link
Member

joboet commented May 9, 2024

Arguably this should be done in the backend for char as u32 so that everyone can benefit from it.

@reitermarkus
Copy link
Contributor Author

Arguably this should be done in the backend for char as u32 so that everyone can benefit from it.

Agreed, however I don't know where the code for that lives.

@clubby789
Copy link
Contributor

That would be

(CastTy::Int(i), CastTy::Int(_)) => {
bx.intcast(llval, ll_t_out, i.is_signed())
}

@joboet
Copy link
Member

joboet commented May 10, 2024

I don't feel comfortable reviewing compiler changes, so
r? compiler

That said, I think this is a good idea!

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 10, 2024
@rustbot rustbot assigned TaKO8Ki and unassigned joboet May 10, 2024
@bors
Copy link
Contributor

bors commented May 10, 2024

☔ The latest upstream changes (presumably #123886) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 11, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 11, 2024

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust.git master
$ git push --force-with-lease

The following commits are merge commits:

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 11, 2024
@clubby789
Copy link
Contributor

Probably best to squash the first two commits, since they add then revert the library change

@reitermarkus
Copy link
Contributor Author

@scottmcm, I think changing the test to use ilog2 broke it. It still seems to work for each of the test functions individually, but if both are in the same file, it fails.

@scottmcm
Copy link
Member

@reitermarkus Sorry for being slow to get back to you here. The changes are looking good and CI is passing, but based on your previous comment that's only because CI doesn't run the codegen test? What's output IR you get?

Alternatively, if you need to change x.ilog2() to 32 - x.leading_zeros() that'd be fine too. I guess it's possible the extra checks in ilog2 are confusing things a bit? (My recollection was that mostly my confusion from the former was that it was a non-trivial expression to figure out as a human why the test should do the right thing, but something simpler that's not ilog2 would also be ok.)

@scottmcm
Copy link
Member

@reitermarkus Ping for the above?
@rustbot author

@rustbot rustbot 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 Jul 17, 2024
@reitermarkus
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot 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 Jul 21, 2024
@scottmcm
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Jul 27, 2024

📌 Commit 2f2eb22 has been approved by scottmcm

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 Jul 27, 2024
@bors
Copy link
Contributor

bors commented Jul 27, 2024

⌛ Testing commit 2f2eb22 with merge 3942254...

@bors
Copy link
Contributor

bors commented Jul 27, 2024

☀️ Test successful - checks-actions
Approved by: scottmcm
Pushing 3942254 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 27, 2024
@bors bors merged commit 3942254 into rust-lang:master Jul 27, 2024
7 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Jul 27, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3942254): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.2% [0.2%, 0.3%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-0.2%, 0.3%] 5

Max RSS (memory usage)

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

Cycles

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

Binary size

Results (primary 0.2%, secondary 0.4%)

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)
0.3% [0.0%, 0.7%] 16
Regressions ❌
(secondary)
0.7% [0.4%, 0.7%] 37
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 1
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 23
All ❌✅ (primary) 0.2% [-0.0%, 0.7%] 17

Bootstrap: 769.985s -> 771.748s (0.23%)
Artifact size: 328.95 MiB -> 329.08 MiB (0.04%)

@rustbot rustbot added the perf-regression Performance regression. label Jul 27, 2024
@pnkfelix
Copy link
Member

Visiting for weekly rustc-perf triage

  • regressions are to image opt {full, incr-full}, cargo opt {full, incr-full}, and syn opt incr-unchanged
  • It appears that its due to extra time spent in LLVM opt, especially lto optimize, which makes sense given that this is meant to be enabling LLVM to attempt more such optimizations?
  • marking as triaged.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jul 31, 2024
@reitermarkus reitermarkus deleted the u32-from-char-opt branch August 10, 2024 15:29
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. perf-regression Performance regression. 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. 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.