Auto merge of #77549 - tmiasko:simplify-branch-same-fix, r=oli-obk

Fix miscompile in SimplifyBranchSame

Cherry-picked from #77486, but with a different test case that used to be compiled incorrectly on both master & beta branches.
This commit is contained in:
bors 2020-10-05 11:41:59 +00:00
commit d890e64dff
2 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,21 @@
// Regression test for SimplifyBranchSame miscompilation.
// run-pass
macro_rules! m {
($a:expr, $b:expr, $c:block) => {
match $a {
Lto::Fat | Lto::Thin => { $b; (); $c }
Lto::No => { $b; () }
}
}
}
pub enum Lto { No, Thin, Fat }
fn f(mut cookie: u32, lto: Lto) -> u32 {
let mut _a = false;
m!(lto, _a = true, {cookie = 0});
cookie
}
fn main() { assert_eq!(f(42, Lto::Thin), 0) }