1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=m68k-linux-gnu -verify-machineinstrs | FileCheck %s
4 define i32 @test1(i32* %y) nounwind {
7 ; CHECK-NEXT: move.l (4,%sp), %a0
8 ; CHECK-NEXT: cmpi.l #0, (%a0)
9 ; CHECK-NEXT: beq .LBB0_2
10 ; CHECK-NEXT: ; %bb.1: ; %cond_false
11 ; CHECK-NEXT: move.l #0, %d0
13 ; CHECK-NEXT: .LBB0_2: ; %cond_true
14 ; CHECK-NEXT: move.l #1, %d0
16 %tmp = load i32, i32* %y ; <i32> [#uses=1]
17 %tmp.upgrd.1 = icmp eq i32 %tmp, 0 ; <i1> [#uses=1]
18 br i1 %tmp.upgrd.1, label %cond_true, label %cond_false
20 cond_false: ; preds = %0
23 cond_true: ; preds = %0
27 define i32 @test2(i32* %y) nounwind {
30 ; CHECK-NEXT: move.l (4,%sp), %a0
31 ; CHECK-NEXT: move.l (%a0), %d0
32 ; CHECK-NEXT: and.l #536870911, %d0
33 ; CHECK-NEXT: cmpi.l #0, %d0
34 ; CHECK-NEXT: beq .LBB1_2
35 ; CHECK-NEXT: ; %bb.1: ; %cond_false
36 ; CHECK-NEXT: move.l #0, %d0
38 ; CHECK-NEXT: .LBB1_2: ; %cond_true
39 ; CHECK-NEXT: move.l #1, %d0
41 %tmp = load i32, i32* %y ; <i32> [#uses=1]
42 %tmp1 = shl i32 %tmp, 3 ; <i32> [#uses=1]
43 %tmp1.upgrd.2 = icmp eq i32 %tmp1, 0 ; <i1> [#uses=1]
44 br i1 %tmp1.upgrd.2, label %cond_true, label %cond_false
46 cond_false: ; preds = %0
49 cond_true: ; preds = %0
53 define i8 @test2b(i8* %y) nounwind {
54 ; CHECK-LABEL: test2b:
56 ; CHECK-NEXT: move.l (4,%sp), %a0
57 ; CHECK-NEXT: move.b (%a0), %d0
58 ; CHECK-NEXT: and.b #31, %d0
59 ; CHECK-NEXT: cmpi.b #0, %d0
60 ; CHECK-NEXT: beq .LBB2_2
61 ; CHECK-NEXT: ; %bb.1: ; %cond_false
62 ; CHECK-NEXT: move.b #0, %d0
64 ; CHECK-NEXT: .LBB2_2: ; %cond_true
65 ; CHECK-NEXT: move.b #1, %d0
67 %tmp = load i8, i8* %y ; <i8> [#uses=1]
68 %tmp1 = shl i8 %tmp, 3 ; <i8> [#uses=1]
69 %tmp1.upgrd.2 = icmp eq i8 %tmp1, 0 ; <i1> [#uses=1]
70 br i1 %tmp1.upgrd.2, label %cond_true, label %cond_false
72 cond_false: ; preds = %0
75 cond_true: ; preds = %0
79 define i64 @test3(i64 %x) nounwind {
82 ; CHECK-NEXT: move.l (8,%sp), %d0
83 ; CHECK-NEXT: or.l (4,%sp), %d0
85 ; CHECK-NEXT: move.l %d0, %d1
86 ; CHECK-NEXT: and.l #255, %d1
87 ; CHECK-NEXT: move.l #0, %d0
89 %t = icmp eq i64 %x, 0
90 %r = zext i1 %t to i64
94 define i64 @test4(i64 %x) nounwind {
97 ; CHECK-NEXT: suba.l #4, %sp
98 ; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill
99 ; CHECK-NEXT: move.l (8,%sp), %d1
100 ; CHECK-NEXT: move.l #0, %d0
101 ; CHECK-NEXT: move.l (12,%sp), %d2
102 ; CHECK-NEXT: sub.l #1, %d2
103 ; CHECK-NEXT: subx.l %d0, %d1
104 ; CHECK-NEXT: slt %d1
105 ; CHECK-NEXT: and.l #255, %d1
106 ; CHECK-NEXT: and.l #1, %d1
107 ; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload
108 ; CHECK-NEXT: adda.l #4, %sp
110 %t = icmp slt i64 %x, 1
111 %r = zext i1 %t to i64
115 define i32 @test6() nounwind align 2 {
116 ; CHECK-LABEL: test6:
118 ; CHECK-NEXT: suba.l #20, %sp
119 ; CHECK-NEXT: move.l (12,%sp), %d0
120 ; CHECK-NEXT: or.l (8,%sp), %d0
121 ; CHECK-NEXT: beq .LBB5_1
122 ; CHECK-NEXT: ; %bb.2: ; %F
123 ; CHECK-NEXT: move.l #0, %d0
124 ; CHECK-NEXT: adda.l #20, %sp
126 ; CHECK-NEXT: .LBB5_1: ; %T
127 ; CHECK-NEXT: move.l #1, %d0
128 ; CHECK-NEXT: adda.l #20, %sp
130 %A = alloca {i64, i64}, align 8
131 %B = getelementptr inbounds {i64, i64}, {i64, i64}* %A, i64 0, i32 1
132 %C = load i64, i64* %B
133 %D = icmp eq i64 %C, 0
134 br i1 %D, label %T, label %F
142 define i32 @test7(i64 %res) nounwind {
143 ; CHECK-LABEL: test7:
144 ; CHECK: ; %bb.0: ; %entry
145 ; CHECK-NEXT: cmpi.l #0, (4,%sp)
146 ; CHECK-NEXT: seq %d0
147 ; CHECK-NEXT: and.l #255, %d0
150 %lnot = icmp ult i64 %res, 4294967296
151 %lnot.ext = zext i1 %lnot to i32
155 define i32 @test8(i64 %res) nounwind {
156 ; CHECK-LABEL: test8:
157 ; CHECK: ; %bb.0: ; %entry
158 ; CHECK-NEXT: move.l (4,%sp), %d0
159 ; CHECK-NEXT: sub.l #3, %d0
160 ; CHECK-NEXT: scs %d0
161 ; CHECK-NEXT: and.l #255, %d0
164 %lnot = icmp ult i64 %res, 12884901888
165 %lnot.ext = zext i1 %lnot to i32
169 define i32 @test11(i64 %l) nounwind {
170 ; CHECK-LABEL: test11:
171 ; CHECK: ; %bb.0: ; %entry
172 ; CHECK-NEXT: move.l (4,%sp), %d0
173 ; CHECK-NEXT: and.l #-32768, %d0
174 ; CHECK-NEXT: eori.l #32768, %d0
175 ; CHECK-NEXT: seq %d0
176 ; CHECK-NEXT: and.l #255, %d0
179 %shr.mask = and i64 %l, -140737488355328
180 %cmp = icmp eq i64 %shr.mask, 140737488355328
181 %conv = zext i1 %cmp to i32
185 define i32 @test13(i32 %mask, i32 %base, i32 %intra) {
186 ; CHECK-LABEL: test13:
187 ; CHECK: .cfi_startproc
188 ; CHECK-NEXT: ; %bb.0:
189 ; CHECK-NEXT: move.b (7,%sp), %d0
190 ; CHECK-NEXT: and.b #8, %d0
191 ; CHECK-NEXT: cmpi.b #0, %d0
192 ; CHECK-NEXT: bne .LBB9_1
193 ; CHECK-NEXT: ; %bb.2:
194 ; CHECK-NEXT: lea (8,%sp), %a0
195 ; CHECK-NEXT: move.l (%a0), %d0
197 ; CHECK-NEXT: .LBB9_1:
198 ; CHECK-NEXT: lea (12,%sp), %a0
199 ; CHECK-NEXT: move.l (%a0), %d0
201 %and = and i32 %mask, 8
202 %tobool = icmp ne i32 %and, 0
203 %cond = select i1 %tobool, i32 %intra, i32 %base
207 define i32 @test14(i32 %mask, i32 %base, i32 %intra) #0 {
208 ; CHECK-LABEL: test14:
209 ; CHECK: .cfi_startproc
210 ; CHECK-NEXT: ; %bb.0:
211 ; CHECK-NEXT: move.l (4,%sp), %d0
212 ; CHECK-NEXT: lsr.l #7, %d0
213 ; CHECK-NEXT: cmpi.l #0, %d0
214 ; CHECK-NEXT: bpl .LBB10_1
215 ; CHECK-NEXT: ; %bb.2:
216 ; CHECK-NEXT: lea (8,%sp), %a0
217 ; CHECK-NEXT: move.l (%a0), %d0
219 ; CHECK-NEXT: .LBB10_1:
220 ; CHECK-NEXT: lea (12,%sp), %a0
221 ; CHECK-NEXT: move.l (%a0), %d0
223 %s = lshr i32 %mask, 7
224 %tobool = icmp sgt i32 %s, -1
225 %cond = select i1 %tobool, i32 %intra, i32 %base
229 define zeroext i1 @test15(i32 %bf.load, i32 %n) {
230 ; CHECK-LABEL: test15:
231 ; CHECK: .cfi_startproc
232 ; CHECK-NEXT: ; %bb.0:
233 ; CHECK-NEXT: move.l #16, %d0
234 ; CHECK-NEXT: move.l (4,%sp), %d1
235 ; CHECK-NEXT: lsr.l %d0, %d1
236 ; CHECK-NEXT: move.l %d1, %d0
237 ; CHECK-NEXT: sub.l (8,%sp), %d0
238 ; CHECK-NEXT: scc %d0
239 ; CHECK-NEXT: cmpi.l #0, %d1
240 ; CHECK-NEXT: seq %d1
241 ; CHECK-NEXT: or.b %d0, %d1
242 ; CHECK-NEXT: move.l %d1, %d0
243 ; CHECK-NEXT: and.l #255, %d0
245 %bf.lshr = lshr i32 %bf.load, 16
246 %cmp2 = icmp eq i32 %bf.lshr, 0
247 %cmp5 = icmp uge i32 %bf.lshr, %n
248 %.cmp5 = or i1 %cmp2, %cmp5
252 define i8 @test16(i16 signext %L) {
253 ; CHECK-LABEL: test16:
254 ; CHECK: .cfi_startproc
255 ; CHECK-NEXT: ; %bb.0:
256 ; CHECK-NEXT: move.w #15, %d1
257 ; CHECK-NEXT: move.w (6,%sp), %d0
258 ; CHECK-NEXT: lsr.w %d1, %d0
259 ; CHECK-NEXT: eori.b #1, %d0
260 ; CHECK-NEXT: ; kill: def $bd0 killed $bd0 killed $wd0
262 %lshr = lshr i16 %L, 15
263 %trunc = trunc i16 %lshr to i8
264 %not = xor i8 %trunc, 1
268 define i8 @test18(i64 %L) {
269 ; CHECK-LABEL: test18:
270 ; CHECK: .cfi_startproc
271 ; CHECK-NEXT: ; %bb.0:
272 ; CHECK-NEXT: move.l #31, %d1
273 ; CHECK-NEXT: move.l (4,%sp), %d0
274 ; CHECK-NEXT: lsr.l %d1, %d0
275 ; CHECK-NEXT: eori.b #1, %d0
276 ; CHECK-NEXT: ; kill: def $bd0 killed $bd0 killed $d0
278 %lshr = lshr i64 %L, 63
279 %trunc = trunc i64 %lshr to i8
280 %not = xor i8 %trunc, 1
284 @d = global i8 0, align 1
286 define void @test20(i32 %bf.load, i8 %x1, i8* %b_addr) {
287 ; CHECK-LABEL: test20:
288 ; CHECK: .cfi_startproc
289 ; CHECK-NEXT: ; %bb.0:
290 ; CHECK-NEXT: suba.l #4, %sp
291 ; CHECK-NEXT: .cfi_def_cfa_offset -8
292 ; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill
293 ; CHECK-NEXT: move.l #16777215, %d0
294 ; CHECK-NEXT: and.l (8,%sp), %d0
295 ; CHECK-NEXT: sne %d1
296 ; CHECK-NEXT: and.l #255, %d1
297 ; CHECK-NEXT: move.l (16,%sp), %a0
298 ; CHECK-NEXT: move.b (15,%sp), %d2
299 ; CHECK-NEXT: and.l #255, %d2
300 ; CHECK-NEXT: add.l %d2, %d1
301 ; CHECK-NEXT: sne (%a0)
302 ; CHECK-NEXT: cmpi.l #0, %d0
303 ; CHECK-NEXT: lea (d,%pc), %a0
304 ; CHECK-NEXT: sne (%a0)
305 ; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload
306 ; CHECK-NEXT: adda.l #4, %sp
308 %bf.shl = shl i32 %bf.load, 8
309 %bf.ashr = ashr exact i32 %bf.shl, 8
310 %tobool4 = icmp ne i32 %bf.ashr, 0
311 %conv = zext i1 %tobool4 to i32
312 %conv6 = zext i8 %x1 to i32
313 %add = add nuw nsw i32 %conv, %conv6
314 %tobool7 = icmp ne i32 %add, 0
315 %frombool = zext i1 %tobool7 to i8
316 store i8 %frombool, i8* %b_addr, align 1
317 %tobool14 = icmp ne i32 %bf.shl, 0
318 %frombool15 = zext i1 %tobool14 to i8
319 store i8 %frombool15, i8* @d, align 1