• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; 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]+}}
14; CHECK-NEXT: b.gt
15; CHECK-NOT: cmp
16; CHECK: b.ne
17entry:
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
22
23if.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
25  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
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
33  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]+}}
42; CHECK-NEXT: b.le
43; CHECK-NOT: cmp
44; CHECK: b.ge
45entry:
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
50
51if.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
53  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
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
61  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]+}}
70; CHECK-NEXT: b.hi
71; CHECK-NOT: cmp
72; CHECK: b.ne
73entry:
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
78
79if.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
81  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
88  store i16 %0, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
89  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]+}}
98; CHECK-NEXT: b.ls
99; CHECK-NOT: cmp
100; CHECK: b.hs
101entry:
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
106
107if.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
109  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
116  store i16 %1, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 0), align 2
117  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]+}}
135; CHECK-NEXT: b.gt
136; CHECK-NOT: cmp
137; CHECK: b.ne
138entry:
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
143
144if.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
146  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
153  store i8 %0, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
154  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]+}}
163; CHECK-NEXT: b.le
164; CHECK-NOT: cmp
165; CHECK: b.ge
166entry:
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
171
172if.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
174  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
181  store i8 %1, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 0), align 2
182  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]+}}
191; CHECK-NEXT: b.hi
192; CHECK-NOT: cmp
193; CHECK: b.ne
194entry:
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
199
200if.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
202  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
209  store i8 %0, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
210  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]+}}
219; CHECK-NEXT: b.ls
220; CHECK-NOT: cmp
221; CHECK: b.hs
222entry:
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
227
228if.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
230  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
237  store i8 %1, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 0), align 2
238  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}
255