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 $1, $1, 24
10 ; MIPS32-NEXT: sll $2, $4, 24
11 ; MIPS32-NEXT: sra $2, $2, 24
12 ; MIPS32-NEXT: div $zero, $1, $2
13 ; MIPS32-NEXT: teq $2, $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 $1, $1, 16
29 ; MIPS32-NEXT: sll $2, $4, 16
30 ; MIPS32-NEXT: sra $2, $2, 16
31 ; MIPS32-NEXT: div $zero, $1, $2
32 ; MIPS32-NEXT: teq $2, $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, 24($sp) # 4-byte Folded Spill
64 ; MIPS32-NEXT: move $4, $6
65 ; MIPS32-NEXT: sw $5, 20($sp) # 4-byte Folded Spill
66 ; MIPS32-NEXT: move $5, $7
67 ; MIPS32-NEXT: lw $6, 24($sp) # 4-byte Folded Reload
68 ; MIPS32-NEXT: lw $7, 20($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 $1, $1, 24
86 ; MIPS32-NEXT: sll $2, $4, 24
87 ; MIPS32-NEXT: sra $2, $2, 24
88 ; MIPS32-NEXT: div $zero, $1, $2
89 ; MIPS32-NEXT: teq $2, $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 $1, $1, 16
105 ; MIPS32-NEXT: sll $2, $4, 16
106 ; MIPS32-NEXT: sra $2, $2, 16
107 ; MIPS32-NEXT: div $zero, $1, $2
108 ; MIPS32-NEXT: teq $2, $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, 24($sp) # 4-byte Folded Spill
140 ; MIPS32-NEXT: move $4, $6
141 ; MIPS32-NEXT: sw $5, 20($sp) # 4-byte Folded Spill
142 ; MIPS32-NEXT: move $5, $7
143 ; MIPS32-NEXT: lw $6, 24($sp) # 4-byte Folded Reload
144 ; MIPS32-NEXT: lw $7, 20($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: ori $1, $zero, 255
161 ; MIPS32-NEXT: and $2, $5, $1
162 ; MIPS32-NEXT: and $1, $4, $1
163 ; MIPS32-NEXT: divu $zero, $2, $1
164 ; MIPS32-NEXT: teq $1, $zero, 7
165 ; MIPS32-NEXT: mflo $1
166 ; MIPS32-NEXT: sll $1, $1, 24
167 ; MIPS32-NEXT: sra $2, $1, 24
168 ; MIPS32-NEXT: jr $ra
171 %div = udiv i8 %b, %a
175 define signext i16 @udiv_i16(i16 signext %a, i16 signext %b) {
176 ; MIPS32-LABEL: udiv_i16:
177 ; MIPS32: # %bb.0: # %entry
178 ; MIPS32-NEXT: ori $1, $zero, 65535
179 ; MIPS32-NEXT: and $2, $5, $1
180 ; MIPS32-NEXT: and $1, $4, $1
181 ; MIPS32-NEXT: divu $zero, $2, $1
182 ; MIPS32-NEXT: teq $1, $zero, 7
183 ; MIPS32-NEXT: mflo $1
184 ; MIPS32-NEXT: sll $1, $1, 16
185 ; MIPS32-NEXT: sra $2, $1, 16
186 ; MIPS32-NEXT: jr $ra
189 %div = udiv i16 %b, %a
193 define signext i32 @udiv_i32(i32 signext %a, i32 signext %b) {
194 ; MIPS32-LABEL: udiv_i32:
195 ; MIPS32: # %bb.0: # %entry
196 ; MIPS32-NEXT: divu $zero, $5, $4
197 ; MIPS32-NEXT: teq $4, $zero, 7
198 ; MIPS32-NEXT: mflo $2
199 ; MIPS32-NEXT: jr $ra
202 %div = udiv i32 %b, %a
206 define signext i64 @udiv_i64(i64 signext %a, i64 signext %b) {
207 ; MIPS32-LABEL: udiv_i64:
208 ; MIPS32: # %bb.0: # %entry
209 ; MIPS32-NEXT: addiu $sp, $sp, -32
210 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
211 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
212 ; MIPS32-NEXT: .cfi_offset 31, -4
213 ; MIPS32-NEXT: sw $4, 24($sp) # 4-byte Folded Spill
214 ; MIPS32-NEXT: move $4, $6
215 ; MIPS32-NEXT: sw $5, 20($sp) # 4-byte Folded Spill
216 ; MIPS32-NEXT: move $5, $7
217 ; MIPS32-NEXT: lw $6, 24($sp) # 4-byte Folded Reload
218 ; MIPS32-NEXT: lw $7, 20($sp) # 4-byte Folded Reload
219 ; MIPS32-NEXT: jal __udivdi3
221 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
222 ; MIPS32-NEXT: addiu $sp, $sp, 32
223 ; MIPS32-NEXT: jr $ra
226 %div = udiv i64 %b, %a
231 define signext i8 @urem_i8(i8 signext %a, i8 signext %b) {
232 ; MIPS32-LABEL: urem_i8:
233 ; MIPS32: # %bb.0: # %entry
234 ; MIPS32-NEXT: ori $1, $zero, 255
235 ; MIPS32-NEXT: and $2, $5, $1
236 ; MIPS32-NEXT: and $1, $4, $1
237 ; MIPS32-NEXT: divu $zero, $2, $1
238 ; MIPS32-NEXT: teq $1, $zero, 7
239 ; MIPS32-NEXT: mfhi $1
240 ; MIPS32-NEXT: sll $1, $1, 24
241 ; MIPS32-NEXT: sra $2, $1, 24
242 ; MIPS32-NEXT: jr $ra
245 %rem = urem i8 %b, %a
249 define signext i16 @urem_i16(i16 signext %a, i16 signext %b) {
250 ; MIPS32-LABEL: urem_i16:
251 ; MIPS32: # %bb.0: # %entry
252 ; MIPS32-NEXT: ori $1, $zero, 65535
253 ; MIPS32-NEXT: and $2, $5, $1
254 ; MIPS32-NEXT: and $1, $4, $1
255 ; MIPS32-NEXT: divu $zero, $2, $1
256 ; MIPS32-NEXT: teq $1, $zero, 7
257 ; MIPS32-NEXT: mfhi $1
258 ; MIPS32-NEXT: sll $1, $1, 16
259 ; MIPS32-NEXT: sra $2, $1, 16
260 ; MIPS32-NEXT: jr $ra
263 %rem = urem i16 %b, %a
267 define signext i32 @urem_i32(i32 signext %a, i32 signext %b) {
268 ; MIPS32-LABEL: urem_i32:
269 ; MIPS32: # %bb.0: # %entry
270 ; MIPS32-NEXT: divu $zero, $5, $4
271 ; MIPS32-NEXT: teq $4, $zero, 7
272 ; MIPS32-NEXT: mfhi $2
273 ; MIPS32-NEXT: jr $ra
276 %rem = urem i32 %b, %a
280 define signext i64 @urem_i64(i64 signext %a, i64 signext %b) {
281 ; MIPS32-LABEL: urem_i64:
282 ; MIPS32: # %bb.0: # %entry
283 ; MIPS32-NEXT: addiu $sp, $sp, -32
284 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
285 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
286 ; MIPS32-NEXT: .cfi_offset 31, -4
287 ; MIPS32-NEXT: sw $4, 24($sp) # 4-byte Folded Spill
288 ; MIPS32-NEXT: move $4, $6
289 ; MIPS32-NEXT: sw $5, 20($sp) # 4-byte Folded Spill
290 ; MIPS32-NEXT: move $5, $7
291 ; MIPS32-NEXT: lw $6, 24($sp) # 4-byte Folded Reload
292 ; MIPS32-NEXT: lw $7, 20($sp) # 4-byte Folded Reload
293 ; MIPS32-NEXT: jal __umoddi3
295 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
296 ; MIPS32-NEXT: addiu $sp, $sp, 32
297 ; MIPS32-NEXT: jr $ra
300 %rem = urem i64 %b, %a