1 ; RUN: llc < %s -mtriple=aarch64-linux-gnuabi -O2 | FileCheck %s
3 ; The following cases are for i16
5 %struct.s_signed_i16 = type { i16, i16, i16 }
6 %struct.s_unsigned_i16 = type { i16, i16, i16 }
8 @cost_s_i8_i16 = common global %struct.s_signed_i16 zeroinitializer, align 2
9 @cost_u_i16 = common global %struct.s_unsigned_i16 zeroinitializer, align 2
11 define void @test_i16_2cmp_signed_1() {
12 ; CHECK-LABEL: test_i16_2cmp_signed_1
13 ; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
18 %0 = load i16, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 1), align 2
19 %1 = load i16, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 2), align 2
20 %cmp = icmp sgt i16 %0, %1
21 br i1 %cmp, label %if.then, label %if.else
23 if.then: ; preds = %entry
24 store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2
27 if.else: ; preds = %entry
28 %cmp5 = icmp eq i16 %0, %1
29 br i1 %cmp5, label %if.then7, label %if.end8
31 if.then7: ; preds = %if.else
32 store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2
35 if.end8: ; preds = %if.else, %if.then7, %if.then
39 define void @test_i16_2cmp_signed_2() {
40 ; CHECK-LABEL: test_i16_2cmp_signed_2
41 ; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
46 %0 = load i16, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 1), align 2
47 %1 = load i16, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 2), align 2
48 %cmp = icmp sgt i16 %0, %1
49 br i1 %cmp, label %if.then, label %if.else
51 if.then: ; preds = %entry
52 store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2
55 if.else: ; preds = %entry
56 %cmp5 = icmp slt i16 %0, %1
57 br i1 %cmp5, label %if.then7, label %if.end8
59 if.then7: ; preds = %if.else
60 store i16 %1, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2
63 if.end8: ; preds = %if.else, %if.then7, %if.then
67 define void @test_i16_2cmp_unsigned_1() {
68 ; CHECK-LABEL: test_i16_2cmp_unsigned_1
69 ; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
74 %0 = load i16, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 1), align 2
75 %1 = load i16, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 2), align 2
76 %cmp = icmp ugt i16 %0, %1
77 br i1 %cmp, label %if.then, label %if.else
79 if.then: ; preds = %entry
80 store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
83 if.else: ; preds = %entry
84 %cmp5 = icmp eq i16 %0, %1
85 br i1 %cmp5, label %if.then7, label %if.end8
87 if.then7: ; preds = %if.else
88 store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
91 if.end8: ; preds = %if.else, %if.then7, %if.then
95 define void @test_i16_2cmp_unsigned_2() {
96 ; CHECK-LABEL: test_i16_2cmp_unsigned_2
97 ; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
102 %0 = load i16, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 1), align 2
103 %1 = load i16, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 2), align 2
104 %cmp = icmp ugt i16 %0, %1
105 br i1 %cmp, label %if.then, label %if.else
107 if.then: ; preds = %entry
108 store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
111 if.else: ; preds = %entry
112 %cmp5 = icmp ult i16 %0, %1
113 br i1 %cmp5, label %if.then7, label %if.end8
115 if.then7: ; preds = %if.else
116 store i16 %1, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
119 if.end8: ; preds = %if.else, %if.then7, %if.then
123 ; The following cases are for i8
125 %struct.s_signed_i8 = type { i8, i8, i8 }
126 %struct.s_unsigned_i8 = type { i8, i8, i8 }
128 @cost_s = common global %struct.s_signed_i8 zeroinitializer, align 2
129 @cost_u_i8 = common global %struct.s_unsigned_i8 zeroinitializer, align 2
132 define void @test_i8_2cmp_signed_1() {
133 ; CHECK-LABEL: test_i8_2cmp_signed_1
134 ; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
139 %0 = load i8, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 1), align 2
140 %1 = load i8, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 2), align 2
141 %cmp = icmp sgt i8 %0, %1
142 br i1 %cmp, label %if.then, label %if.else
144 if.then: ; preds = %entry
145 store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
148 if.else: ; preds = %entry
149 %cmp5 = icmp eq i8 %0, %1
150 br i1 %cmp5, label %if.then7, label %if.end8
152 if.then7: ; preds = %if.else
153 store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
156 if.end8: ; preds = %if.else, %if.then7, %if.then
160 define void @test_i8_2cmp_signed_2() {
161 ; CHECK-LABEL: test_i8_2cmp_signed_2
162 ; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
167 %0 = load i8, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 1), align 2
168 %1 = load i8, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 2), align 2
169 %cmp = icmp sgt i8 %0, %1
170 br i1 %cmp, label %if.then, label %if.else
172 if.then: ; preds = %entry
173 store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
176 if.else: ; preds = %entry
177 %cmp5 = icmp slt i8 %0, %1
178 br i1 %cmp5, label %if.then7, label %if.end8
180 if.then7: ; preds = %if.else
181 store i8 %1, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
184 if.end8: ; preds = %if.else, %if.then7, %if.then
188 define void @test_i8_2cmp_unsigned_1() {
189 ; CHECK-LABEL: test_i8_2cmp_unsigned_1
190 ; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
195 %0 = load i8, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 1), align 2
196 %1 = load i8, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 2), align 2
197 %cmp = icmp ugt i8 %0, %1
198 br i1 %cmp, label %if.then, label %if.else
200 if.then: ; preds = %entry
201 store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
204 if.else: ; preds = %entry
205 %cmp5 = icmp eq i8 %0, %1
206 br i1 %cmp5, label %if.then7, label %if.end8
208 if.then7: ; preds = %if.else
209 store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
212 if.end8: ; preds = %if.else, %if.then7, %if.then
216 define void @test_i8_2cmp_unsigned_2() {
217 ; CHECK-LABEL: test_i8_2cmp_unsigned_2
218 ; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
223 %0 = load i8, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 1), align 2
224 %1 = load i8, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 2), align 2
225 %cmp = icmp ugt i8 %0, %1
226 br i1 %cmp, label %if.then, label %if.else
228 if.then: ; preds = %entry
229 store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
232 if.else: ; preds = %entry
233 %cmp5 = icmp ult i8 %0, %1
234 br i1 %cmp5, label %if.then7, label %if.end8
236 if.then7: ; preds = %if.else
237 store i8 %1, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
240 if.end8: ; preds = %if.else, %if.then7, %if.then
244 ; Make sure the case below won't crash.
246 ; The optimization of ZERO_EXTEND and SIGN_EXTEND in type legalization stage can't assert
247 ; the operand of a set_cc is always a TRUNCATE.
249 define i1 @foo(float %inl, float %inr) {
250 %lval = fptosi float %inl to i8
251 %rval = fptosi float %inr to i8
252 %sum = icmp eq i8 %lval, %rval