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