blob: 0b21c75392edbc13db9908f303af25b27e00d82d [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; Test that vectors are scalarized/lowered correctly.
2; RUN: llvm-upgrade < %s | llvm-as | llc
3
4%f1 = type <1 x float>
5%f2 = type <2 x float>
6%f4 = type <4 x float>
7%i4 = type <4 x int>
8%f8 = type <8 x float>
9%d8 = type <8 x double>
10
11implementation
12
13;;; TEST HANDLING OF VARIOUS VECTOR SIZES
14
15void %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}
46
47void %test_fmul(%f8 *%P, %f8* %Q, %f8 *%S) {
48 %p = load %f8* %P
49 %q = load %f8* %Q
50 %R = mul %f8 %p, %q
51 store %f8 %R, %f8 *%S
52 ret void
53}
54
55void %test_div(%f8 *%P, %f8* %Q, %f8 *%S) {
56 %p = load %f8* %P
57 %q = load %f8* %Q
58 %R = div %f8 %p, %q
59 store %f8 %R, %f8 *%S
60 ret void
61}
62
63;;; TEST VECTOR CONSTRUCTS
64
65void %test_cst(%f4 *%P, %f4 *%S) {
66 %p = load %f4* %P
Dale Johannesend727a2b2007-09-05 17:50:36 +000067 %R = add %f4 %p, <float 0x3FB99999A0000000, float 1.0, float 2.0, float 4.5>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068 store %f4 %R, %f4 *%S
69 ret void
70}
71
72void %test_zero(%f4 *%P, %f4 *%S) {
73 %p = load %f4* %P
74 %R = add %f4 %p, zeroinitializer
75 store %f4 %R, %f4 *%S
76 ret void
77}
78
79void %test_undef(%f4 *%P, %f4 *%S) {
80 %p = load %f4* %P
81 %R = add %f4 %p, undef
82 store %f4 %R, %f4 *%S
83 ret void
84}
85
86void %test_constant_insert(%f4 *%S) {
87 %R = insertelement %f4 zeroinitializer, float 10.0, uint 0
88 store %f4 %R, %f4 *%S
89 ret void
90}
91
92void %test_variable_buildvector(float %F, %f4 *%S) {
93 %R = insertelement %f4 zeroinitializer, float %F, uint 0
94 store %f4 %R, %f4 *%S
95 ret void
96}
97
98void %test_scalar_to_vector(float %F, %f4 *%S) {
99 %R = insertelement %f4 undef, float %F, uint 0 ;; R = scalar_to_vector F
100 store %f4 %R, %f4 *%S
101 ret void
102}
103
104float %test_extract_elt(%f8 *%P) {
105 %p = load %f8* %P
106 %R = extractelement %f8 %p, uint 3
107 ret float %R
108}
109
110double %test_extract_elt2(%d8 *%P) {
111 %p = load %d8* %P
112 %R = extractelement %d8 %p, uint 3
113 ret double %R
114}
115
116void %test_cast_1(<4 x float>* %b, <4 x int>* %a) {
117 %tmp = load <4 x float>* %b
118 %tmp2 = add <4 x float> %tmp, <float 1.0, float 2.0, float 3.0, float 4.0>
119 %tmp3 = cast <4 x float> %tmp2 to <4 x int>
120 %tmp4 = add <4 x int> %tmp3, <int 1, int 2, int 3, int 4>
121 store <4 x int> %tmp4, <4 x int>* %a
122 ret void
123}
124
125void %test_cast_2(<8 x float>* %a, <8 x int>* %b) {
126 %T = load <8 x float>* %a
127 %T2 = cast <8 x float> %T to <8 x int>
128 store <8 x int> %T2, <8 x int>* %b
129 ret void
130}
131
132
133;;; TEST IMPORTANT IDIOMS
134
135void %splat(%f4* %P, %f4* %Q, float %X) {
136 %tmp = insertelement %f4 undef, float %X, uint 0
137 %tmp2 = insertelement %f4 %tmp, float %X, uint 1
138 %tmp4 = insertelement %f4 %tmp2, float %X, uint 2
139 %tmp6 = insertelement %f4 %tmp4, float %X, uint 3
140 %q = load %f4* %Q
141 %R = add %f4 %q, %tmp6
142 store %f4 %R, %f4* %P
143 ret void
144}
145
146void %splat_i4(%i4* %P, %i4* %Q, int %X) {
147 %tmp = insertelement %i4 undef, int %X, uint 0
148 %tmp2 = insertelement %i4 %tmp, int %X, uint 1
149 %tmp4 = insertelement %i4 %tmp2, int %X, uint 2
150 %tmp6 = insertelement %i4 %tmp4, int %X, uint 3
151 %q = load %i4* %Q
152 %R = add %i4 %q, %tmp6
153 store %i4 %R, %i4* %P
154 ret void
155}
156