1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=m68k-linux -verify-machineinstrs | FileCheck %s
5 define zeroext i16 @test1(i16 zeroext %x) nounwind {
7 ; CHECK: ; %bb.0: ; %entry
8 ; CHECK-NEXT: move.w (6,%sp), %d0
9 ; CHECK-NEXT: mulu #-1985, %d0
10 ; CHECK-NEXT: lsr.l #8, %d0
11 ; CHECK-NEXT: lsr.l #8, %d0
12 ; CHECK-NEXT: lsr.w #5, %d0
13 ; CHECK-NEXT: and.l #65535, %d0
16 %div = udiv i16 %x, 33
20 define zeroext i16 @test2(i8 signext %x, i16 zeroext %c) {
22 ; CHECK: .cfi_startproc
23 ; CHECK-NEXT: ; %bb.0: ; %entry
24 ; CHECK-NEXT: move.w (10,%sp), %d0
25 ; CHECK-NEXT: mulu #-21845, %d0
26 ; CHECK-NEXT: lsr.l #8, %d0
27 ; CHECK-NEXT: lsr.l #8, %d0
28 ; CHECK-NEXT: lsr.w #1, %d0
29 ; CHECK-NEXT: and.l #65535, %d0
36 define zeroext i8 @test3(i8 zeroext %x, i8 zeroext %c) {
38 ; CHECK: .cfi_startproc
39 ; CHECK-NEXT: ; %bb.0: ; %entry
40 ; CHECK-NEXT: move.b (11,%sp), %d0
41 ; CHECK-NEXT: and.l #255, %d0
42 ; CHECK-NEXT: mulu #-21845, %d0
43 ; CHECK-NEXT: lsr.l #8, %d0
44 ; CHECK-NEXT: lsr.l #8, %d0
45 ; CHECK-NEXT: lsr.w #1, %d0
46 ; CHECK-NEXT: and.l #65535, %d0
53 define signext i16 @test4(i16 signext %x) nounwind {
55 ; CHECK: ; %bb.0: ; %entry
56 ; CHECK-NEXT: suba.l #4, %sp
57 ; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill
58 ; CHECK-NEXT: move.w (10,%sp), %d0
59 ; CHECK-NEXT: muls #1986, %d0
60 ; CHECK-NEXT: asr.l #8, %d0
61 ; CHECK-NEXT: asr.l #8, %d0
62 ; CHECK-NEXT: move.w #15, %d1
63 ; CHECK-NEXT: move.w %d0, %d2
64 ; CHECK-NEXT: lsr.w %d1, %d2
65 ; CHECK-NEXT: add.w %d2, %d0
66 ; CHECK-NEXT: ext.l %d0
67 ; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload
68 ; CHECK-NEXT: adda.l #4, %sp
71 %div = sdiv i16 %x, 33 ; <i32> [#uses=1]
75 define i32 @test5(i32 %A) nounwind {
78 ; CHECK-NEXT: suba.l #12, %sp
79 ; CHECK-NEXT: move.l #1577682821, (4,%sp)
80 ; CHECK-NEXT: move.l (16,%sp), (%sp)
81 ; CHECK-NEXT: jsr __udivsi3@PLT
82 ; CHECK-NEXT: adda.l #12, %sp
84 %tmp1 = udiv i32 %A, 1577682821 ; <i32> [#uses=1]
89 define signext i16 @test6(i16 signext %x) nounwind {
91 ; CHECK: ; %bb.0: ; %entry
92 ; CHECK-NEXT: suba.l #4, %sp
93 ; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill
94 ; CHECK-NEXT: move.w (10,%sp), %d0
95 ; CHECK-NEXT: muls #26215, %d0
96 ; CHECK-NEXT: asr.l #8, %d0
97 ; CHECK-NEXT: asr.l #8, %d0
98 ; CHECK-NEXT: move.w #15, %d1
99 ; CHECK-NEXT: move.w %d0, %d2
100 ; CHECK-NEXT: lsr.w %d1, %d2
101 ; CHECK-NEXT: asr.w #2, %d0
102 ; CHECK-NEXT: add.w %d2, %d0
103 ; CHECK-NEXT: ext.l %d0
104 ; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload
105 ; CHECK-NEXT: adda.l #4, %sp
108 %div = sdiv i16 %x, 10
112 define i32 @test7(i32 %x) nounwind {
113 ; CHECK-LABEL: test7:
115 ; CHECK-NEXT: suba.l #12, %sp
116 ; CHECK-NEXT: move.l #28, (4,%sp)
117 ; CHECK-NEXT: move.l (16,%sp), (%sp)
118 ; CHECK-NEXT: jsr __udivsi3@PLT
119 ; CHECK-NEXT: adda.l #12, %sp
121 %div = udiv i32 %x, 28
125 define i8 @test8(i8 %x) nounwind {
126 ; CHECK-LABEL: test8:
128 ; CHECK-NEXT: move.b (7,%sp), %d0
129 ; CHECK-NEXT: and.l #255, %d0
130 ; CHECK-NEXT: lsr.w #1, %d0
131 ; CHECK-NEXT: mulu #26887, %d0
132 ; CHECK-NEXT: lsr.l #8, %d0
133 ; CHECK-NEXT: lsr.l #8, %d0
134 ; CHECK-NEXT: lsr.w #4, %d0
135 ; CHECK-NEXT: ; kill: def $bd0 killed $bd0 killed $d0
137 %div = udiv i8 %x, 78
141 define i8 @test9(i8 %x) nounwind {
142 ; CHECK-LABEL: test9:
144 ; CHECK-NEXT: move.b (7,%sp), %d0
145 ; CHECK-NEXT: and.l #255, %d0
146 ; CHECK-NEXT: mulu #18079, %d0
147 ; CHECK-NEXT: lsr.l #8, %d0
148 ; CHECK-NEXT: lsr.l #8, %d0
149 ; CHECK-NEXT: lsr.w #5, %d0
150 ; CHECK-NEXT: ; kill: def $bd0 killed $bd0 killed $d0
152 %div = udiv i8 %x, 116
156 define i32 @testsize1(i32 %x) minsize nounwind {
157 ; CHECK-LABEL: testsize1:
158 ; CHECK: ; %bb.0: ; %entry
159 ; CHECK-NEXT: suba.l #4, %sp
160 ; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill
161 ; CHECK-NEXT: move.l #31, %d1
162 ; CHECK-NEXT: move.l (8,%sp), %d0
163 ; CHECK-NEXT: move.l %d0, %d2
164 ; CHECK-NEXT: asr.l %d1, %d2
165 ; CHECK-NEXT: move.l #27, %d1
166 ; CHECK-NEXT: lsr.l %d1, %d2
167 ; CHECK-NEXT: add.l %d2, %d0
168 ; CHECK-NEXT: asr.l #5, %d0
169 ; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload
170 ; CHECK-NEXT: adda.l #4, %sp
173 %div = sdiv i32 %x, 32
177 define i32 @testsize2(i32 %x) minsize nounwind {
178 ; CHECK-LABEL: testsize2:
179 ; CHECK: ; %bb.0: ; %entry
180 ; CHECK-NEXT: suba.l #12, %sp
181 ; CHECK-NEXT: move.l #33, (4,%sp)
182 ; CHECK-NEXT: move.l (16,%sp), (%sp)
183 ; CHECK-NEXT: jsr __divsi3@PLT
184 ; CHECK-NEXT: adda.l #12, %sp
187 %div = sdiv i32 %x, 33
191 define i32 @testsize3(i32 %x) minsize nounwind {
192 ; CHECK-LABEL: testsize3:
193 ; CHECK: ; %bb.0: ; %entry
194 ; CHECK-NEXT: move.l (4,%sp), %d0
195 ; CHECK-NEXT: lsr.l #5, %d0
198 %div = udiv i32 %x, 32
202 define i32 @testsize4(i32 %x) minsize nounwind {
203 ; CHECK-LABEL: testsize4:
204 ; CHECK: ; %bb.0: ; %entry
205 ; CHECK-NEXT: suba.l #12, %sp
206 ; CHECK-NEXT: move.l #33, (4,%sp)
207 ; CHECK-NEXT: move.l (16,%sp), (%sp)
208 ; CHECK-NEXT: jsr __udivsi3@PLT
209 ; CHECK-NEXT: adda.l #12, %sp
212 %div = udiv i32 %x, 33