Skip to content

Conversation

@dianqk
Copy link
Member

@dianqk dianqk commented Oct 23, 2025

I have overhauled MatchBranchSimplification in this PR. This pass is tested merge cases one by one, which is more readable and extensible.

This PR also merges the following pattern that is mostly generated by GVN into one basic block that contains the copy statement:

match a {
    Foo::A(_) => *a,
    Foo::B => Foo::B
}

Fixes #128081.

@rustbot rustbot added 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. labels Oct 23, 2025
@dianqk
Copy link
Member Author

dianqk commented Oct 23, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 23, 2025
rust-bors bot added a commit that referenced this pull request Oct 23, 2025
[WIP] Simplify the canonical enum clone branches to a copy statement
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Oct 23, 2025

💔 Test for b4269e3 failed: CI. Failed jobs:

@dianqk
Copy link
Member Author

dianqk commented Oct 23, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 23, 2025
[WIP] Simplify the canonical enum clone branches to a copy statement
@rust-bors
Copy link

rust-bors bot commented Oct 24, 2025

☀️ Try build successful (CI)
Build commit: 673e3f6 (673e3f61f8b218d304147e821d485edf0ebf3b09, parent: 6501e64fcb02d22b49d6e59d10a7692ec8095619)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (673e3f6): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.7% [0.7%, 0.7%] 1
Regressions ❌
(secondary)
0.3% [0.3%, 0.4%] 6
Improvements ✅
(primary)
-1.0% [-2.4%, -0.1%] 6
Improvements ✅
(secondary)
-0.2% [-1.3%, -0.1%] 17
All ❌✅ (primary) -0.8% [-2.4%, 0.7%] 7

Max RSS (memory usage)

Results (primary 2.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.8% [1.9%, 4.3%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.8% [1.9%, 4.3%] 3

Cycles

Results (primary -3.4%, secondary -2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.5% [2.5%, 2.5%] 1
Improvements ✅
(primary)
-3.4% [-3.4%, -3.4%] 1
Improvements ✅
(secondary)
-2.7% [-4.5%, -2.1%] 6
All ❌✅ (primary) -3.4% [-3.4%, -3.4%] 1

Binary size

Results (primary -0.1%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.4%, -0.0%] 20
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 41
All ❌✅ (primary) -0.1% [-0.4%, 0.2%] 23

Bootstrap: 476.496s -> 474.095s (-0.50%)
Artifact size: 390.49 MiB -> 390.42 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 24, 2025
@dianqk dianqk changed the title [WIP] Simplify the canonical enum clone branches to a copy statement Simplify the canonical enum clone branches to a copy statement Oct 26, 2025
@dianqk
Copy link
Member Author

dianqk commented Oct 26, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 26, 2025
Simplify the canonical enum clone branches to a copy statement
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 26, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 26, 2025

☀️ Try build successful (CI)
Build commit: da8af3c (da8af3c91a895fd9646d0e6ef1477767ea0b6076, parent: e5177985a5493c783d6ba20960d2723d9d2e9214)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (da8af3c): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.7% [0.7%, 0.7%] 1
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
-0.9% [-2.5%, -0.1%] 6
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.1%] 6
All ❌✅ (primary) -0.7% [-2.5%, 0.7%] 7

Max RSS (memory usage)

Results (primary 3.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.0% [2.1%, 4.0%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.0% [2.1%, 4.0%] 2

Cycles

Results (secondary -2.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.1% [-2.1%, -2.1%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.1%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.1%, 0.2%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.5%, -0.0%] 17
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 43
All ❌✅ (primary) -0.1% [-0.5%, 0.2%] 19

Bootstrap: 475.08s -> 474.068s (-0.21%)
Artifact size: 390.51 MiB -> 390.49 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 26, 2025
@dianqk dianqk marked this pull request as ready for review October 26, 2025 11:05
@rustbot
Copy link
Collaborator

rustbot commented Oct 26, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Oct 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 26, 2025

r? @madsmtm

rustbot has assigned @madsmtm.
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

@dianqk
Copy link
Member Author

dianqk commented Oct 30, 2025

r? cjgillot

@rustbot rustbot assigned cjgillot and unassigned madsmtm Oct 30, 2025
@madsmtm
Copy link
Contributor

madsmtm commented Oct 30, 2025

r? cjgillot

Yeah, that's probably a better choice, I'm not that familiar with MIR.

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

Labels

perf-regression Performance regression. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad codegen for non-copy-derived struct with all Copy derived fields

6 participants