blob: 244f7da25855dc359a291e5b93dda289f22574d4 [file] [log] [blame]
Chris Lattner95ab2682006-03-17 20:04:40 +00001; Test that vectors are scalarized/lowered correctly.
Reid Spencer67263ba2006-04-12 21:03:04 +00002; RUN: llvm-as < %s | llc > /dev/null &&
3; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g5 > /dev/null &&
4; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g3 > /dev/null &&
5; RUN: llvm-as < %s | llc -march=x86 -mcpu=i386 > /dev/null &&
6; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -o /dev/null
Chris Lattner95ab2682006-03-17 20:04:40 +00007
8%f1 = type <1 x float>
9%f2 = type <2 x float>
10%f4 = type <4 x float>
Chris Lattner4d2182a2006-03-21 18:27:27 +000011%i4 = type <4 x int>
Chris Lattner95ab2682006-03-17 20:04:40 +000012%f8 = type <8 x float>
Chris Lattnerbf934142006-03-31 17:59:16 +000013%d8 = type <8 x double>
Chris Lattner95ab2682006-03-17 20:04:40 +000014
15implementation
16
Chris Lattner1e4af782006-03-19 00:20:03 +000017;;; TEST HANDLING OF VARIOUS VECTOR SIZES
18
Chris Lattner95ab2682006-03-17 20:04:40 +000019void %test_f1(%f1 *%P, %f1* %Q, %f1 *%S) {
20 %p = load %f1 *%P
21 %q = load %f1* %Q
22 %R = add %f1 %p, %q
23 store %f1 %R, %f1 *%S
24 ret void
25}
26
27void %test_f2(%f2 *%P, %f2* %Q, %f2 *%S) {
28 %p = load %f2* %P
29 %q = load %f2* %Q
30 %R = add %f2 %p, %q
31 store %f2 %R, %f2 *%S
32 ret void
33}
34
35void %test_f4(%f4 *%P, %f4* %Q, %f4 *%S) {
36 %p = load %f4* %P
37 %q = load %f4* %Q
38 %R = add %f4 %p, %q
39 store %f4 %R, %f4 *%S
40 ret void
41}
42
43void %test_f8(%f8 *%P, %f8* %Q, %f8 *%S) {
44 %p = load %f8* %P
45 %q = load %f8* %Q
46 %R = add %f8 %p, %q
47 store %f8 %R, %f8 *%S
48 ret void
49}
Chris Lattner1e4af782006-03-19 00:20:03 +000050
Chris Lattner4d2182a2006-03-21 18:27:27 +000051void %test_fmul(%f8 *%P, %f8* %Q, %f8 *%S) {
52 %p = load %f8* %P
53 %q = load %f8* %Q
54 %R = mul %f8 %p, %q
55 store %f8 %R, %f8 *%S
56 ret void
57}
Chris Lattner1e4af782006-03-19 00:20:03 +000058;;; TEST VECTOR CONSTRUCTS
59
60void %test_cst(%f4 *%P, %f4 *%S) {
61 %p = load %f4* %P
62 %R = add %f4 %p, <float 0.1, float 1.0, float 2.0, float 4.5>
63 store %f4 %R, %f4 *%S
64 ret void
65}
66
67void %test_zero(%f4 *%P, %f4 *%S) {
68 %p = load %f4* %P
69 %R = add %f4 %p, zeroinitializer
70 store %f4 %R, %f4 *%S
71 ret void
72}
73
74void %test_undef(%f4 *%P, %f4 *%S) {
75 %p = load %f4* %P
76 %R = add %f4 %p, undef
77 store %f4 %R, %f4 *%S
78 ret void
79}
Chris Lattner152c72d2006-03-19 01:27:04 +000080
81void %test_constant_insert(%f4 *%S) {
82 %R = insertelement %f4 zeroinitializer, float 10.0, uint 0
83 store %f4 %R, %f4 *%S
84 ret void
85}
86
87void %test_variable_buildvector(float %F, %f4 *%S) {
88 %R = insertelement %f4 zeroinitializer, float %F, uint 0
89 store %f4 %R, %f4 *%S
90 ret void
91}
Chris Lattner00e2c942006-03-19 04:45:11 +000092
Chris Lattner7ca97772006-03-19 05:46:51 +000093void %test_scalar_to_vector(float %F, %f4 *%S) {
94 %R = insertelement %f4 undef, float %F, uint 0 ;; R = scalar_to_vector F
95 store %f4 %R, %f4 *%S
96 ret void
97}
98
Chris Lattner5d37acc2006-03-23 21:15:57 +000099float %test_extract_elt(%f8 *%P) {
100 %p = load %f8* %P
101 %R = extractelement %f8 %p, uint 3
102 ret float %R
103}
104
Chris Lattnerbf934142006-03-31 17:59:16 +0000105double %test_extract_elt2(%d8 *%P) {
106 %p = load %d8* %P
107 %R = extractelement %d8 %p, uint 3
108 ret double %R
109}
110
Chris Lattner5d37acc2006-03-23 21:15:57 +0000111void %test_cast_1(<4 x float>* %b, <4 x int>* %a) {
112 %tmp = load <4 x float>* %b
113 %tmp2 = add <4 x float> %tmp, <float 1.0, float 2.0, float 3.0, float 4.0>
114 %tmp3 = cast <4 x float> %tmp2 to <4 x int>
115 %tmp4 = add <4 x int> %tmp3, <int 1, int 2, int 3, int 4>
116 store <4 x int> %tmp4, <4 x int>* %a
117 ret void
118}
119
120void %test_cast_2(<8 x float>* %a, <8 x int>* %b) {
121 %T = load <8 x float>* %a
122 %T2 = cast <8 x float> %T to <8 x int>
123 store <8 x int> %T2, <8 x int>* %b
124 ret void
125}
126
127
Chris Lattner00e2c942006-03-19 04:45:11 +0000128;;; TEST IMPORTANT IDIOMS
129
130void %splat(%f4* %P, %f4* %Q, float %X) {
131 %tmp = insertelement %f4 undef, float %X, uint 0
132 %tmp2 = insertelement %f4 %tmp, float %X, uint 1
133 %tmp4 = insertelement %f4 %tmp2, float %X, uint 2
134 %tmp6 = insertelement %f4 %tmp4, float %X, uint 3
135 %q = load %f4* %Q
136 %R = add %f4 %q, %tmp6
137 store %f4 %R, %f4* %P
138 ret void
139}
140
Chris Lattner4d2182a2006-03-21 18:27:27 +0000141void %splat_i4(%i4* %P, %i4* %Q, int %X) {
142 %tmp = insertelement %i4 undef, int %X, uint 0
143 %tmp2 = insertelement %i4 %tmp, int %X, uint 1
144 %tmp4 = insertelement %i4 %tmp2, int %X, uint 2
145 %tmp6 = insertelement %i4 %tmp4, int %X, uint 3
146 %q = load %i4* %Q
147 %R = add %i4 %q, %tmp6
148 store %i4 %R, %i4* %P
149 ret void
150}
151