blob: 22d0584f63b02b7ad401a0a5ce88ab6d43a3090c [file] [log] [blame]
Jiangning Liuffbc6902014-09-19 05:30:35 +00001; RUN: llc < %s -mtriple=aarch64-linux-gnuabi -O2 | FileCheck %s
2
3; The following cases are for i16
4
5%struct.s_signed_i16 = type { i16, i16, i16 }
6%struct.s_unsigned_i16 = type { i16, i16, i16 }
7
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
10
11define void @test_i16_2cmp_signed_1() {
12; CHECK-LABEL: test_i16_2cmp_signed_1
13; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
James Molloy88cad7e2016-09-01 12:58:13 +000014; CHECK-NEXT: b.lt
Jiangning Liuffbc6902014-09-19 05:30:35 +000015; CHECK-NOT: cmp
James Molloy88cad7e2016-09-01 12:58:13 +000016; CHECK: ret
Jiangning Liuffbc6902014-09-19 05:30:35 +000017entry:
David Blaikief72d05b2015-03-13 18:20:45 +000018 %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
Jiangning Liuffbc6902014-09-19 05:30:35 +000020 %cmp = icmp sgt i16 %0, %1
21 br i1 %cmp, label %if.then, label %if.else
22
23if.then: ; preds = %entry
David Blaikief72d05b2015-03-13 18:20:45 +000024 store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +000025 br label %if.end8
26
27if.else: ; preds = %entry
28 %cmp5 = icmp eq i16 %0, %1
29 br i1 %cmp5, label %if.then7, label %if.end8
30
31if.then7: ; preds = %if.else
David Blaikief72d05b2015-03-13 18:20:45 +000032 store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +000033 br label %if.end8
34
35if.end8: ; preds = %if.else, %if.then7, %if.then
36 ret void
37}
38
39define void @test_i16_2cmp_signed_2() {
40; CHECK-LABEL: test_i16_2cmp_signed_2
41; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
James Molloy88cad7e2016-09-01 12:58:13 +000042; CHECK-NEXT: b.gt
Jiangning Liuffbc6902014-09-19 05:30:35 +000043; CHECK-NOT: cmp
44; CHECK: b.ge
45entry:
David Blaikief72d05b2015-03-13 18:20:45 +000046 %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
Jiangning Liuffbc6902014-09-19 05:30:35 +000048 %cmp = icmp sgt i16 %0, %1
49 br i1 %cmp, label %if.then, label %if.else
50
51if.then: ; preds = %entry
David Blaikief72d05b2015-03-13 18:20:45 +000052 store i16 %0, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +000053 br label %if.end8
54
55if.else: ; preds = %entry
56 %cmp5 = icmp slt i16 %0, %1
57 br i1 %cmp5, label %if.then7, label %if.end8
58
59if.then7: ; preds = %if.else
David Blaikief72d05b2015-03-13 18:20:45 +000060 store i16 %1, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +000061 br label %if.end8
62
63if.end8: ; preds = %if.else, %if.then7, %if.then
64 ret void
65}
66
67define void @test_i16_2cmp_unsigned_1() {
68; CHECK-LABEL: test_i16_2cmp_unsigned_1
69; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
James Molloy88cad7e2016-09-01 12:58:13 +000070; CHECK-NEXT: b.lo
Jiangning Liuffbc6902014-09-19 05:30:35 +000071; CHECK-NOT: cmp
James Molloy88cad7e2016-09-01 12:58:13 +000072; CHECK: ret
Jiangning Liuffbc6902014-09-19 05:30:35 +000073entry:
David Blaikief72d05b2015-03-13 18:20:45 +000074 %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
Jiangning Liuffbc6902014-09-19 05:30:35 +000076 %cmp = icmp ugt i16 %0, %1
77 br i1 %cmp, label %if.then, label %if.else
78
79if.then: ; preds = %entry
David Blaikief72d05b2015-03-13 18:20:45 +000080 store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +000081 br label %if.end8
82
83if.else: ; preds = %entry
84 %cmp5 = icmp eq i16 %0, %1
85 br i1 %cmp5, label %if.then7, label %if.end8
86
87if.then7: ; preds = %if.else
David Blaikief72d05b2015-03-13 18:20:45 +000088 store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +000089 br label %if.end8
90
91if.end8: ; preds = %if.else, %if.then7, %if.then
92 ret void
93}
94
95define void @test_i16_2cmp_unsigned_2() {
96; CHECK-LABEL: test_i16_2cmp_unsigned_2
97; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
James Molloy88cad7e2016-09-01 12:58:13 +000098; CHECK-NEXT: b.hi
Jiangning Liuffbc6902014-09-19 05:30:35 +000099; CHECK-NOT: cmp
100; CHECK: b.hs
101entry:
David Blaikief72d05b2015-03-13 18:20:45 +0000102 %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
Jiangning Liuffbc6902014-09-19 05:30:35 +0000104 %cmp = icmp ugt i16 %0, %1
105 br i1 %cmp, label %if.then, label %if.else
106
107if.then: ; preds = %entry
David Blaikief72d05b2015-03-13 18:20:45 +0000108 store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000109 br label %if.end8
110
111if.else: ; preds = %entry
112 %cmp5 = icmp ult i16 %0, %1
113 br i1 %cmp5, label %if.then7, label %if.end8
114
115if.then7: ; preds = %if.else
David Blaikief72d05b2015-03-13 18:20:45 +0000116 store i16 %1, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000117 br label %if.end8
118
119if.end8: ; preds = %if.else, %if.then7, %if.then
120 ret void
121}
122
123; The following cases are for i8
124
125%struct.s_signed_i8 = type { i8, i8, i8 }
126%struct.s_unsigned_i8 = type { i8, i8, i8 }
127
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
130
131
132define void @test_i8_2cmp_signed_1() {
133; CHECK-LABEL: test_i8_2cmp_signed_1
134; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
James Molloy88cad7e2016-09-01 12:58:13 +0000135; CHECK-NEXT: b.lt
Jiangning Liuffbc6902014-09-19 05:30:35 +0000136; CHECK-NOT: cmp
James Molloy88cad7e2016-09-01 12:58:13 +0000137; CHECK: ret
Jiangning Liuffbc6902014-09-19 05:30:35 +0000138entry:
David Blaikief72d05b2015-03-13 18:20:45 +0000139 %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
Jiangning Liuffbc6902014-09-19 05:30:35 +0000141 %cmp = icmp sgt i8 %0, %1
142 br i1 %cmp, label %if.then, label %if.else
143
144if.then: ; preds = %entry
David Blaikief72d05b2015-03-13 18:20:45 +0000145 store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000146 br label %if.end8
147
148if.else: ; preds = %entry
149 %cmp5 = icmp eq i8 %0, %1
150 br i1 %cmp5, label %if.then7, label %if.end8
151
152if.then7: ; preds = %if.else
David Blaikief72d05b2015-03-13 18:20:45 +0000153 store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000154 br label %if.end8
155
156if.end8: ; preds = %if.else, %if.then7, %if.then
157 ret void
158}
159
160define void @test_i8_2cmp_signed_2() {
161; CHECK-LABEL: test_i8_2cmp_signed_2
162; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
James Molloy88cad7e2016-09-01 12:58:13 +0000163; CHECK-NEXT: b.gt
Jiangning Liuffbc6902014-09-19 05:30:35 +0000164; CHECK-NOT: cmp
165; CHECK: b.ge
166entry:
David Blaikief72d05b2015-03-13 18:20:45 +0000167 %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
Jiangning Liuffbc6902014-09-19 05:30:35 +0000169 %cmp = icmp sgt i8 %0, %1
170 br i1 %cmp, label %if.then, label %if.else
171
172if.then: ; preds = %entry
David Blaikief72d05b2015-03-13 18:20:45 +0000173 store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000174 br label %if.end8
175
176if.else: ; preds = %entry
177 %cmp5 = icmp slt i8 %0, %1
178 br i1 %cmp5, label %if.then7, label %if.end8
179
180if.then7: ; preds = %if.else
David Blaikief72d05b2015-03-13 18:20:45 +0000181 store i8 %1, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000182 br label %if.end8
183
184if.end8: ; preds = %if.else, %if.then7, %if.then
185 ret void
186}
187
188define void @test_i8_2cmp_unsigned_1() {
189; CHECK-LABEL: test_i8_2cmp_unsigned_1
190; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
James Molloy88cad7e2016-09-01 12:58:13 +0000191; CHECK-NEXT: b.lo
Jiangning Liuffbc6902014-09-19 05:30:35 +0000192; CHECK-NOT: cmp
James Molloy88cad7e2016-09-01 12:58:13 +0000193; CHECK: ret
Jiangning Liuffbc6902014-09-19 05:30:35 +0000194entry:
David Blaikief72d05b2015-03-13 18:20:45 +0000195 %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
Jiangning Liuffbc6902014-09-19 05:30:35 +0000197 %cmp = icmp ugt i8 %0, %1
198 br i1 %cmp, label %if.then, label %if.else
199
200if.then: ; preds = %entry
David Blaikief72d05b2015-03-13 18:20:45 +0000201 store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000202 br label %if.end8
203
204if.else: ; preds = %entry
205 %cmp5 = icmp eq i8 %0, %1
206 br i1 %cmp5, label %if.then7, label %if.end8
207
208if.then7: ; preds = %if.else
David Blaikief72d05b2015-03-13 18:20:45 +0000209 store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000210 br label %if.end8
211
212if.end8: ; preds = %if.else, %if.then7, %if.then
213 ret void
214}
215
216define void @test_i8_2cmp_unsigned_2() {
217; CHECK-LABEL: test_i8_2cmp_unsigned_2
218; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
James Molloy88cad7e2016-09-01 12:58:13 +0000219; CHECK-NEXT: b.hi
Jiangning Liuffbc6902014-09-19 05:30:35 +0000220; CHECK-NOT: cmp
221; CHECK: b.hs
222entry:
David Blaikief72d05b2015-03-13 18:20:45 +0000223 %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
Jiangning Liuffbc6902014-09-19 05:30:35 +0000225 %cmp = icmp ugt i8 %0, %1
226 br i1 %cmp, label %if.then, label %if.else
227
228if.then: ; preds = %entry
David Blaikief72d05b2015-03-13 18:20:45 +0000229 store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000230 br label %if.end8
231
232if.else: ; preds = %entry
233 %cmp5 = icmp ult i8 %0, %1
234 br i1 %cmp5, label %if.then7, label %if.end8
235
236if.then7: ; preds = %if.else
David Blaikief72d05b2015-03-13 18:20:45 +0000237 store i8 %1, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
Jiangning Liuffbc6902014-09-19 05:30:35 +0000238 br label %if.end8
239
240if.end8: ; preds = %if.else, %if.then7, %if.then
241 ret void
242}
243
244; Make sure the case below won't crash.
245
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.
248
249define 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
253 ret i1 %sum
254}