]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/copy-prop/non_dominate.rs
Auto merge of #107443 - cjgillot:generator-less-query, r=compiler-errors
[rust.git] / tests / mir-opt / copy-prop / non_dominate.rs
1 // unit-test: CopyProp
2
3 #![feature(custom_mir, core_intrinsics)]
4 #![allow(unused_assignments)]
5 extern crate core;
6 use core::intrinsics::mir::*;
7
8 #[custom_mir(dialect = "analysis", phase = "post-cleanup")]
9 fn f(c: bool) -> bool {
10     mir!(
11         let a: bool;
12         let b: bool;
13         { Goto(bb1) }
14         bb1 = { b = c; match b { false => bb3, _ => bb2 }}
15         // This assignment to `a` does not dominate the use in `bb3`.
16         // It should not be replaced by `b`.
17         bb2 = { a = b; c = false; Goto(bb1) }
18         bb3 = { RET = a; Return() }
19     )
20 }
21
22 fn main() {
23     assert_eq!(true, f(true));
24 }
25
26 // EMIT_MIR non_dominate.f.CopyProp.diff