os-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
670 B
Rust
Raw Normal View History

2022-08-30 00:57:49 +02:00
//@ unit-test: DataflowConstProp
// EMIT_MIR issue_81605.f.DataflowConstProp.diff
2024-01-11 23:22:33 -08: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-30 00:57:49 +02:00
fn f() -> usize {
2024-01-11 23:22:33 -08:00
// CHECK: switchInt(const true) -> [0: {{bb.*}}, otherwise: {{bb.*}}];
2022-08-30 00:57:49 +02:00
1 + if true { 1 } else { 2 }
// CHECK: _0 = const 2_usize;
2022-08-30 00:57:49 +02:00
}
fn main() {
f();
}