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

Disable SimplifyToExp in MatchBranchSimplification #124156

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

DianQK
Copy link
Member

@DianQK DianQK commented Apr 19, 2024

Due to the miscompilation mentioned in #124150, We need to disable MatchBranchSimplification temporarily.

To fully resolve this issue, my plan is:

  1. Disable SimplifyToExp in MatchBranchSimplification (this PR).
  2. Remove all potentially unclear transforms in Don't perform unsigned comparisons for signed integers  #124122.
  3. Gradually add back the removed transforms (possibly multiple PRs).

r? @Nilstrieb or @oli-obk

@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 Apr 19, 2024
@rustbot
Copy link
Collaborator

rustbot commented Apr 19, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@RalfJung
Copy link
Member

This one is easy to review. :)
r=me when CI is green.

@@ -1,3 +1,4 @@
//@ unit-test: MatchBranchSimplification
Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's okay to change it for unit testing since the MIR output is the same.

Copy link
Member

@RalfJung RalfJung Apr 19, 2024

Choose a reason for hiding this comment

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

I'm surprised the test didn't already have this declaration, if it was meant to test a particular pass.

But also, unit-test is a very non-self-explaining name for "please run only and specifically this pass".

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the default compiler flag is -O.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I know it doesn't need the declaration to test default-on opts. But when a test tests a specific opt, wouldn't it be good to add that declaration even if it is not needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are probably similar test cases in the repository. ;) Perhaps there was no support for unit testing in the past?

Copy link
Member Author

Choose a reason for hiding this comment

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

For fixing the miscompilation, I hope to make as few changes as possible. This can go into a separate PR now.

Copy link
Member

Choose a reason for hiding this comment

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

Oh yeah sure this was more of a general comment. Sorry for being unclear.

@@ -1,9 +1,10 @@
//@ unit-test: MatchBranchSimplification
Copy link
Member Author

Choose a reason for hiding this comment

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

The same as tests/mir-opt/switch_to_self.rs.

@@ -1,4 +1,5 @@
//@ unit-test: InstSimplify
//@ should-fail Broken due to https://github.com/rust-lang/rust/issues/124150.
Copy link
Member

Choose a reason for hiding this comment

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

Why does this affect this test, when #120614 did not change this test?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was already accomplished by the existing SimplifyToIf. I just did a refactor in #120614.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, so this is not equivalent to reverting #120614, it disables more than that.

In that case, hard for me to say whether it's appropriate to disable the entire pass.

@RalfJung
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 19, 2024
@bors
Copy link
Contributor

bors commented Apr 19, 2024

⌛ Trying commit 2d3178b with merge e7a5d6f...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 19, 2024
Disable MatchBranchSimplification

Due to the miscompilation mentioned in rust-lang#124150, We need to disable MatchBranchSimplification temporarily.

To fully resolve this issue, my plan is:
1. Disable MatchBranchSimplification (this PR).
2. Remove all potentially unclear transforms in rust-lang#124122.
3. Gradually add back the removed transforms (possibly multiple PRs).

r? `@Nilstrieb` or `@oli-obk`
@rust-log-analyzer

This comment has been minimized.

@DianQK DianQK force-pushed the disable-match_branches branch from 2d3178b to ca30ce6 Compare April 19, 2024 10:59
@rustbot
Copy link
Collaborator

rustbot commented Apr 19, 2024

Some changes occurred in coverage tests.

cc @Zalathar

@DianQK
Copy link
Member Author

DianQK commented Apr 19, 2024

If the perf result is unacceptable, I would consider revert the PR or just disable SimplifyToExp.

@RalfJung
Copy link
Member

or just disable SimplifyToExp.

If there's an easy way to disable just the affected part of this pass, then let's just do that?

@rust-log-analyzer

This comment has been minimized.

@DianQK
Copy link
Member Author

DianQK commented Apr 19, 2024

or just disable SimplifyToExp.

If there's an easy way to disable just the affected part of this pass, then let's just do that?

I can write the following code:

if tcx.sess.opts.unstable_opts.unsound_mir_opts
    && SimplifyToExp::default().simplify(tcx, body, bb_idx, param_env).is_some()
{
    should_cleanup = true;
    continue;
}

But I've never seen code like this before.

Edit: The code below works fine for me.

if false && SimplifyToExp::default().simplify(tcx, body, bb_idx, param_env).is_some()
{
    should_cleanup = true;
    continue;
}

@DianQK DianQK force-pushed the disable-match_branches branch from ca30ce6 to 86a51cd Compare April 19, 2024 12:55
@DianQK DianQK changed the title Disable MatchBranchSimplification Disable SimplifyToExp in MatchBranchSimplification Apr 19, 2024
@rust-log-analyzer

This comment has been minimized.

@DianQK DianQK force-pushed the disable-match_branches branch from 86a51cd to e2f8ec6 Compare April 19, 2024 13:14
@RalfJung
Copy link
Member

Why not use tcx.sess.opts.unstable_opts.unsound_mir_opts? Seems reasonable to me.

@DianQK DianQK force-pushed the disable-match_branches branch from e2f8ec6 to b52be28 Compare April 19, 2024 21:38
@DianQK
Copy link
Member Author

DianQK commented Apr 19, 2024

Why not use tcx.sess.opts.unstable_opts.unsound_mir_opts? Seems reasonable to me.

I'm just worried it might be a bit weird because I've never seen this kind of code before.
Done. But I didn't add -Zunsound-mir-opts to the test case because then we could see that the modified code was working.

@RalfJung
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 20, 2024

📌 Commit b52be28 has been approved by RalfJung

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

bors commented Apr 20, 2024

⌛ Testing commit b52be28 with merge a61b14d...

@bors
Copy link
Contributor

bors commented Apr 20, 2024

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing a61b14d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 20, 2024
@bors bors merged commit a61b14d into rust-lang:master Apr 20, 2024
13 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 20, 2024
@DianQK DianQK deleted the disable-match_branches branch April 20, 2024 11:01
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a61b14d): comparison URL.

Overall result: ❌ regressions - 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)
1.9% [1.9%, 1.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
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)
6.7% [3.2%, 13.5%] 3
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 6.7% [3.2%, 13.5%] 3

Cycles

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) - - 0

Binary size

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.1% [0.0%, 0.1%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.0%, 0.1%] 6

Bootstrap: 670.395s -> 670.71s (0.05%)
Artifact size: 315.30 MiB -> 315.28 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. S-waiting-on-perf Status: Waiting on a perf run to be completed. 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.

7 participants