2024-04-20 06:19:34 -05:00
|
|
|
//@ test-mir-pass: DataflowConstProp
|
2022-08-29 17:57:49 -05:00
|
|
|
|
|
|
|
// EMIT_MIR issue_81605.f.DataflowConstProp.diff
|
2024-01-08 18:58:58 -06:00
|
|
|
|
2024-01-12 01:22:33 -06:00
|
|
|
// Plese find the original issue [here](https://github.com/rust-lang/rust/issues/81605).
|
|
|
|
// This test program comes directly from the issue. Prior to this issue,
|
|
|
|
// the compiler cannot simplify the return value of `f` into 2. This was
|
|
|
|
// solved by adding a new MIR constant propagation based on dataflow
|
|
|
|
// analysis in [#101168](https://github.com/rust-lang/rust/pull/101168).
|
|
|
|
|
|
|
|
// CHECK-LABEL: fn f(
|
2022-08-29 17:57:49 -05:00
|
|
|
fn f() -> usize {
|
2024-01-12 01:22:33 -06:00
|
|
|
// CHECK: switchInt(const true) -> [0: {{bb.*}}, otherwise: {{bb.*}}];
|
2022-08-29 17:57:49 -05:00
|
|
|
1 + if true { 1 } else { 2 }
|
2024-01-08 18:58:58 -06:00
|
|
|
// CHECK: _0 = const 2_usize;
|
2022-08-29 17:57:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
f();
|
|
|
|
}
|