blob: e66b91963352a95335e2fa771f5fea50e8899985 [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>
Chris Lattner4d2182a2006-03-21 18:27:27 +00009%i4 = type <4 x int>
Chris Lattner95ab2682006-03-17 20:04:40 +000010%f8 = type <8 x float>
11
12implementation
13
Chris Lattner1e4af782006-03-19 00:20:03 +000014;;; TEST HANDLING OF VARIOUS VECTOR SIZES
15
Chris Lattner95ab2682006-03-17 20:04:40 +000016void %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}
Chris Lattner1e4af782006-03-19 00:20:03 +000047
Chris Lattner4d2182a2006-03-21 18:27:27 +000048void %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}
Chris Lattner1e4af782006-03-19 00:20:03 +000055;;; TEST VECTOR CONSTRUCTS
56
57void %test_cst(%f4 *%P, %f4 *%S) {
58 %p = load %f4* %P
59 %R = add %f4 %p, <float 0.1, float 1.0, float 2.0, float 4.5>
60 store %f4 %R, %f4 *%S
61 ret void
62}
63
64void %test_zero(%f4 *%P, %f4 *%S) {
65 %p = load %f4* %P
66 %R = add %f4 %p, zeroinitializer
67 store %f4 %R, %f4 *%S
68 ret void
69}
70
71void %test_undef(%f4 *%P, %f4 *%S) {
72 %p = load %f4* %P
73 %R = add %f4 %p, undef
74 store %f4 %R, %f4 *%S
75 ret void
76}
Chris Lattner152c72d2006-03-19 01:27:04 +000077
78void %test_constant_insert(%f4 *%S) {
79 %R = insertelement %f4 zeroinitializer, float 10.0, uint 0
80 store %f4 %R, %f4 *%S
81 ret void
82}
83
84void %test_variable_buildvector(float %F, %f4 *%S) {
85 %R = insertelement %f4 zeroinitializer, float %F, uint 0
86 store %f4 %R, %f4 *%S
87 ret void
88}
Chris Lattner00e2c942006-03-19 04:45:11 +000089
Chris Lattner7ca97772006-03-19 05:46:51 +000090void %test_scalar_to_vector(float %F, %f4 *%S) {
91 %R = insertelement %f4 undef, float %F, uint 0 ;; R = scalar_to_vector F
92 store %f4 %R, %f4 *%S
93 ret void
94}
95
Chris Lattner5d37acc2006-03-23 21:15:57 +000096float %test_extract_elt(%f8 *%P) {
97 %p = load %f8* %P
98 %R = extractelement %f8 %p, uint 3
99 ret float %R
100}
101
102void %test_cast_1(<4 x float>* %b, <4 x int>* %a) {
103 %tmp = load <4 x float>* %b
104 %tmp2 = add <4 x float> %tmp, <float 1.0, float 2.0, float 3.0, float 4.0>
105 %tmp3 = cast <4 x float> %tmp2 to <4 x int>
106 %tmp4 = add <4 x int> %tmp3, <int 1, int 2, int 3, int 4>
107 store <4 x int> %tmp4, <4 x int>* %a
108 ret void
109}
110
111void %test_cast_2(<8 x float>* %a, <8 x int>* %b) {
112 %T = load <8 x float>* %a
113 %T2 = cast <8 x float> %T to <8 x int>
114 store <8 x int> %T2, <8 x int>* %b
115 ret void
116}
117
118
Chris Lattner00e2c942006-03-19 04:45:11 +0000119;;; TEST IMPORTANT IDIOMS
120
121void %splat(%f4* %P, %f4* %Q, float %X) {
122 %tmp = insertelement %f4 undef, float %X, uint 0
123 %tmp2 = insertelement %f4 %tmp, float %X, uint 1
124 %tmp4 = insertelement %f4 %tmp2, float %X, uint 2
125 %tmp6 = insertelement %f4 %tmp4, float %X, uint 3
126 %q = load %f4* %Q
127 %R = add %f4 %q, %tmp6
128 store %f4 %R, %f4* %P
129 ret void
130}
131
Chris Lattner4d2182a2006-03-21 18:27:27 +0000132void %splat_i4(%i4* %P, %i4* %Q, int %X) {
133 %tmp = insertelement %i4 undef, int %X, uint 0
134 %tmp2 = insertelement %i4 %tmp, int %X, uint 1
135 %tmp4 = insertelement %i4 %tmp2, int %X, uint 2
136 %tmp6 = insertelement %i4 %tmp4, int %X, uint 3
137 %q = load %i4* %Q
138 %R = add %i4 %q, %tmp6
139 store %i4 %R, %i4* %P
140 ret void
141}
142