blob: a015e6fd1c303143d88a783144a779cdff8d20db [file] [log] [blame]
Chris Lattner95ab2682006-03-17 20:04:40 +00001; Test that vectors are scalarized/lowered correctly.
Chris Lattner00e2c942006-03-19 04:45:11 +00002; RUN: llvm-as < %s | llc &&
3; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g5 &&
4; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g3
Chris Lattner95ab2682006-03-17 20:04:40 +00005
6%f1 = type <1 x float>
7%f2 = type <2 x float>
8%f4 = type <4 x float>
9%f8 = type <8 x float>
10
11implementation
12
Chris Lattner1e4af782006-03-19 00:20:03 +000013;;; TEST HANDLING OF VARIOUS VECTOR SIZES
14
Chris Lattner95ab2682006-03-17 20:04:40 +000015void %test_f1(%f1 *%P, %f1* %Q, %f1 *%S) {
16 %p = load %f1 *%P
17 %q = load %f1* %Q
18 %R = add %f1 %p, %q
19 store %f1 %R, %f1 *%S
20 ret void
21}
22
23void %test_f2(%f2 *%P, %f2* %Q, %f2 *%S) {
24 %p = load %f2* %P
25 %q = load %f2* %Q
26 %R = add %f2 %p, %q
27 store %f2 %R, %f2 *%S
28 ret void
29}
30
31void %test_f4(%f4 *%P, %f4* %Q, %f4 *%S) {
32 %p = load %f4* %P
33 %q = load %f4* %Q
34 %R = add %f4 %p, %q
35 store %f4 %R, %f4 *%S
36 ret void
37}
38
39void %test_f8(%f8 *%P, %f8* %Q, %f8 *%S) {
40 %p = load %f8* %P
41 %q = load %f8* %Q
42 %R = add %f8 %p, %q
43 store %f8 %R, %f8 *%S
44 ret void
45}
Chris Lattner1e4af782006-03-19 00:20:03 +000046
47;;; TEST VECTOR CONSTRUCTS
48
49void %test_cst(%f4 *%P, %f4 *%S) {
50 %p = load %f4* %P
51 %R = add %f4 %p, <float 0.1, float 1.0, float 2.0, float 4.5>
52 store %f4 %R, %f4 *%S
53 ret void
54}
55
56void %test_zero(%f4 *%P, %f4 *%S) {
57 %p = load %f4* %P
58 %R = add %f4 %p, zeroinitializer
59 store %f4 %R, %f4 *%S
60 ret void
61}
62
63void %test_undef(%f4 *%P, %f4 *%S) {
64 %p = load %f4* %P
65 %R = add %f4 %p, undef
66 store %f4 %R, %f4 *%S
67 ret void
68}
Chris Lattner152c72d2006-03-19 01:27:04 +000069
70void %test_constant_insert(%f4 *%S) {
71 %R = insertelement %f4 zeroinitializer, float 10.0, uint 0
72 store %f4 %R, %f4 *%S
73 ret void
74}
75
76void %test_variable_buildvector(float %F, %f4 *%S) {
77 %R = insertelement %f4 zeroinitializer, float %F, uint 0
78 store %f4 %R, %f4 *%S
79 ret void
80}
Chris Lattner00e2c942006-03-19 04:45:11 +000081
82;;; TEST IMPORTANT IDIOMS
83
84void %splat(%f4* %P, %f4* %Q, float %X) {
85 %tmp = insertelement %f4 undef, float %X, uint 0
86 %tmp2 = insertelement %f4 %tmp, float %X, uint 1
87 %tmp4 = insertelement %f4 %tmp2, float %X, uint 2
88 %tmp6 = insertelement %f4 %tmp4, float %X, uint 3
89 %q = load %f4* %Q
90 %R = add %f4 %q, %tmp6
91 store %f4 %R, %f4* %P
92 ret void
93}
94