]> git.lizzy.rs Git - rust.git/blob - tests/codegen/autovectorize-f32x4.rs
Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki
[rust.git] / tests / codegen / autovectorize-f32x4.rs
1 // compile-flags: -C opt-level=3
2 // only-x86_64
3 #![crate_type = "lib"]
4
5 // CHECK-LABEL: @auto_vectorize_direct
6 #[no_mangle]
7 pub fn auto_vectorize_direct(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
8 // CHECK: load <4 x float>
9 // CHECK: load <4 x float>
10 // CHECK: fadd <4 x float>
11 // CHECK: store <4 x float>
12     [
13         a[0] + b[0],
14         a[1] + b[1],
15         a[2] + b[2],
16         a[3] + b[3],
17     ]
18 }
19
20 // CHECK-LABEL: @auto_vectorize_loop
21 #[no_mangle]
22 pub fn auto_vectorize_loop(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
23 // CHECK: load <4 x float>
24 // CHECK: load <4 x float>
25 // CHECK: fadd <4 x float>
26 // CHECK: store <4 x float>
27     let mut c = [0.0; 4];
28     for i in 0..4 {
29         c[i] = a[i] + b[i];
30     }
31     c
32 }