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: div $zero, $5, $4
9 ; MIPS32-NEXT: teq $4, $zero, 7
10 ; MIPS32-NEXT: mflo $1
11 ; MIPS32-NEXT: sll $1, $1, 24
12 ; MIPS32-NEXT: sra $2, $1, 24
20 define signext i16 @sdiv_i16(i16 signext %a, i16 signext %b) {
21 ; MIPS32-LABEL: sdiv_i16:
22 ; MIPS32: # %bb.0: # %entry
23 ; MIPS32-NEXT: div $zero, $5, $4
24 ; MIPS32-NEXT: teq $4, $zero, 7
25 ; MIPS32-NEXT: mflo $1
26 ; MIPS32-NEXT: sll $1, $1, 16
27 ; MIPS32-NEXT: sra $2, $1, 16
31 %div = sdiv i16 %b, %a
35 define signext i32 @sdiv_i32(i32 signext %a, i32 signext %b) {
36 ; MIPS32-LABEL: sdiv_i32:
37 ; MIPS32: # %bb.0: # %entry
38 ; MIPS32-NEXT: div $zero, $5, $4
39 ; MIPS32-NEXT: teq $4, $zero, 7
40 ; MIPS32-NEXT: mflo $2
44 %div = sdiv i32 %b, %a
48 define signext i64 @sdiv_i64(i64 signext %a, i64 signext %b) {
49 ; MIPS32-LABEL: sdiv_i64:
50 ; MIPS32: # %bb.0: # %entry
51 ; MIPS32-NEXT: addiu $sp, $sp, -32
52 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
53 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
54 ; MIPS32-NEXT: .cfi_offset 31, -4
55 ; MIPS32-NEXT: sw $4, 20($sp) # 4-byte Folded Spill
56 ; MIPS32-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
57 ; MIPS32-NEXT: move $4, $6
58 ; MIPS32-NEXT: lw $6, 20($sp) # 4-byte Folded Reload
59 ; MIPS32-NEXT: move $5, $7
60 ; MIPS32-NEXT: lw $7, 24($sp) # 4-byte Folded Reload
61 ; MIPS32-NEXT: jal __divdi3
63 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
64 ; MIPS32-NEXT: addiu $sp, $sp, 32
68 %div = sdiv i64 %b, %a
73 define signext i8 @srem_i8(i8 signext %a, i8 signext %b) {
74 ; MIPS32-LABEL: srem_i8:
75 ; MIPS32: # %bb.0: # %entry
76 ; MIPS32-NEXT: div $zero, $5, $4
77 ; MIPS32-NEXT: teq $4, $zero, 7
78 ; MIPS32-NEXT: mflo $1
79 ; MIPS32-NEXT: sll $1, $1, 24
80 ; MIPS32-NEXT: sra $2, $1, 24
88 define signext i16 @srem_i16(i16 signext %a, i16 signext %b) {
89 ; MIPS32-LABEL: srem_i16:
90 ; MIPS32: # %bb.0: # %entry
91 ; MIPS32-NEXT: div $zero, $5, $4
92 ; MIPS32-NEXT: teq $4, $zero, 7
93 ; MIPS32-NEXT: mfhi $1
94 ; MIPS32-NEXT: sll $1, $1, 16
95 ; MIPS32-NEXT: sra $2, $1, 16
99 %rem = srem i16 %b, %a
103 define signext i32 @srem_i32(i32 signext %a, i32 signext %b) {
104 ; MIPS32-LABEL: srem_i32:
105 ; MIPS32: # %bb.0: # %entry
106 ; MIPS32-NEXT: div $zero, $5, $4
107 ; MIPS32-NEXT: teq $4, $zero, 7
108 ; MIPS32-NEXT: mfhi $2
109 ; MIPS32-NEXT: jr $ra
112 %rem = srem i32 %b, %a
116 define signext i64 @srem_i64(i64 signext %a, i64 signext %b) {
117 ; MIPS32-LABEL: srem_i64:
118 ; MIPS32: # %bb.0: # %entry
119 ; MIPS32-NEXT: addiu $sp, $sp, -32
120 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
121 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
122 ; MIPS32-NEXT: .cfi_offset 31, -4
123 ; MIPS32-NEXT: sw $4, 20($sp) # 4-byte Folded Spill
124 ; MIPS32-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
125 ; MIPS32-NEXT: move $4, $6
126 ; MIPS32-NEXT: lw $6, 20($sp) # 4-byte Folded Reload
127 ; MIPS32-NEXT: move $5, $7
128 ; MIPS32-NEXT: lw $7, 24($sp) # 4-byte Folded Reload
129 ; MIPS32-NEXT: jal __moddi3
131 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
132 ; MIPS32-NEXT: addiu $sp, $sp, 32
133 ; MIPS32-NEXT: jr $ra
136 %rem = srem i64 %b, %a
141 define signext i8 @udiv_i8(i8 signext %a, i8 signext %b) {
142 ; MIPS32-LABEL: udiv_i8:
143 ; MIPS32: # %bb.0: # %entry
144 ; MIPS32-NEXT: andi $2, $5, 255
145 ; MIPS32-NEXT: andi $1, $4, 255
146 ; MIPS32-NEXT: divu $zero, $2, $1
147 ; MIPS32-NEXT: teq $1, $zero, 7
148 ; MIPS32-NEXT: mflo $1
149 ; MIPS32-NEXT: sll $1, $1, 24
150 ; MIPS32-NEXT: sra $2, $1, 24
151 ; MIPS32-NEXT: jr $ra
154 %div = udiv i8 %b, %a
158 define signext i16 @udiv_i16(i16 signext %a, i16 signext %b) {
159 ; MIPS32-LABEL: udiv_i16:
160 ; MIPS32: # %bb.0: # %entry
161 ; MIPS32-NEXT: andi $2, $5, 65535
162 ; MIPS32-NEXT: andi $1, $4, 65535
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, 16
167 ; MIPS32-NEXT: sra $2, $1, 16
168 ; MIPS32-NEXT: jr $ra
171 %div = udiv i16 %b, %a
175 define signext i32 @udiv_i32(i32 signext %a, i32 signext %b) {
176 ; MIPS32-LABEL: udiv_i32:
177 ; MIPS32: # %bb.0: # %entry
178 ; MIPS32-NEXT: divu $zero, $5, $4
179 ; MIPS32-NEXT: teq $4, $zero, 7
180 ; MIPS32-NEXT: mflo $2
181 ; MIPS32-NEXT: jr $ra
184 %div = udiv i32 %b, %a
188 define signext i64 @udiv_i64(i64 signext %a, i64 signext %b) {
189 ; MIPS32-LABEL: udiv_i64:
190 ; MIPS32: # %bb.0: # %entry
191 ; MIPS32-NEXT: addiu $sp, $sp, -32
192 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
193 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
194 ; MIPS32-NEXT: .cfi_offset 31, -4
195 ; MIPS32-NEXT: sw $4, 20($sp) # 4-byte Folded Spill
196 ; MIPS32-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
197 ; MIPS32-NEXT: move $4, $6
198 ; MIPS32-NEXT: lw $6, 20($sp) # 4-byte Folded Reload
199 ; MIPS32-NEXT: move $5, $7
200 ; MIPS32-NEXT: lw $7, 24($sp) # 4-byte Folded Reload
201 ; MIPS32-NEXT: jal __udivdi3
203 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
204 ; MIPS32-NEXT: addiu $sp, $sp, 32
205 ; MIPS32-NEXT: jr $ra
208 %div = udiv i64 %b, %a
213 define signext i8 @urem_i8(i8 signext %a, i8 signext %b) {
214 ; MIPS32-LABEL: urem_i8:
215 ; MIPS32: # %bb.0: # %entry
216 ; MIPS32-NEXT: andi $2, $5, 255
217 ; MIPS32-NEXT: andi $1, $4, 255
218 ; MIPS32-NEXT: divu $zero, $2, $1
219 ; MIPS32-NEXT: teq $1, $zero, 7
220 ; MIPS32-NEXT: mfhi $1
221 ; MIPS32-NEXT: sll $1, $1, 24
222 ; MIPS32-NEXT: sra $2, $1, 24
223 ; MIPS32-NEXT: jr $ra
226 %rem = urem i8 %b, %a
230 define signext i16 @urem_i16(i16 signext %a, i16 signext %b) {
231 ; MIPS32-LABEL: urem_i16:
232 ; MIPS32: # %bb.0: # %entry
233 ; MIPS32-NEXT: andi $2, $5, 65535
234 ; MIPS32-NEXT: andi $1, $4, 65535
235 ; MIPS32-NEXT: divu $zero, $2, $1
236 ; MIPS32-NEXT: teq $1, $zero, 7
237 ; MIPS32-NEXT: mfhi $1
238 ; MIPS32-NEXT: sll $1, $1, 16
239 ; MIPS32-NEXT: sra $2, $1, 16
240 ; MIPS32-NEXT: jr $ra
243 %rem = urem i16 %b, %a
247 define signext i32 @urem_i32(i32 signext %a, i32 signext %b) {
248 ; MIPS32-LABEL: urem_i32:
249 ; MIPS32: # %bb.0: # %entry
250 ; MIPS32-NEXT: divu $zero, $5, $4
251 ; MIPS32-NEXT: teq $4, $zero, 7
252 ; MIPS32-NEXT: mfhi $2
253 ; MIPS32-NEXT: jr $ra
256 %rem = urem i32 %b, %a
260 define signext i64 @urem_i64(i64 signext %a, i64 signext %b) {
261 ; MIPS32-LABEL: urem_i64:
262 ; MIPS32: # %bb.0: # %entry
263 ; MIPS32-NEXT: addiu $sp, $sp, -32
264 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
265 ; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill
266 ; MIPS32-NEXT: .cfi_offset 31, -4
267 ; MIPS32-NEXT: sw $4, 20($sp) # 4-byte Folded Spill
268 ; MIPS32-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
269 ; MIPS32-NEXT: move $4, $6
270 ; MIPS32-NEXT: lw $6, 20($sp) # 4-byte Folded Reload
271 ; MIPS32-NEXT: move $5, $7
272 ; MIPS32-NEXT: lw $7, 24($sp) # 4-byte Folded Reload
273 ; MIPS32-NEXT: jal __umoddi3
275 ; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload
276 ; MIPS32-NEXT: addiu $sp, $sp, 32
277 ; MIPS32-NEXT: jr $ra
280 %rem = urem i64 %b, %a