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

match lowering: handle or-patterns one layer at a time #122046

Merged
merged 2 commits into from Apr 1, 2024

Conversation

Nadrieril
Copy link
Contributor

@Nadrieril Nadrieril commented Mar 5, 2024

create_or_subcandidates and merge_trivial_subcandidates both call themselves recursively to handle nested or-patterns, which is hard to follow. In this PR I avoid the need for that; we now process a single "layer" of or-patterns at a time.

By calling back into match_candidates, we only need to expand one layer at a time. Conversely, since we always try to simplify a layer that we just expanded (thanks to #123067), we only have to merge one layer at a time.

r? @matthewjasper

@rustbot 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 Mar 5, 2024
@bors

This comment was marked as resolved.

@Nadrieril
Copy link
Contributor Author

Gentle ping on this one, I got a few things blocked on it

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 26, 2024
…i-obk

match lowering: consistently merge simple or-patterns

There are two places where we expand or-patterns in match lowering: the main one is `test_candidates_with_or`, and there's one in `match_candidates` that's an optimization for the simple case where the whole pattern is just one or-pattern.

To reduce duplication, we merge or-pattern alternatives into a single block when possible, but we only to that in `test_candidates_with_or`. This PR fixes this oversight and merges them in `match_candidates` too.

This is a part of splitting up rust-lang#122046 into smaller bits.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 26, 2024
Rollup merge of rust-lang#123067 - Nadrieril:always-simplify-or, r=oli-obk

match lowering: consistently merge simple or-patterns

There are two places where we expand or-patterns in match lowering: the main one is `test_candidates_with_or`, and there's one in `match_candidates` that's an optimization for the simple case where the whole pattern is just one or-pattern.

To reduce duplication, we merge or-pattern alternatives into a single block when possible, but we only to that in `test_candidates_with_or`. This PR fixes this oversight and merges them in `match_candidates` too.

This is a part of splitting up rust-lang#122046 into smaller bits.
@bors

This comment has been minimized.

By calling back into `match_candidates`, we only need to expand one
layer at a time. Conversely, since we always try to simplify a layer
that we just expanded, we only have to merge one layer at a time.
@Nadrieril Nadrieril force-pushed the integrate-or-pats2 branch 2 times, most recently from 15de647 to 23c9f69 Compare March 27, 2024 19:47
@Nadrieril
Copy link
Contributor Author

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned matthewjasper Mar 27, 2024
@matthewjasper
Copy link
Contributor

Sorry about taking so long on this
r? @matthewjasper
@bors r+

@bors
Copy link
Contributor

bors commented Apr 1, 2024

📌 Commit 7410f78 has been approved by matthewjasper

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 Apr 1, 2024
@bors
Copy link
Contributor

bors commented Apr 1, 2024

⌛ Testing commit 7410f78 with merge 6bb6b81...

@bors
Copy link
Contributor

bors commented Apr 1, 2024

☀️ Test successful - checks-actions
Approved by: matthewjasper
Pushing 6bb6b81 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 1, 2024
@bors bors merged commit 6bb6b81 into rust-lang:master Apr 1, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 1, 2024
@Nadrieril Nadrieril deleted the integrate-or-pats2 branch April 1, 2024 14:38
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6bb6b81): 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
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

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
Regressions ❌
(secondary)
1.7% [1.4%, 1.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

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

Binary size

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

Bootstrap: 669.305s -> 667.497s (-0.27%)
Artifact size: 315.75 MiB -> 315.72 MiB (-0.01%)

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

Successfully merging this pull request may close these issues.

None yet

6 participants