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
10 %f2 = type <2 x float>
11 %f4 = type <4 x float>
13 %f8 = type <8 x float>
14 %d8 = type <8 x double>
18 ;;; TEST HANDLING OF VARIOUS VECTOR SIZES
20 void %test_f1(%f1 *%P, %f1* %Q, %f1 *%S) {
28 void %test_f2(%f2 *%P, %f2* %Q, %f2 *%S) {
36 void %test_f4(%f4 *%P, %f4* %Q, %f4 *%S) {
44 void %test_f8(%f8 *%P, %f8* %Q, %f8 *%S) {
52 void %test_fmul(%f8 *%P, %f8* %Q, %f8 *%S) {
60 void %test_div(%f8 *%P, %f8* %Q, %f8 *%S) {
68 ;;; TEST VECTOR CONSTRUCTS
70 void %test_cst(%f4 *%P, %f4 *%S) {
72 %R = add %f4 %p, <float 0.1, float 1.0, float 2.0, float 4.5>
77 void %test_zero(%f4 *%P, %f4 *%S) {
79 %R = add %f4 %p, zeroinitializer
84 void %test_undef(%f4 *%P, %f4 *%S) {
86 %R = add %f4 %p, undef
91 void %test_constant_insert(%f4 *%S) {
92 %R = insertelement %f4 zeroinitializer, float 10.0, uint 0
97 void %test_variable_buildvector(float %F, %f4 *%S) {
98 %R = insertelement %f4 zeroinitializer, float %F, uint 0
103 void %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
109 float %test_extract_elt(%f8 *%P) {
111 %R = extractelement %f8 %p, uint 3
115 double %test_extract_elt2(%d8 *%P) {
117 %R = extractelement %d8 %p, uint 3
121 void %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
130 void %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
138 ;;; TEST IMPORTANT IDIOMS
140 void %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
146 %R = add %f4 %q, %tmp6
147 store %f4 %R, %f4* %P
151 void %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
157 %R = add %i4 %q, %tmp6
158 store %i4 %R, %i4* %P