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: muls #171, %d0
43 ; CHECK-NEXT: moveq #9, %d1
44 ; CHECK-NEXT: lsr.w %d1, %d0
45 ; CHECK-NEXT: and.l #65535, %d0
52 define signext i16 @test4(i16 signext %x) nounwind {
54 ; CHECK: ; %bb.0: ; %entry
55 ; CHECK-NEXT: suba.l #4, %sp
56 ; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill
57 ; CHECK-NEXT: move.w (10,%sp), %d0
58 ; CHECK-NEXT: muls #1986, %d0
59 ; CHECK-NEXT: asr.l #8, %d0
60 ; CHECK-NEXT: asr.l #8, %d0
61 ; CHECK-NEXT: moveq #15, %d1
62 ; CHECK-NEXT: move.w %d0, %d2
63 ; CHECK-NEXT: lsr.w %d1, %d2
64 ; CHECK-NEXT: add.w %d2, %d0
65 ; CHECK-NEXT: ext.l %d0
66 ; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload
67 ; CHECK-NEXT: adda.l #4, %sp
70 %div = sdiv i16 %x, 33 ; <i32> [#uses=1]
74 define i32 @test5(i32 %A) nounwind {
77 ; CHECK-NEXT: suba.l #12, %sp
78 ; CHECK-NEXT: move.l #1577682821, (4,%sp)
79 ; CHECK-NEXT: move.l (16,%sp), (%sp)
80 ; CHECK-NEXT: jsr __udivsi3
81 ; CHECK-NEXT: adda.l #12, %sp
83 %tmp1 = udiv i32 %A, 1577682821 ; <i32> [#uses=1]
88 define signext i16 @test6(i16 signext %x) nounwind {
90 ; CHECK: ; %bb.0: ; %entry
91 ; CHECK-NEXT: suba.l #4, %sp
92 ; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill
93 ; CHECK-NEXT: move.w (10,%sp), %d0
94 ; CHECK-NEXT: muls #26215, %d0
95 ; CHECK-NEXT: asr.l #8, %d0
96 ; CHECK-NEXT: asr.l #8, %d0
97 ; CHECK-NEXT: moveq #15, %d1
98 ; CHECK-NEXT: move.w %d0, %d2
99 ; CHECK-NEXT: lsr.w %d1, %d2
100 ; CHECK-NEXT: asr.w #2, %d0
101 ; CHECK-NEXT: add.w %d2, %d0
102 ; CHECK-NEXT: ext.l %d0
103 ; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload
104 ; CHECK-NEXT: adda.l #4, %sp
107 %div = sdiv i16 %x, 10
111 define i32 @test7(i32 %x) nounwind {
112 ; CHECK-LABEL: test7:
114 ; CHECK-NEXT: suba.l #12, %sp
115 ; CHECK-NEXT: move.l #28, (4,%sp)
116 ; CHECK-NEXT: move.l (16,%sp), (%sp)
117 ; CHECK-NEXT: jsr __udivsi3
118 ; CHECK-NEXT: adda.l #12, %sp
120 %div = udiv i32 %x, 28
124 define i8 @test8(i8 %x) nounwind {
125 ; CHECK-LABEL: test8:
127 ; CHECK-NEXT: move.b (7,%sp), %d0
128 ; CHECK-NEXT: lsr.b #1, %d0
129 ; CHECK-NEXT: and.l #255, %d0
130 ; CHECK-NEXT: muls #211, %d0
131 ; CHECK-NEXT: moveq #13, %d1
132 ; CHECK-NEXT: lsr.w %d1, %d0
133 ; CHECK-NEXT: ; kill: def $bd0 killed $bd0 killed $d0
135 %div = udiv i8 %x, 78
139 define i8 @test9(i8 %x) nounwind {
140 ; CHECK-LABEL: test9:
142 ; CHECK-NEXT: move.b (7,%sp), %d0
143 ; CHECK-NEXT: lsr.b #2, %d0
144 ; CHECK-NEXT: and.l #255, %d0
145 ; CHECK-NEXT: muls #71, %d0
146 ; CHECK-NEXT: moveq #11, %d1
147 ; CHECK-NEXT: lsr.w %d1, %d0
148 ; CHECK-NEXT: ; kill: def $bd0 killed $bd0 killed $d0
150 %div = udiv i8 %x, 116
154 define i32 @testsize1(i32 %x) minsize nounwind {
155 ; CHECK-LABEL: testsize1:
156 ; CHECK: ; %bb.0: ; %entry
157 ; CHECK-NEXT: suba.l #4, %sp
158 ; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill
159 ; CHECK-NEXT: moveq #31, %d1
160 ; CHECK-NEXT: move.l (8,%sp), %d0
161 ; CHECK-NEXT: move.l %d0, %d2
162 ; CHECK-NEXT: asr.l %d1, %d2
163 ; CHECK-NEXT: moveq #27, %d1
164 ; CHECK-NEXT: lsr.l %d1, %d2
165 ; CHECK-NEXT: add.l %d2, %d0
166 ; CHECK-NEXT: asr.l #5, %d0
167 ; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload
168 ; CHECK-NEXT: adda.l #4, %sp
171 %div = sdiv i32 %x, 32
175 define i32 @testsize2(i32 %x) minsize nounwind {
176 ; CHECK-LABEL: testsize2:
177 ; CHECK: ; %bb.0: ; %entry
178 ; CHECK-NEXT: suba.l #12, %sp
179 ; CHECK-NEXT: move.l #33, (4,%sp)
180 ; CHECK-NEXT: move.l (16,%sp), (%sp)
181 ; CHECK-NEXT: jsr __divsi3
182 ; CHECK-NEXT: adda.l #12, %sp
185 %div = sdiv i32 %x, 33
189 define i32 @testsize3(i32 %x) minsize nounwind {
190 ; CHECK-LABEL: testsize3:
191 ; CHECK: ; %bb.0: ; %entry
192 ; CHECK-NEXT: move.l (4,%sp), %d0
193 ; CHECK-NEXT: lsr.l #5, %d0
196 %div = udiv i32 %x, 32
200 define i32 @testsize4(i32 %x) minsize nounwind {
201 ; CHECK-LABEL: testsize4:
202 ; CHECK: ; %bb.0: ; %entry
203 ; CHECK-NEXT: suba.l #12, %sp
204 ; CHECK-NEXT: move.l #33, (4,%sp)
205 ; CHECK-NEXT: move.l (16,%sp), (%sp)
206 ; CHECK-NEXT: jsr __udivsi3
207 ; CHECK-NEXT: adda.l #12, %sp
210 %div = udiv i32 %x, 33