summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/dead-store-elimination/cycle.rs
blob: b35ce0bcb5ad1de071ec29bca04d8a649371afe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// unit-test: DeadStoreElimination

#[inline(never)]
fn cond() -> bool {
    false
}

// EMIT_MIR cycle.cycle.DeadStoreElimination.diff
fn cycle(mut x: i32, mut y: i32, mut z: i32) {
    // This example is interesting because the non-transitive version of `MaybeLiveLocals` would
    // report that *all* of these stores are live.
    while cond() {
        let temp = z;
        z = y;
        y = x;
        x = temp;
    }
}

fn main() {
    cycle(1, 2, 3);
}