rust/tests/mir-opt/dataflow-const-prop/issue_81605.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
674 B
Rust
Raw Normal View History

//@ test-mir-pass: DataflowConstProp
2022-08-29 17:57:49 -05:00
// EMIT_MIR issue_81605.f.DataflowConstProp.diff
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 }
// CHECK: _0 = const 2_usize;
2022-08-29 17:57:49 -05:00
}
fn main() {
f();
}