Skip to content

Commit 934345b

Browse files
workingjubileescottmcm
authored andcommitted
Add autovectorization codegen test
Co-authored-by: Scott McMurray <[email protected]>
1 parent 8e98537 commit 934345b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
pub fn auto_vectorize_loop(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
22+
// CHECK: load <4 x float>
23+
// CHECK: load <4 x float>
24+
// CHECK: fadd <4 x float>
25+
// CHECK: store <4 x float>
26+
let mut c = [0.0; 4];
27+
for i in 0..4 {
28+
c[i] = a[i] + b[i];
29+
}
30+
c
31+
}

0 commit comments

Comments
 (0)