about summary refs log tree commit diff
path: root/tests/mir-opt/instsimplify/combine_array_len.rs
blob: 91f43f75689decb7c59b5e2cd409dbd09f20c94f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ test-mir-pass: InstSimplify-after-simplifycfg

// EMIT_MIR combine_array_len.norm2.InstSimplify-after-simplifycfg.diff
fn norm2(x: [f32; 2]) -> f32 {
    // CHECK-LABEL: fn norm2(
    // CHECK-NOT: Len(
    let a = x[0];
    let b = x[1];
    a * a + b * b
}

fn main() {
    assert_eq!(norm2([3.0, 4.0]), 5.0 * 5.0);
}