blob: 34a3b2444b880feb36842277194580e3ecaf9cfa [file] [log] [blame]
Chris Lattner95ab2682006-03-17 20:04:40 +00001; Test that vectors are scalarized/lowered correctly.
Chris Lattner8981f062006-04-13 17:10:03 +00002; RUN: llvm-as < %s | llc &&
3; RUN: llvm-as < %s | llc -mtriple a-b-c &&
4; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g5 &&
5; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g3 &&
6; RUN: llvm-as < %s | llc -march=x86 -mcpu=i386 &&
7; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah
Chris Lattner95ab2682006-03-17 20:04:40 +00008
9%f1 = type <1 x float>
10%f2 = type <2 x float>
11%f4 = type <4 x float>
Chris Lattner4d2182a2006-03-21 18:27:27 +000012%i4 = type <4 x int>
Chris Lattner95ab2682006-03-17 20:04:40 +000013%f8 = type <8 x float>
Chris Lattnerbf934142006-03-31 17:59:16 +000014%d8 = type <8 x double>
Chris Lattner95ab2682006-03-17 20:04:40 +000015
16implementation
17
Chris Lattner1e4af782006-03-19 00:20:03 +000018;;; TEST HANDLING OF VARIOUS VECTOR SIZES
19
Chris Lattner95ab2682006-03-17 20:04:40 +000020void %test_f1(%f1 *%P, %f1* %Q, %f1 *%S) {
21 %p = load %f1 *%P
22 %q = load %f1* %Q
23 %R = add %f1 %p, %q
24 store %f1 %R, %f1 *%S
25 ret void
26}
27
28void %test_f2(%f2 *%P, %f2* %Q, %f2 *%S) {
29 %p = load %f2* %P
30 %q = load %f2* %Q
31 %R = add %f2 %p, %q
32 store %f2 %R, %f2 *%S
33 ret void
34}
35
36void %test_f4(%f4 *%P, %f4* %Q, %f4 *%S) {
37 %p = load %f4* %P
38 %q = load %f4* %Q
39 %R = add %f4 %p, %q
40 store %f4 %R, %f4 *%S
41 ret void
42}
43
44void %test_f8(%f8 *%P, %f8* %Q, %f8 *%S) {
45 %p = load %f8* %P
46 %q = load %f8* %Q
47 %R = add %f8 %p, %q
48 store %f8 %R, %f8 *%S
49 ret void
50}
Chris Lattner1e4af782006-03-19 00:20:03 +000051
Chris Lattner4d2182a2006-03-21 18:27:27 +000052void %test_fmul(%f8 *%P, %f8* %Q, %f8 *%S) {
53 %p = load %f8* %P
54 %q = load %f8* %Q
55 %R = mul %f8 %p, %q
56 store %f8 %R, %f8 *%S
57 ret void
58}
Chris Lattner5ecc0ac2006-05-24 00:12:50 +000059
60void %test_div(%f8 *%P, %f8* %Q, %f8 *%S) {
61 %p = load %f8* %P
62 %q = load %f8* %Q
63 %R = div %f8 %p, %q
64 store %f8 %R, %f8 *%S
65 ret void
66}
67
Chris Lattner1e4af782006-03-19 00:20:03 +000068;;; TEST VECTOR CONSTRUCTS
69
70void %test_cst(%f4 *%P, %f4 *%S) {
71 %p = load %f4* %P
72 %R = add %f4 %p, <float 0.1, float 1.0, float 2.0, float 4.5>
73 store %f4 %R, %f4 *%S
74 ret void
75}
76
77void %test_zero(%f4 *%P, %f4 *%S) {
78 %p = load %f4* %P
79 %R = add %f4 %p, zeroinitializer
80 store %f4 %R, %f4 *%S
81 ret void
82}
83
84void %test_undef(%f4 *%P, %f4 *%S) {
85 %p = load %f4* %P
86 %R = add %f4 %p, undef
87 store %f4 %R, %f4 *%S
88 ret void
89}
Chris Lattner152c72d2006-03-19 01:27:04 +000090
91void %test_constant_insert(%f4 *%S) {
92 %R = insertelement %f4 zeroinitializer, float 10.0, uint 0
93 store %f4 %R, %f4 *%S
94 ret void
95}
96
97void %test_variable_buildvector(float %F, %f4 *%S) {
98 %R = insertelement %f4 zeroinitializer, float %F, uint 0
99 store %f4 %R, %f4 *%S
100 ret void
101}
Chris Lattner00e2c942006-03-19 04:45:11 +0000102
Chris Lattner7ca97772006-03-19 05:46:51 +0000103void %test_scalar_to_vector(float %F, %f4 *%S) {
104 %R = insertelement %f4 undef, float %F, uint 0 ;; R = scalar_to_vector F
105 store %f4 %R, %f4 *%S
106 ret void
107}
108
Chris Lattner5d37acc2006-03-23 21:15:57 +0000109float %test_extract_elt(%f8 *%P) {
110 %p = load %f8* %P
111 %R = extractelement %f8 %p, uint 3
112 ret float %R
113}
114
Chris Lattnerbf934142006-03-31 17:59:16 +0000115double %test_extract_elt2(%d8 *%P) {
116 %p = load %d8* %P
117 %R = extractelement %d8 %p, uint 3
118 ret double %R
119}
120
Chris Lattner5d37acc2006-03-23 21:15:57 +0000121void %test_cast_1(<4 x float>* %b, <4 x int>* %a) {
122 %tmp = load <4 x float>* %b
123 %tmp2 = add <4 x float> %tmp, <float 1.0, float 2.0, float 3.0, float 4.0>
124 %tmp3 = cast <4 x float> %tmp2 to <4 x int>
125 %tmp4 = add <4 x int> %tmp3, <int 1, int 2, int 3, int 4>
126 store <4 x int> %tmp4, <4 x int>* %a
127 ret void
128}
129
130void %test_cast_2(<8 x float>* %a, <8 x int>* %b) {
131 %T = load <8 x float>* %a
132 %T2 = cast <8 x float> %T to <8 x int>
133 store <8 x int> %T2, <8 x int>* %b
134 ret void
135}
136
137
Chris Lattner00e2c942006-03-19 04:45:11 +0000138;;; TEST IMPORTANT IDIOMS
139
140void %splat(%f4* %P, %f4* %Q, float %X) {
141 %tmp = insertelement %f4 undef, float %X, uint 0
142 %tmp2 = insertelement %f4 %tmp, float %X, uint 1
143 %tmp4 = insertelement %f4 %tmp2, float %X, uint 2
144 %tmp6 = insertelement %f4 %tmp4, float %X, uint 3
145 %q = load %f4* %Q
146 %R = add %f4 %q, %tmp6
147 store %f4 %R, %f4* %P
148 ret void
149}
150
Chris Lattner4d2182a2006-03-21 18:27:27 +0000151void %splat_i4(%i4* %P, %i4* %Q, int %X) {
152 %tmp = insertelement %i4 undef, int %X, uint 0
153 %tmp2 = insertelement %i4 %tmp, int %X, uint 1
154 %tmp4 = insertelement %i4 %tmp2, int %X, uint 2
155 %tmp6 = insertelement %i4 %tmp4, int %X, uint 3
156 %q = load %i4* %Q
157 %R = add %i4 %q, %tmp6
158 store %i4 %R, %i4* %P
159 ret void
160}
161