wide-compares.ll
11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=armv7-unknown-linux < %s -verify-machineinstrs | FileCheck --check-prefix=CHECK-ARM %s
; RUN: llc -mtriple=thumb-eabi < %s -verify-machineinstrs | FileCheck --check-prefix=CHECK-THUMB1-NOMOV %s
; RUN: llc -mtriple=thumbv6-unknown-linux < %s -verify-machineinstrs | FileCheck --check-prefix=CHECK-THUMB1 %s
; RUN: llc -mtriple=thumbv7-unknown-linux < %s -verify-machineinstrs | FileCheck --check-prefix=CHECK-THUMB2 %s
define i32 @test_slt1(i64 %a, i64 %b) {
; CHECK-ARM-LABEL: test_slt1:
; CHECK-ARM: @ %bb.0: @ %entry
; CHECK-ARM-NEXT: subs r0, r0, r2
; CHECK-ARM-NEXT: mov r12, #2
; CHECK-ARM-NEXT: sbcs r0, r1, r3
; CHECK-ARM-NEXT: movwlt r12, #1
; CHECK-ARM-NEXT: mov r0, r12
; CHECK-ARM-NEXT: bx lr
;
; CHECK-THUMB1-NOMOV-LABEL: test_slt1:
; CHECK-THUMB1-NOMOV: @ %bb.0: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: subs r0, r0, r2
; CHECK-THUMB1-NOMOV-NEXT: sbcs r1, r3
; CHECK-THUMB1-NOMOV-NEXT: bge .LBB0_2
; CHECK-THUMB1-NOMOV-NEXT: @ %bb.1: @ %bb1
; CHECK-THUMB1-NOMOV-NEXT: movs r0, #1
; CHECK-THUMB1-NOMOV-NEXT: bx lr
; CHECK-THUMB1-NOMOV-NEXT: .LBB0_2: @ %bb2
; CHECK-THUMB1-NOMOV-NEXT: movs r0, #2
; CHECK-THUMB1-NOMOV-NEXT: bx lr
;
; CHECK-THUMB1-LABEL: test_slt1:
; CHECK-THUMB1: @ %bb.0: @ %entry
; CHECK-THUMB1-NEXT: subs r0, r0, r2
; CHECK-THUMB1-NEXT: sbcs r1, r3
; CHECK-THUMB1-NEXT: bge .LBB0_2
; CHECK-THUMB1-NEXT: @ %bb.1: @ %bb1
; CHECK-THUMB1-NEXT: movs r0, #1
; CHECK-THUMB1-NEXT: bx lr
; CHECK-THUMB1-NEXT: .LBB0_2: @ %bb2
; CHECK-THUMB1-NEXT: movs r0, #2
; CHECK-THUMB1-NEXT: bx lr
;
; CHECK-THUMB2-LABEL: test_slt1:
; CHECK-THUMB2: @ %bb.0: @ %entry
; CHECK-THUMB2-NEXT: subs r0, r0, r2
; CHECK-THUMB2-NEXT: mov.w r12, #2
; CHECK-THUMB2-NEXT: sbcs.w r0, r1, r3
; CHECK-THUMB2-NEXT: it lt
; CHECK-THUMB2-NEXT: movlt.w r12, #1
; CHECK-THUMB2-NEXT: mov r0, r12
; CHECK-THUMB2-NEXT: bx lr
entry:
%cmp = icmp slt i64 %a, %b
br i1 %cmp, label %bb1, label %bb2
bb1:
ret i32 1
bb2:
ret i32 2
}
define void @test_slt2(i64 %a, i64 %b) {
; CHECK-ARM-LABEL: test_slt2:
; CHECK-ARM: @ %bb.0: @ %entry
; CHECK-ARM-NEXT: push {r11, lr}
; CHECK-ARM-NEXT: subs r0, r0, r2
; CHECK-ARM-NEXT: sbcs r0, r1, r3
; CHECK-ARM-NEXT: bge .LBB1_2
; CHECK-ARM-NEXT: @ %bb.1: @ %bb1
; CHECK-ARM-NEXT: bl f
; CHECK-ARM-NEXT: pop {r11, pc}
; CHECK-ARM-NEXT: .LBB1_2: @ %bb2
; CHECK-ARM-NEXT: bl g
; CHECK-ARM-NEXT: pop {r11, pc}
;
; CHECK-THUMB1-NOMOV-LABEL: test_slt2:
; CHECK-THUMB1-NOMOV: @ %bb.0: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: .save {r7, lr}
; CHECK-THUMB1-NOMOV-NEXT: push {r7, lr}
; CHECK-THUMB1-NOMOV-NEXT: subs r0, r0, r2
; CHECK-THUMB1-NOMOV-NEXT: sbcs r1, r3
; CHECK-THUMB1-NOMOV-NEXT: bge .LBB1_2
; CHECK-THUMB1-NOMOV-NEXT: @ %bb.1: @ %bb1
; CHECK-THUMB1-NOMOV-NEXT: bl f
; CHECK-THUMB1-NOMOV-NEXT: b .LBB1_3
; CHECK-THUMB1-NOMOV-NEXT: .LBB1_2: @ %bb2
; CHECK-THUMB1-NOMOV-NEXT: bl g
; CHECK-THUMB1-NOMOV-NEXT: .LBB1_3: @ %bb1
; CHECK-THUMB1-NOMOV-NEXT: pop {r7}
; CHECK-THUMB1-NOMOV-NEXT: pop {r0}
; CHECK-THUMB1-NOMOV-NEXT: bx r0
;
; CHECK-THUMB1-LABEL: test_slt2:
; CHECK-THUMB1: @ %bb.0: @ %entry
; CHECK-THUMB1-NEXT: push {r7, lr}
; CHECK-THUMB1-NEXT: subs r0, r0, r2
; CHECK-THUMB1-NEXT: sbcs r1, r3
; CHECK-THUMB1-NEXT: bge .LBB1_2
; CHECK-THUMB1-NEXT: @ %bb.1: @ %bb1
; CHECK-THUMB1-NEXT: bl f
; CHECK-THUMB1-NEXT: pop {r7, pc}
; CHECK-THUMB1-NEXT: .LBB1_2: @ %bb2
; CHECK-THUMB1-NEXT: bl g
; CHECK-THUMB1-NEXT: pop {r7, pc}
;
; CHECK-THUMB2-LABEL: test_slt2:
; CHECK-THUMB2: @ %bb.0: @ %entry
; CHECK-THUMB2-NEXT: push {r7, lr}
; CHECK-THUMB2-NEXT: subs r0, r0, r2
; CHECK-THUMB2-NEXT: sbcs.w r0, r1, r3
; CHECK-THUMB2-NEXT: bge .LBB1_2
; CHECK-THUMB2-NEXT: @ %bb.1: @ %bb1
; CHECK-THUMB2-NEXT: bl f
; CHECK-THUMB2-NEXT: pop {r7, pc}
; CHECK-THUMB2-NEXT: .LBB1_2: @ %bb2
; CHECK-THUMB2-NEXT: bl g
; CHECK-THUMB2-NEXT: pop {r7, pc}
entry:
%cmp = icmp slt i64 %a, %b
br i1 %cmp, label %bb1, label %bb2
bb1:
call void @f()
ret void
bb2:
call void @g()
ret void
}
declare void @f()
declare void @g()
define i64 @test_slt_select(i64 %c, i64 %d, i64 %a, i64 %b) {
; CHECK-ARM-LABEL: test_slt_select:
; CHECK-ARM: @ %bb.0: @ %entry
; CHECK-ARM-NEXT: push {r4, r5, r6, r7, r11, lr}
; CHECK-ARM-NEXT: ldr r12, [sp, #32]
; CHECK-ARM-NEXT: mov r6, #0
; CHECK-ARM-NEXT: ldr lr, [sp, #24]
; CHECK-ARM-NEXT: ldr r7, [sp, #36]
; CHECK-ARM-NEXT: ldr r5, [sp, #28]
; CHECK-ARM-NEXT: subs r4, lr, r12
; CHECK-ARM-NEXT: sbcs r7, r5, r7
; CHECK-ARM-NEXT: movwlo r6, #1
; CHECK-ARM-NEXT: cmp r6, #0
; CHECK-ARM-NEXT: moveq r0, r2
; CHECK-ARM-NEXT: moveq r1, r3
; CHECK-ARM-NEXT: pop {r4, r5, r6, r7, r11, pc}
;
; CHECK-THUMB1-NOMOV-LABEL: test_slt_select:
; CHECK-THUMB1-NOMOV: @ %bb.0: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: .save {r4, r5, r6, r7, lr}
; CHECK-THUMB1-NOMOV-NEXT: push {r4, r5, r6, r7, lr}
; CHECK-THUMB1-NOMOV-NEXT: .pad #4
; CHECK-THUMB1-NOMOV-NEXT: sub sp, #4
; CHECK-THUMB1-NOMOV-NEXT: ldr r4, [sp, #36]
; CHECK-THUMB1-NOMOV-NEXT: ldr r5, [sp, #28]
; CHECK-THUMB1-NOMOV-NEXT: ldr r6, [sp, #32]
; CHECK-THUMB1-NOMOV-NEXT: ldr r7, [sp, #24]
; CHECK-THUMB1-NOMOV-NEXT: subs r6, r7, r6
; CHECK-THUMB1-NOMOV-NEXT: sbcs r5, r4
; CHECK-THUMB1-NOMOV-NEXT: blo .LBB2_2
; CHECK-THUMB1-NOMOV-NEXT: @ %bb.1: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: movs r4, #0
; CHECK-THUMB1-NOMOV-NEXT: cmp r4, #0
; CHECK-THUMB1-NOMOV-NEXT: beq .LBB2_3
; CHECK-THUMB1-NOMOV-NEXT: b .LBB2_4
; CHECK-THUMB1-NOMOV-NEXT: .LBB2_2:
; CHECK-THUMB1-NOMOV-NEXT: movs r4, #1
; CHECK-THUMB1-NOMOV-NEXT: cmp r4, #0
; CHECK-THUMB1-NOMOV-NEXT: bne .LBB2_4
; CHECK-THUMB1-NOMOV-NEXT: .LBB2_3: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: movs r0, r2
; CHECK-THUMB1-NOMOV-NEXT: .LBB2_4: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: cmp r4, #0
; CHECK-THUMB1-NOMOV-NEXT: bne .LBB2_6
; CHECK-THUMB1-NOMOV-NEXT: @ %bb.5: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: movs r1, r3
; CHECK-THUMB1-NOMOV-NEXT: .LBB2_6: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: add sp, #4
; CHECK-THUMB1-NOMOV-NEXT: pop {r4, r5, r6, r7}
; CHECK-THUMB1-NOMOV-NEXT: pop {r2}
; CHECK-THUMB1-NOMOV-NEXT: bx r2
;
; CHECK-THUMB1-LABEL: test_slt_select:
; CHECK-THUMB1: @ %bb.0: @ %entry
; CHECK-THUMB1-NEXT: push {r4, r5, r6, r7, lr}
; CHECK-THUMB1-NEXT: sub sp, #4
; CHECK-THUMB1-NEXT: ldr r4, [sp, #36]
; CHECK-THUMB1-NEXT: ldr r5, [sp, #28]
; CHECK-THUMB1-NEXT: ldr r6, [sp, #32]
; CHECK-THUMB1-NEXT: ldr r7, [sp, #24]
; CHECK-THUMB1-NEXT: subs r6, r7, r6
; CHECK-THUMB1-NEXT: sbcs r5, r4
; CHECK-THUMB1-NEXT: blo .LBB2_2
; CHECK-THUMB1-NEXT: @ %bb.1: @ %entry
; CHECK-THUMB1-NEXT: movs r4, #0
; CHECK-THUMB1-NEXT: cmp r4, #0
; CHECK-THUMB1-NEXT: beq .LBB2_3
; CHECK-THUMB1-NEXT: b .LBB2_4
; CHECK-THUMB1-NEXT: .LBB2_2:
; CHECK-THUMB1-NEXT: movs r4, #1
; CHECK-THUMB1-NEXT: cmp r4, #0
; CHECK-THUMB1-NEXT: bne .LBB2_4
; CHECK-THUMB1-NEXT: .LBB2_3: @ %entry
; CHECK-THUMB1-NEXT: mov r0, r2
; CHECK-THUMB1-NEXT: .LBB2_4: @ %entry
; CHECK-THUMB1-NEXT: cmp r4, #0
; CHECK-THUMB1-NEXT: beq .LBB2_6
; CHECK-THUMB1-NEXT: @ %bb.5: @ %entry
; CHECK-THUMB1-NEXT: add sp, #4
; CHECK-THUMB1-NEXT: pop {r4, r5, r6, r7, pc}
; CHECK-THUMB1-NEXT: .LBB2_6: @ %entry
; CHECK-THUMB1-NEXT: mov r1, r3
; CHECK-THUMB1-NEXT: add sp, #4
; CHECK-THUMB1-NEXT: pop {r4, r5, r6, r7, pc}
;
; CHECK-THUMB2-LABEL: test_slt_select:
; CHECK-THUMB2: @ %bb.0: @ %entry
; CHECK-THUMB2-NEXT: push {r4, r5, r6, r7, lr}
; CHECK-THUMB2-NEXT: sub sp, #4
; CHECK-THUMB2-NEXT: ldrd r12, r7, [sp, #32]
; CHECK-THUMB2-NEXT: movs r6, #0
; CHECK-THUMB2-NEXT: ldrd lr, r5, [sp, #24]
; CHECK-THUMB2-NEXT: subs.w r4, lr, r12
; CHECK-THUMB2-NEXT: sbcs.w r7, r5, r7
; CHECK-THUMB2-NEXT: it lo
; CHECK-THUMB2-NEXT: movlo r6, #1
; CHECK-THUMB2-NEXT: cmp r6, #0
; CHECK-THUMB2-NEXT: itt eq
; CHECK-THUMB2-NEXT: moveq r0, r2
; CHECK-THUMB2-NEXT: moveq r1, r3
; CHECK-THUMB2-NEXT: add sp, #4
; CHECK-THUMB2-NEXT: pop {r4, r5, r6, r7, pc}
entry:
%cmp = icmp ult i64 %a, %b
%r1 = select i1 %cmp, i64 %c, i64 %d
ret i64 %r1
}
define {i32, i32} @test_slt_not(i32 %c, i32 %d, i64 %a, i64 %b) {
; CHECK-ARM-LABEL: test_slt_not:
; CHECK-ARM: @ %bb.0: @ %entry
; CHECK-ARM-NEXT: ldr r12, [sp]
; CHECK-ARM-NEXT: mov r1, #0
; CHECK-ARM-NEXT: ldr r0, [sp, #4]
; CHECK-ARM-NEXT: subs r2, r2, r12
; CHECK-ARM-NEXT: sbcs r0, r3, r0
; CHECK-ARM-NEXT: mov r0, #0
; CHECK-ARM-NEXT: movwge r1, #1
; CHECK-ARM-NEXT: movwlt r0, #1
; CHECK-ARM-NEXT: bx lr
;
; CHECK-THUMB1-NOMOV-LABEL: test_slt_not:
; CHECK-THUMB1-NOMOV: @ %bb.0: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: .save {r4, r5, r7, lr}
; CHECK-THUMB1-NOMOV-NEXT: push {r4, r5, r7, lr}
; CHECK-THUMB1-NOMOV-NEXT: movs r1, #1
; CHECK-THUMB1-NOMOV-NEXT: movs r4, #0
; CHECK-THUMB1-NOMOV-NEXT: ldr r0, [sp, #20]
; CHECK-THUMB1-NOMOV-NEXT: ldr r5, [sp, #16]
; CHECK-THUMB1-NOMOV-NEXT: subs r2, r2, r5
; CHECK-THUMB1-NOMOV-NEXT: sbcs r3, r0
; CHECK-THUMB1-NOMOV-NEXT: push {r1}
; CHECK-THUMB1-NOMOV-NEXT: pop {r0}
; CHECK-THUMB1-NOMOV-NEXT: blt .LBB3_2
; CHECK-THUMB1-NOMOV-NEXT: @ %bb.1: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: push {r4}
; CHECK-THUMB1-NOMOV-NEXT: pop {r0}
; CHECK-THUMB1-NOMOV-NEXT: .LBB3_2: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: bge .LBB3_4
; CHECK-THUMB1-NOMOV-NEXT: @ %bb.3: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: movs r1, r4
; CHECK-THUMB1-NOMOV-NEXT: .LBB3_4: @ %entry
; CHECK-THUMB1-NOMOV-NEXT: pop {r4, r5, r7}
; CHECK-THUMB1-NOMOV-NEXT: pop {r2}
; CHECK-THUMB1-NOMOV-NEXT: bx r2
;
; CHECK-THUMB1-LABEL: test_slt_not:
; CHECK-THUMB1: @ %bb.0: @ %entry
; CHECK-THUMB1-NEXT: push {r4, r5, r7, lr}
; CHECK-THUMB1-NEXT: movs r1, #1
; CHECK-THUMB1-NEXT: movs r4, #0
; CHECK-THUMB1-NEXT: ldr r0, [sp, #20]
; CHECK-THUMB1-NEXT: ldr r5, [sp, #16]
; CHECK-THUMB1-NEXT: subs r2, r2, r5
; CHECK-THUMB1-NEXT: sbcs r3, r0
; CHECK-THUMB1-NEXT: mov r0, r1
; CHECK-THUMB1-NEXT: bge .LBB3_3
; CHECK-THUMB1-NEXT: @ %bb.1: @ %entry
; CHECK-THUMB1-NEXT: blt .LBB3_4
; CHECK-THUMB1-NEXT: .LBB3_2: @ %entry
; CHECK-THUMB1-NEXT: pop {r4, r5, r7, pc}
; CHECK-THUMB1-NEXT: .LBB3_3: @ %entry
; CHECK-THUMB1-NEXT: mov r0, r4
; CHECK-THUMB1-NEXT: bge .LBB3_2
; CHECK-THUMB1-NEXT: .LBB3_4: @ %entry
; CHECK-THUMB1-NEXT: mov r1, r4
; CHECK-THUMB1-NEXT: pop {r4, r5, r7, pc}
;
; CHECK-THUMB2-LABEL: test_slt_not:
; CHECK-THUMB2: @ %bb.0: @ %entry
; CHECK-THUMB2-NEXT: ldr.w r12, [sp]
; CHECK-THUMB2-NEXT: movs r1, #0
; CHECK-THUMB2-NEXT: ldr r0, [sp, #4]
; CHECK-THUMB2-NEXT: subs.w r2, r2, r12
; CHECK-THUMB2-NEXT: sbcs.w r0, r3, r0
; CHECK-THUMB2-NEXT: mov.w r0, #0
; CHECK-THUMB2-NEXT: ite lt
; CHECK-THUMB2-NEXT: movlt r0, #1
; CHECK-THUMB2-NEXT: movge r1, #1
; CHECK-THUMB2-NEXT: bx lr
entry:
%cmp = icmp slt i64 %a, %b
%not = xor i1 %cmp, true
%r1 = zext i1 %cmp to i32
%r2 = zext i1 %not to i32
%z = insertvalue { i32, i32 } undef, i32 %r1, 0
%z2 = insertvalue { i32, i32 } %z, i32 %r2, 1
ret { i32, i32 } %z2
}