add a new testcase. This insertelement should be a noop on SSE.
[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 -march=ppc32 -mcpu=g5 &&
4 ; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g3
5
6 %f1 = type <1 x float>
7 %f2 = type <2 x float>
8 %f4 = type <4 x float>
9 %f8 = type <8 x float>
10
11 implementation
12
13 ;;; TEST HANDLING OF VARIOUS VECTOR SIZES
14
15 void %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
23 void %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
31 void %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
39 void %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
47 ;;; TEST VECTOR CONSTRUCTS
48
49 void %test_cst(%f4 *%P, %f4 *%S) {
50   %p = load %f4* %P
51   %R = add %f4 %p, <float 0.1, float 1.0, float 2.0, float 4.5>
52   store %f4 %R, %f4 *%S
53   ret void
54 }
55
56 void %test_zero(%f4 *%P, %f4 *%S) {
57   %p = load %f4* %P
58   %R = add %f4 %p, zeroinitializer
59   store %f4 %R, %f4 *%S
60   ret void
61 }
62
63 void %test_undef(%f4 *%P, %f4 *%S) {
64   %p = load %f4* %P
65   %R = add %f4 %p, undef
66   store %f4 %R, %f4 *%S
67   ret void
68 }
69
70 void %test_constant_insert(%f4 *%S) {
71   %R = insertelement %f4 zeroinitializer, float 10.0, uint 0
72   store %f4 %R, %f4 *%S
73   ret void
74 }
75
76 void %test_variable_buildvector(float %F, %f4 *%S) {
77   %R = insertelement %f4 zeroinitializer, float %F, uint 0
78   store %f4 %R, %f4 *%S
79   ret void
80 }
81
82 void %test_scalar_to_vector(float %F, %f4 *%S) {
83   %R = insertelement %f4 undef, float %F, uint 0   ;; R = scalar_to_vector F
84   store %f4 %R, %f4 *%S
85   ret void
86 }
87
88 ;;; TEST IMPORTANT IDIOMS
89
90 void %splat(%f4* %P, %f4* %Q, float %X) {
91         %tmp = insertelement %f4 undef, float %X, uint 0
92         %tmp2 = insertelement %f4 %tmp, float %X, uint 1
93         %tmp4 = insertelement %f4 %tmp2, float %X, uint 2
94         %tmp6 = insertelement %f4 %tmp4, float %X, uint 3
95         %q = load %f4* %Q
96         %R = add %f4 %q, %tmp6
97         store %f4 %R, %f4* %P
98         ret void
99 }
100