2024-04-20 06:19:34 -05:00
|
|
|
//@ test-mir-pass: DataflowConstProp
|
2022-08-25 11:43:46 -05:00
|
|
|
|
|
|
|
// EMIT_MIR if.main.DataflowConstProp.diff
|
2024-01-08 18:58:58 -06:00
|
|
|
// CHECK-LABEL: fn main(
|
2022-08-25 11:43:46 -05:00
|
|
|
fn main() {
|
2024-01-08 18:58:58 -06:00
|
|
|
// CHECK: debug b => [[b:_.*]];
|
|
|
|
// CHECK: debug c => [[c:_.*]];
|
|
|
|
// CHECK: debug d => [[d:_.*]];
|
|
|
|
// CHECK: debug e => [[e:_.*]];
|
|
|
|
|
2022-08-25 11:43:46 -05:00
|
|
|
let a = 1;
|
2024-01-08 18:58:58 -06:00
|
|
|
|
2024-01-12 01:22:33 -06:00
|
|
|
// CHECK: switchInt(const true) -> [0: {{bb.*}}, otherwise: {{bb.*}}];
|
2024-01-08 18:58:58 -06:00
|
|
|
// CHECK: [[b]] = const 2_i32;
|
2022-11-09 11:03:30 -06:00
|
|
|
let b = if a == 1 { 2 } else { 3 };
|
2024-01-08 18:58:58 -06:00
|
|
|
|
|
|
|
// CHECK: [[c]] = const 3_i32;
|
2022-08-25 11:43:46 -05:00
|
|
|
let c = b + 1;
|
|
|
|
|
2024-01-12 01:22:33 -06:00
|
|
|
// CHECK: switchInt(const true) -> [0: {{bb.*}}, otherwise: {{bb.*}}];
|
2024-01-08 18:58:58 -06:00
|
|
|
// CHECK: [[d]] = const 1_i32;
|
2022-11-09 11:03:30 -06:00
|
|
|
let d = if a == 1 { a } else { a + 1 };
|
2024-01-08 18:58:58 -06:00
|
|
|
|
|
|
|
// CHECK: [[e]] = const 2_i32;
|
2022-08-25 11:43:46 -05:00
|
|
|
let e = d + 1;
|
|
|
|
}
|