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