diff options
Diffstat (limited to 'tests/mir-opt/instsimplify/combine_array_len.rs')
-rw-r--r-- | tests/mir-opt/instsimplify/combine_array_len.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/mir-opt/instsimplify/combine_array_len.rs b/tests/mir-opt/instsimplify/combine_array_len.rs new file mode 100644 index 000000000..3b6795bc9 --- /dev/null +++ b/tests/mir-opt/instsimplify/combine_array_len.rs @@ -0,0 +1,15 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// unit-test: InstSimplify + +// EMIT_MIR combine_array_len.norm2.InstSimplify.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); +} |