ff08faf55a3e8f5e00e881a175be57e0eb036c6d
[oota-llvm.git] / test / ExecutionEngine / test-interp-vec-loadstore.ll
1 ; RUN: %lli -force-interpreter=true %s | FileCheck %s
2 ; XFAIL: mips
3 ; CHECK: int test passed
4 ; CHECK: double test passed
5 ; CHECK: float test passed
6
7 @msg_int = internal global [17 x i8] c"int test passed\0A\00"
8 @msg_double = internal global [20 x i8] c"double test passed\0A\00"
9 @msg_float = internal global [19 x i8] c"float test passed\0A\00"
10
11 declare i32 @printf(i8*, ...)
12
13 define i32 @main() {
14   %a = alloca <4 x i32>, align 16
15   %b = alloca <4 x double>, align 16
16   %c = alloca <4 x float>, align 16
17   %pint_0 = alloca i32
18   %pint_1 = alloca i32
19   %pint_2 = alloca i32
20   %pint_3 = alloca i32
21   %pdouble_0 = alloca double
22   %pdouble_1 = alloca double
23   %pdouble_2 = alloca double
24   %pdouble_3 = alloca double
25   %pfloat_0 = alloca float
26   %pfloat_1 = alloca float
27   %pfloat_2 = alloca float
28   %pfloat_3 = alloca float
29
30   ; store constants 1,2,3,4 as vector
31   store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %a, align 16
32   ; store constants 1,2,3,4 as scalars
33   store i32 1, i32* %pint_0
34   store i32 2, i32* %pint_1
35   store i32 3, i32* %pint_2
36   store i32 4, i32* %pint_3
37   
38   ; load stored scalars
39   %val_int0 = load i32* %pint_0
40   %val_int1 = load i32* %pint_1
41   %val_int2 = load i32* %pint_2
42   %val_int3 = load i32* %pint_3
43
44   ; load stored vector
45   %val0 = load <4 x i32> *%a, align 16
46
47   ; extract integers from the loaded vector
48   %res_i32_0 = extractelement <4 x i32> %val0, i32 0
49   %res_i32_1 = extractelement <4 x i32> %val0, i32 1
50   %res_i32_2 = extractelement <4 x i32> %val0, i32 2
51   %res_i32_3 = extractelement <4 x i32> %val0, i32 3
52
53   ; compare extracted data with stored constants
54   %test_result_int_0 = icmp eq i32 %res_i32_0, %val_int0
55   %test_result_int_1 = icmp eq i32 %res_i32_1, %val_int1
56   %test_result_int_2 = icmp eq i32 %res_i32_2, %val_int2
57   %test_result_int_3 = icmp eq i32 %res_i32_3, %val_int3
58
59   %test_result_int_4 = icmp eq i32 %res_i32_0, %val_int3
60   %test_result_int_5 = icmp eq i32 %res_i32_1, %val_int2
61   %test_result_int_6 = icmp eq i32 %res_i32_2, %val_int1
62   %test_result_int_7 = icmp eq i32 %res_i32_3, %val_int0
63
64   ; it should be TRUE
65   %A_i = or i1 %test_result_int_0, %test_result_int_4
66   %B_i = or i1 %test_result_int_1, %test_result_int_5
67   %C_i = or i1 %test_result_int_2, %test_result_int_6
68   %D_i = or i1 %test_result_int_3, %test_result_int_7
69   %E_i = and i1 %A_i, %B_i
70   %F_i = and i1 %C_i, %D_i
71   %res_i = and i1 %E_i, %F_i
72
73   ; if TRUE print message
74   br i1 %res_i, label %Print_int, label %Double
75 Print_int:
76   %ptr0 = getelementptr [17 x i8]* @msg_int, i32 0, i32 0
77   call i32 (i8*,...)* @printf(i8* %ptr0)
78   br label %Double
79 Double:
80   store <4 x double> <double 5.0, double 6.0, double 7.0, double 8.0>, <4 x double>* %b, align 16
81   ; store constants as scalars
82   store double 5.0, double* %pdouble_0
83   store double 6.0, double* %pdouble_1
84   store double 7.0, double* %pdouble_2
85   store double 8.0, double* %pdouble_3
86
87   ; load stored vector
88   %val1 = load <4 x double> *%b, align 16
89   ; load stored scalars
90   %val_double0 = load double* %pdouble_0
91   %val_double1 = load double* %pdouble_1
92   %val_double2 = load double* %pdouble_2
93   %val_double3 = load double* %pdouble_3
94
95   %res_double_0 = extractelement <4 x double> %val1, i32 0
96   %res_double_1 = extractelement <4 x double> %val1, i32 1
97   %res_double_2 = extractelement <4 x double> %val1, i32 2
98   %res_double_3 = extractelement <4 x double> %val1, i32 3
99
100   %test_result_double_0 = fcmp oeq double %res_double_0, %val_double0
101   %test_result_double_1 = fcmp oeq double %res_double_1, %val_double1
102   %test_result_double_2 = fcmp oeq double %res_double_2, %val_double2
103   %test_result_double_3 = fcmp oeq double %res_double_3, %val_double3
104
105   %test_result_double_4 = fcmp oeq double %res_double_0, %val_double3
106   %test_result_double_5 = fcmp oeq double %res_double_1, %val_double2
107   %test_result_double_6 = fcmp oeq double %res_double_2, %val_double1
108   %test_result_double_7 = fcmp oeq double %res_double_3, %val_double0
109
110   %A_double = or i1 %test_result_double_0, %test_result_double_4
111   %B_double = or i1 %test_result_double_1, %test_result_double_5
112   %C_double = or i1 %test_result_double_2, %test_result_double_6
113   %D_double = or i1 %test_result_double_3, %test_result_double_7
114   %E_double = and i1 %A_double, %B_double
115   %F_double = and i1 %C_double, %D_double
116   %res_double = and i1 %E_double, %F_double
117
118   br i1 %res_double, label %Print_double, label %Float
119 Print_double:
120   %ptr1 = getelementptr [20 x i8]* @msg_double, i32 0, i32 0
121   call i32 (i8*,...)* @printf(i8* %ptr1)
122   br label %Float
123 Float:
124   store <4 x float> <float 9.0, float 10.0, float 11.0, float 12.0>, <4 x float>* %c, align 16
125
126   store float 9.0, float* %pfloat_0
127   store float 10.0, float* %pfloat_1
128   store float 11.0, float* %pfloat_2
129   store float 12.0, float* %pfloat_3
130
131   ; load stored vector
132   %val2 = load <4 x float> *%c, align 16
133   ; load stored scalars
134   %val_float0 = load float* %pfloat_0
135   %val_float1 = load float* %pfloat_1
136   %val_float2 = load float* %pfloat_2
137   %val_float3 = load float* %pfloat_3
138
139   %res_float_0 = extractelement <4 x float> %val2, i32 0
140   %res_float_1 = extractelement <4 x float> %val2, i32 1
141   %res_float_2 = extractelement <4 x float> %val2, i32 2
142   %res_float_3 = extractelement <4 x float> %val2, i32 3
143
144   %test_result_float_0 = fcmp oeq float %res_float_0, %val_float0
145   %test_result_float_1 = fcmp oeq float %res_float_1, %val_float1
146   %test_result_float_2 = fcmp oeq float %res_float_2, %val_float2
147   %test_result_float_3 = fcmp oeq float %res_float_3, %val_float3
148
149   %test_result_float_4 = fcmp oeq float %res_float_0, %val_float3
150   %test_result_float_5 = fcmp oeq float %res_float_1, %val_float2
151   %test_result_float_6 = fcmp oeq float %res_float_2, %val_float1
152   %test_result_float_7 = fcmp oeq float %res_float_3, %val_float0
153
154   %A_float = or i1 %test_result_float_0, %test_result_float_4
155   %B_float = or i1 %test_result_float_1, %test_result_float_5
156   %C_float = or i1 %test_result_float_2, %test_result_float_6
157   %D_float = or i1 %test_result_float_3, %test_result_float_7
158   %E_float = and i1 %A_float, %B_float
159   %F_float = and i1 %C_float, %D_float
160   %res_float = and i1 %E_float, %F_float
161
162   br i1 %res_float, label %Print_float, label %Exit
163 Print_float:
164   %ptr2 = getelementptr [19 x i8]* @msg_float, i32 0, i32 0
165   call i32 (i8*,...)* @printf(i8* %ptr2)
166   br label %Exit
167 Exit:
168
169   ret i32 0
170 }