Skip to content

Less cloning in early otherwise branch #77472

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

Conversation

simonvandel
Copy link
Contributor

This is probably easiest read commit by commit.

@rust-highfive
Copy link
Contributor

r? @eddyb

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 2, 2020
@jyn514 jyn514 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 3, 2020
@bors

This comment has been minimized.

@simonvandel simonvandel force-pushed the refactor-early-otherwise-branch branch from 1106178 to 1a8d28a Compare October 14, 2020 15:35
@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. I-compiletime Issue: Problems and improvements with respect to compile times. labels Oct 30, 2020
@@ -300,7 +299,6 @@ impl<'a, 'tcx> Helper<'a, 'tcx> {
// the declaration of the discriminant read. Place of this read is being used in the switch
let discr_decl = &self.body.local_decls()[discr_local];
let discr_ty = discr_decl.ty;
// the otherwise target lies as the last element
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you meant to remove this comment.

Comment on lines -253 to -254
// check that the value being matched on is the same. The
if this_bb_discr_info.targets_with_values.iter().find(|x| x.0 == value).is_none() {
Copy link
Member

Choose a reason for hiding this comment

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

Where is this check duplicated? The check above does not look at targets_with_values at all.

Comment on lines +263 to +271
// The types of the two adts matched on have to be equal for this optimization to apply
if discr_info.type_adt_matched_on != this_bb_discr_info.type_adt_matched_on {
trace!(
"NO: types do not match. LHS: {:?}, RHS: {:?}",
discr_info.type_adt_matched_on,
this_bb_discr_info.type_adt_matched_on
);
return None;
}
Copy link
Member

Choose a reason for hiding this comment

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

There doesn't seem to be much point to this change without benchmarks. Personally I would expect a simple != to be faster than two conditionals.

@@ -198,36 +196,36 @@ struct OptimizationToApply<'tcx> {
struct OptimizationInfo<'tcx> {
/// Info about the first switch and discriminant
first_switch_info: SwitchDiscriminantInfo<'tcx>,
/// Info about the second switch and discriminant
second_switch_info: SwitchDiscriminantInfo<'tcx>,
/// Info about all swtiches that are successors of the first switch
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Info about all swtiches that are successors of the first switch
/// Info about all switches that are successors of the first switch

@camelid camelid added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 20, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2020

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned eddyb Nov 26, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2020

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Collaborator

bors commented Nov 26, 2020

⌛ Trying commit 1a8d28a with merge 556d995f6cd76d0ded6c51fa190e2ebf48671659...

@bors
Copy link
Collaborator

bors commented Nov 26, 2020

☀️ Try build successful - checks-actions
Build commit: 556d995f6cd76d0ded6c51fa190e2ebf48671659 (556d995f6cd76d0ded6c51fa190e2ebf48671659)

@rust-timer
Copy link
Collaborator

Queued 556d995f6cd76d0ded6c51fa190e2ebf48671659 with parent 0d96516, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (556d995f6cd76d0ded6c51fa190e2ebf48671659): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-perf

@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2020

No measurable impact. I'll go over the code later, but I think we should thus only take the commits that improve readability

@camelid
Copy link
Member

camelid commented Dec 18, 2020

@simonvandel Could you address Oli's comments? By the way, you have some merge conflicts.

@camelid camelid 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 Dec 18, 2020
@simonvandel
Copy link
Contributor Author

I currently don't have the time to work on this, unfortunately. If you prefer to close it for now, then feel tree to do so.

@Dylan-DPC-zz Dylan-DPC-zz added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. I-compiletime Issue: Problems and improvements with respect to compile times. S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

10 participants