Skip to content

Conversation

@dianqk
Copy link
Member

@dianqk dianqk commented Oct 23, 2025

I have overhauled MatchBranchSimplification in this PR. This pass tries to unify statements one by one, which is more readable and extensible.

This PR also unifies 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
Contributor

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
Contributor

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 force-pushed the matchbr-copy branch 2 times, most recently from d2deaa3 to 8a2e9e4 Compare October 26, 2025 05:22
@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
Contributor

rust-bors bot commented Oct 26, 2025

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

@rust-timer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 20, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@dianqk
Copy link
Member Author

dianqk commented Jan 20, 2026

@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 Jan 20, 2026
@dianqk
Copy link
Member Author

dianqk commented Jan 22, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Jan 22, 2026
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 Jan 22, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 22, 2026

☀️ Try build successful (CI)
Build commit: 8e941f2 (8e941f231426d82f25aa9c9df9407de6e7e936e0, parent: d29e4783dff30f9526eeba3929ebfe86c00c9dad)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8e941f2): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@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
Improvements ✅
(primary)
-1.0% [-2.5%, -0.2%] 6
Improvements ✅
(secondary)
-0.2% [-0.4%, -0.1%] 6
All ❌✅ (primary) -0.8% [-2.5%, 0.7%] 7

Max RSS (memory usage)

Results (primary 4.3%, secondary 1.0%)

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

mean range count
Regressions ❌
(primary)
5.5% [3.2%, 8.2%] 5
Regressions ❌
(secondary)
4.8% [4.8%, 4.8%] 1
Improvements ✅
(primary)
-1.7% [-1.7%, -1.7%] 1
Improvements ✅
(secondary)
-2.9% [-2.9%, -2.9%] 1
All ❌✅ (primary) 4.3% [-1.7%, 8.2%] 6

Cycles

Results (primary 2.0%, secondary 5.7%)

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

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

Binary size

Results (primary -0.0%, 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.2% [0.0%, 0.3%] 10
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
-0.2% [-1.1%, -0.0%] 14
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 9
All ❌✅ (primary) -0.0% [-1.1%, 0.3%] 24

Bootstrap: 472.528s -> 473.524s (0.21%)
Artifact size: 383.22 MiB -> 383.24 MiB (0.00%)

@rustbot rustbot removed perf-regression Performance regression. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 22, 2026
@dianqk
Copy link
Member Author

dianqk commented Jan 23, 2026

@bors try parent=d29e4783dff30f9526eeba3929ebfe86c00c9dad @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Jan 23, 2026
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 Jan 23, 2026
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[group]Runner Image Provisioner
Hosted Compute Agent
Version: 20260115.477
Commit: 4b342d620503cbe250a3154040964899ea7c9b00
Build Date: 2026-01-15T22:32:41Z
Worker ID: {fe0fca4a-3f86-4bd5-82a8-09f5f66721d5}
Azure Region: westcentralus
##[endgroup]
##[group]Operating System
Ubuntu
24.04.3
LTS
---
REPOSITORY                                   TAG       IMAGE ID       CREATED      SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    354d02aa29ac   3 days ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:596da3f22bcbdff2c96fd7126001278022c834c1621c5efa2ad1a7794590636c
deleted: sha256:354d02aa29acf525570c732b6e006ecf138de6d63ca525d552eb4b24880ddc6c
deleted: sha256:8b7af0e426bc2cbeeacfd96b8354d3b80016991520977197e62090e47abaede8
deleted: sha256:cadf11ef1de7fdd5eab563757942353684047f09b212dc99d6ed48e8acf34d62
deleted: sha256:569b0caf9d5285db44ccd2629a3470139eea755be423a33a54d8a24cb3926bfa
deleted: sha256:f9dc5feb048d8f9fd43137e3998f59e9acfbd76c47a4e14984d109654119e282
---
..............................................     (146/146)

======== tests/rustdoc-gui/globals.goml ========

[ERROR] line 14: The following errors happened: [Property named `"searchIndex"` doesn't exist]: for command `assert-window-property-false: {"searchIndex": null}`
    at <file:///checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/test_docs/index.html?search=Foo>

======== tests/rustdoc-gui/search-result-display.goml ========

[WARNING] line 39: Delta is 0 for "x", maybe try to use `compare-elements-position` instead?

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 23, 2026

☀️ Try build successful (CI)
Build commit: 4e6c6dc (4e6c6dc83bfbd42901372bdf346032a61b25c2f8, parent: d29e4783dff30f9526eeba3929ebfe86c00c9dad)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4e6c6dc): 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
Improvements ✅
(primary)
-1.1% [-2.4%, -0.2%] 4
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.1%] 5
All ❌✅ (primary) -0.7% [-2.4%, 0.7%] 5

Max RSS (memory usage)

Results (primary 1.7%, secondary 0.0%)

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

mean range count
Regressions ❌
(primary)
6.5% [2.7%, 13.9%] 3
Regressions ❌
(secondary)
4.3% [4.3%, 4.3%] 1
Improvements ✅
(primary)
-3.1% [-3.8%, -2.0%] 3
Improvements ✅
(secondary)
-2.2% [-2.9%, -1.4%] 2
All ❌✅ (primary) 1.7% [-3.8%, 13.9%] 6

Cycles

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

Binary size

Results (primary -0.1%, secondary 0.0%)

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.1% [0.0%, 0.1%] 5
Improvements ✅
(primary)
-0.1% [-0.5%, -0.0%] 15
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 6
All ❌✅ (primary) -0.1% [-0.5%, 0.2%] 18

Bootstrap: 472.528s -> 472.063s (-0.10%)
Artifact size: 383.22 MiB -> 383.22 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 23, 2026
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-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.

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

7 participants