-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix Broken MIR on match branch simplification w/ u8 #75507 #75508
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
I checked and this only breaks on |
bfb4da5
to
670fa77
Compare
c6ec708
to
5b1481f
Compare
@@ -0,0 +1,32 @@ | |||
// EMIT_MIR_FOR_EACH_BIT_WIDTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are our mir-opt tests running on mir-opt-level 3 by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, I'm not sure, but when I ran it initially with this file it failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they run with mir-opt-level=2
but I can't find it in the source off hand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust/src/tools/compiletest/src/runtest.rs
Lines 1941 to 1946 in 8e21bd0
MirOpt => { | |
rustc.args(&[ | |
"-Zdump-mir=all", | |
"-Zmir-opt-level=3", | |
"-Zdump-mir-exclude-pass-number", | |
]); |
@bors r+ |
📌 Commit fd74026 has been approved by |
@bors r- closing in favour of the other PR that's based on this one |
MatchBranchSimplification: fix equal const bool assignments The match branch simplification is applied when target blocks contain statements that are either equal or perform a const bool assignment with different values to the same place. Previously, when constructing new statements, only statements from a single block had been examined. This lead to a misoptimization when statements are equal because the assign the *same* const bool value to the same place. Fix the issue by examining statements from both blocks when deciding on replacement. Additionally: * Copy discriminant instead of moving it since it might be necessary to use its value more than once. * Optimize when switching on copy operand Based on rust-lang#75508. r? @oli-obk / @JulianKnodt
Fixes #75507 yet, and this adds a regression test.
Done by explicitly checking that the type of the const is a bool.
r? @oli-obk cc: @matthiaskrgr