1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
5 define signext i8 @sdiv_i8(i8 signext %a, i8 signext %b) {
6 ; MIPS32-LABEL: sdiv_i8:
7 ; MIPS32: # %bb.0: # %entry
8 ; MIPS32-NEXT: sll $1, $5, 24
9 ; MIPS32-NEXT: sra $2, $1, 24
10 ; MIPS32-NEXT: sll $1, $4, 24
11 ; MIPS32-NEXT: sra $1, $1, 24
12 ; MIPS32-NEXT: div $zero, $2, $1
13 ; MIPS32-NEXT: teq $1, $zero, 7
14 ; MIPS32-NEXT: mflo $1
15 ; MIPS32-NEXT: sll $1, $1, 24
16 ; MIPS32-NEXT: sra $2, $1, 24
24 define signext i16 @sdiv_i16(i16 signext %a, i16 signext %b) {
25 ; MIPS32-LABEL: sdiv_i16:
26 ; MIPS32: # %bb.0: # %entry
27 ; MIPS32-NEXT: sll $1, $5, 16
28 ; MIPS32-NEXT: sra $2, $1, 16
29 ; MIPS32-NEXT: sll $1, $4, 16
30 ; MIPS32-NEXT: sra $1, $1, 16
31 ; MIPS32-NEXT: div $zero, $2, $1
32 ; MIPS32-NEXT: teq $1, $zero, 7
33 ; MIPS32-NEXT: mflo $1
34 ; MIPS32-NEXT: sll $1, $1, 16
35 ; MIPS32-NEXT: sra $2, $1, 16
39 %div = sdiv i16 %b, %a
43 define signext i32 @sdiv_i32(i32 signext %a, i32 signext %b) {
44 ; MIPS32-LABEL: sdiv_i32:
45 ; MIPS32: # %bb.0: # %entry
46 ; MIPS32-NEXT: div $zero, $5, $4
47 ; MIPS32-NEXT: teq $4, $zero, 7
48 ; MIPS32-NEXT: mflo $2
52 %div = sdiv i32 %b, %a
56 define signext i64 @sdiv_i64(i64 signext %a, i64 signext %b) {
57 ; MIPS32-LABEL: sdiv_i64:
58 ; MIPS32: # %bb.0: # %entry
59 ; MIPS32-NEXT: addiu $sp, $sp, -32
60 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
61 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
62 ; MIPS32-NEXT: .cfi_offset 31, -4
63 ; MIPS32-NEXT: sw $4, 20($sp) # 4-byte Folded Spill
64 ; MIPS32-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
65 ; MIPS32-NEXT: move $4, $6
66 ; MIPS32-NEXT: lw $6, 20($sp) # 4-byte Folded Reload
67 ; MIPS32-NEXT: move $5, $7
68 ; MIPS32-NEXT: lw $7, 24($sp) # 4-byte Folded Reload
69 ; MIPS32-NEXT: jal __divdi3
71 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
72 ; MIPS32-NEXT: addiu $sp, $sp, 32
76 %div = sdiv i64 %b, %a
81 define signext i8 @srem_i8(i8 signext %a, i8 signext %b) {
82 ; MIPS32-LABEL: srem_i8:
83 ; MIPS32: # %bb.0: # %entry
84 ; MIPS32-NEXT: sll $1, $5, 24
85 ; MIPS32-NEXT: sra $2, $1, 24
86 ; MIPS32-NEXT: sll $1, $4, 24
87 ; MIPS32-NEXT: sra $1, $1, 24
88 ; MIPS32-NEXT: div $zero, $2, $1
89 ; MIPS32-NEXT: teq $1, $zero, 7
90 ; MIPS32-NEXT: mflo $1
91 ; MIPS32-NEXT: sll $1, $1, 24
92 ; MIPS32-NEXT: sra $2, $1, 24
100 define signext i16 @srem_i16(i16 signext %a, i16 signext %b) {
101 ; MIPS32-LABEL: srem_i16:
102 ; MIPS32: # %bb.0: # %entry
103 ; MIPS32-NEXT: sll $1, $5, 16
104 ; MIPS32-NEXT: sra $2, $1, 16
105 ; MIPS32-NEXT: sll $1, $4, 16
106 ; MIPS32-NEXT: sra $1, $1, 16
107 ; MIPS32-NEXT: div $zero, $2, $1
108 ; MIPS32-NEXT: teq $1, $zero, 7
109 ; MIPS32-NEXT: mfhi $1
110 ; MIPS32-NEXT: sll $1, $1, 16
111 ; MIPS32-NEXT: sra $2, $1, 16
112 ; MIPS32-NEXT: jr $ra
115 %rem = srem i16 %b, %a
119 define signext i32 @srem_i32(i32 signext %a, i32 signext %b) {
120 ; MIPS32-LABEL: srem_i32:
121 ; MIPS32: # %bb.0: # %entry
122 ; MIPS32-NEXT: div $zero, $5, $4
123 ; MIPS32-NEXT: teq $4, $zero, 7
124 ; MIPS32-NEXT: mfhi $2
125 ; MIPS32-NEXT: jr $ra
128 %rem = srem i32 %b, %a
132 define signext i64 @srem_i64(i64 signext %a, i64 signext %b) {
133 ; MIPS32-LABEL: srem_i64:
134 ; MIPS32: # %bb.0: # %entry
135 ; MIPS32-NEXT: addiu $sp, $sp, -32
136 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
137 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
138 ; MIPS32-NEXT: .cfi_offset 31, -4
139 ; MIPS32-NEXT: sw $4, 20($sp) # 4-byte Folded Spill
140 ; MIPS32-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
141 ; MIPS32-NEXT: move $4, $6
142 ; MIPS32-NEXT: lw $6, 20($sp) # 4-byte Folded Reload
143 ; MIPS32-NEXT: move $5, $7
144 ; MIPS32-NEXT: lw $7, 24($sp) # 4-byte Folded Reload
145 ; MIPS32-NEXT: jal __moddi3
147 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
148 ; MIPS32-NEXT: addiu $sp, $sp, 32
149 ; MIPS32-NEXT: jr $ra
152 %rem = srem i64 %b, %a
157 define signext i8 @udiv_i8(i8 signext %a, i8 signext %b) {
158 ; MIPS32-LABEL: udiv_i8:
159 ; MIPS32: # %bb.0: # %entry
160 ; MIPS32-NEXT: andi $2, $5, 255
161 ; MIPS32-NEXT: andi $1, $4, 255
162 ; MIPS32-NEXT: divu $zero, $2, $1
163 ; MIPS32-NEXT: teq $1, $zero, 7
164 ; MIPS32-NEXT: mflo $1
165 ; MIPS32-NEXT: sll $1, $1, 24
166 ; MIPS32-NEXT: sra $2, $1, 24
167 ; MIPS32-NEXT: jr $ra
170 %div = udiv i8 %b, %a
174 define signext i16 @udiv_i16(i16 signext %a, i16 signext %b) {
175 ; MIPS32-LABEL: udiv_i16:
176 ; MIPS32: # %bb.0: # %entry
177 ; MIPS32-NEXT: andi $2, $5, 65535
178 ; MIPS32-NEXT: andi $1, $4, 65535
179 ; MIPS32-NEXT: divu $zero, $2, $1
180 ; MIPS32-NEXT: teq $1, $zero, 7
181 ; MIPS32-NEXT: mflo $1
182 ; MIPS32-NEXT: sll $1, $1, 16
183 ; MIPS32-NEXT: sra $2, $1, 16
184 ; MIPS32-NEXT: jr $ra
187 %div = udiv i16 %b, %a
191 define signext i32 @udiv_i32(i32 signext %a, i32 signext %b) {
192 ; MIPS32-LABEL: udiv_i32:
193 ; MIPS32: # %bb.0: # %entry
194 ; MIPS32-NEXT: divu $zero, $5, $4
195 ; MIPS32-NEXT: teq $4, $zero, 7
196 ; MIPS32-NEXT: mflo $2
197 ; MIPS32-NEXT: jr $ra
200 %div = udiv i32 %b, %a
204 define signext i64 @udiv_i64(i64 signext %a, i64 signext %b) {
205 ; MIPS32-LABEL: udiv_i64:
206 ; MIPS32: # %bb.0: # %entry
207 ; MIPS32-NEXT: addiu $sp, $sp, -32
208 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
209 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
210 ; MIPS32-NEXT: .cfi_offset 31, -4
211 ; MIPS32-NEXT: sw $4, 20($sp) # 4-byte Folded Spill
212 ; MIPS32-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
213 ; MIPS32-NEXT: move $4, $6
214 ; MIPS32-NEXT: lw $6, 20($sp) # 4-byte Folded Reload
215 ; MIPS32-NEXT: move $5, $7
216 ; MIPS32-NEXT: lw $7, 24($sp) # 4-byte Folded Reload
217 ; MIPS32-NEXT: jal __udivdi3
219 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
220 ; MIPS32-NEXT: addiu $sp, $sp, 32
221 ; MIPS32-NEXT: jr $ra
224 %div = udiv i64 %b, %a
229 define signext i8 @urem_i8(i8 signext %a, i8 signext %b) {
230 ; MIPS32-LABEL: urem_i8:
231 ; MIPS32: # %bb.0: # %entry
232 ; MIPS32-NEXT: andi $2, $5, 255
233 ; MIPS32-NEXT: andi $1, $4, 255
234 ; MIPS32-NEXT: divu $zero, $2, $1
235 ; MIPS32-NEXT: teq $1, $zero, 7
236 ; MIPS32-NEXT: mfhi $1
237 ; MIPS32-NEXT: sll $1, $1, 24
238 ; MIPS32-NEXT: sra $2, $1, 24
239 ; MIPS32-NEXT: jr $ra
242 %rem = urem i8 %b, %a
246 define signext i16 @urem_i16(i16 signext %a, i16 signext %b) {
247 ; MIPS32-LABEL: urem_i16:
248 ; MIPS32: # %bb.0: # %entry
249 ; MIPS32-NEXT: andi $2, $5, 65535
250 ; MIPS32-NEXT: andi $1, $4, 65535
251 ; MIPS32-NEXT: divu $zero, $2, $1
252 ; MIPS32-NEXT: teq $1, $zero, 7
253 ; MIPS32-NEXT: mfhi $1
254 ; MIPS32-NEXT: sll $1, $1, 16
255 ; MIPS32-NEXT: sra $2, $1, 16
256 ; MIPS32-NEXT: jr $ra
259 %rem = urem i16 %b, %a
263 define signext i32 @urem_i32(i32 signext %a, i32 signext %b) {
264 ; MIPS32-LABEL: urem_i32:
265 ; MIPS32: # %bb.0: # %entry
266 ; MIPS32-NEXT: divu $zero, $5, $4
267 ; MIPS32-NEXT: teq $4, $zero, 7
268 ; MIPS32-NEXT: mfhi $2
269 ; MIPS32-NEXT: jr $ra
272 %rem = urem i32 %b, %a
276 define signext i64 @urem_i64(i64 signext %a, i64 signext %b) {
277 ; MIPS32-LABEL: urem_i64:
278 ; MIPS32: # %bb.0: # %entry
279 ; MIPS32-NEXT: addiu $sp, $sp, -32
280 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
281 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
282 ; MIPS32-NEXT: .cfi_offset 31, -4
283 ; MIPS32-NEXT: sw $4, 20($sp) # 4-byte Folded Spill
284 ; MIPS32-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
285 ; MIPS32-NEXT: move $4, $6
286 ; MIPS32-NEXT: lw $6, 20($sp) # 4-byte Folded Reload
287 ; MIPS32-NEXT: move $5, $7
288 ; MIPS32-NEXT: lw $7, 24($sp) # 4-byte Folded Reload
289 ; MIPS32-NEXT: jal __umoddi3
291 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
292 ; MIPS32-NEXT: addiu $sp, $sp, 32
293 ; MIPS32-NEXT: jr $ra
296 %rem = urem i64 %b, %a