Add a run with an unusual target triple, revert the patch that sent output to
[oota-llvm.git] / test / CodeGen / Generic / vector.ll
1 ; Test that vectors are scalarized/lowered correctly.
2 ; 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
8
9 %f1 = type <1 x float>
10 %f2 = type <2 x float>
11 %f4 = type <4 x float>
12 %i4 = type <4 x int>
13 %f8 = type <8 x float>
14 %d8 = type <8 x double>
15
16 implementation
17
18 ;;; TEST HANDLING OF VARIOUS VECTOR SIZES
19
20 void %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
28 void %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
36 void %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
44 void %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 }
51
52 void %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 }
59 ;;; TEST VECTOR CONSTRUCTS
60
61 void %test_cst(%f4 *%P, %f4 *%S) {
62   %p = load %f4* %P
63   %R = add %f4 %p, <float 0.1, float 1.0, float 2.0, float 4.5>
64   store %f4 %R, %f4 *%S
65   ret void
66 }
67
68 void %test_zero(%f4 *%P, %f4 *%S) {
69   %p = load %f4* %P
70   %R = add %f4 %p, zeroinitializer
71   store %f4 %R, %f4 *%S
72   ret void
73 }
74
75 void %test_undef(%f4 *%P, %f4 *%S) {
76   %p = load %f4* %P
77   %R = add %f4 %p, undef
78   store %f4 %R, %f4 *%S
79   ret void
80 }
81
82 void %test_constant_insert(%f4 *%S) {
83   %R = insertelement %f4 zeroinitializer, float 10.0, uint 0
84   store %f4 %R, %f4 *%S
85   ret void
86 }
87
88 void %test_variable_buildvector(float %F, %f4 *%S) {
89   %R = insertelement %f4 zeroinitializer, float %F, uint 0
90   store %f4 %R, %f4 *%S
91   ret void
92 }
93
94 void %test_scalar_to_vector(float %F, %f4 *%S) {
95   %R = insertelement %f4 undef, float %F, uint 0   ;; R = scalar_to_vector F
96   store %f4 %R, %f4 *%S
97   ret void
98 }
99
100 float %test_extract_elt(%f8 *%P) {
101   %p = load %f8* %P
102   %R = extractelement %f8 %p, uint 3
103   ret float %R
104 }
105
106 double %test_extract_elt2(%d8 *%P) {
107   %p = load %d8* %P
108   %R = extractelement %d8 %p, uint 3
109   ret double %R
110 }
111
112 void %test_cast_1(<4 x float>* %b, <4 x int>* %a) {
113   %tmp = load <4 x float>* %b
114   %tmp2 = add <4 x float> %tmp, <float 1.0, float 2.0, float 3.0, float 4.0>
115   %tmp3 = cast <4 x float> %tmp2 to <4 x int>
116   %tmp4 = add <4 x int> %tmp3, <int 1, int 2, int 3, int 4>
117   store <4 x int> %tmp4, <4 x int>* %a
118   ret void
119 }
120
121 void %test_cast_2(<8 x float>* %a, <8 x int>* %b) {
122   %T = load <8 x float>* %a
123   %T2 = cast <8 x float> %T to <8 x int>
124   store <8 x int> %T2, <8 x int>* %b
125   ret void
126 }
127
128
129 ;;; TEST IMPORTANT IDIOMS
130
131 void %splat(%f4* %P, %f4* %Q, float %X) {
132         %tmp = insertelement %f4 undef, float %X, uint 0
133         %tmp2 = insertelement %f4 %tmp, float %X, uint 1
134         %tmp4 = insertelement %f4 %tmp2, float %X, uint 2
135         %tmp6 = insertelement %f4 %tmp4, float %X, uint 3
136         %q = load %f4* %Q
137         %R = add %f4 %q, %tmp6
138         store %f4 %R, %f4* %P
139         ret void
140 }
141
142 void %splat_i4(%i4* %P, %i4* %Q, int %X) {
143         %tmp = insertelement %i4 undef, int %X, uint 0
144         %tmp2 = insertelement %i4 %tmp, int %X, uint 1
145         %tmp4 = insertelement %i4 %tmp2, int %X, uint 2
146         %tmp6 = insertelement %i4 %tmp4, int %X, uint 3
147         %q = load %i4* %Q
148         %R = add %i4 %q, %tmp6
149         store %i4 %R, %i4* %P
150         ret void
151 }
152