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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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
Contributor

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
Contributor

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

@rust-log-analyzer

This comment has been minimized.

@scottmcm
Copy link
Member

Thanks, this is looking good! One more request, then r=me.

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants