1 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
2 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -relocation-model=pic -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32_PIC
4 define i32 @mod4_0_to_11(i32 %a) {
5 ; MIPS32-LABEL: mod4_0_to_11:
6 ; MIPS32: # %bb.0: # %entry
7 ; MIPS32-NEXT: addiu $sp, $sp, -32
8 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
9 ; MIPS32-NEXT: ori $1, $zero, 7
10 ; MIPS32-NEXT: ori $2, $zero, 3
11 ; MIPS32-NEXT: ori $3, $zero, 2
12 ; MIPS32-NEXT: ori $5, $zero, 1
13 ; MIPS32-NEXT: ori $6, $zero, 0
14 ; MIPS32-NEXT: addiu $7, $zero, 65535
15 ; MIPS32-NEXT: ori $8, $zero, 0
16 ; MIPS32-NEXT: subu $8, $4, $8
17 ; MIPS32-NEXT: sltu $1, $1, $8
18 ; MIPS32-NEXT: and $1, $1, $5
19 ; MIPS32-NEXT: sw $4, 28($sp) # 4-byte Folded Spill
20 ; MIPS32-NEXT: sw $2, 24($sp) # 4-byte Folded Spill
21 ; MIPS32-NEXT: sw $3, 20($sp) # 4-byte Folded Spill
22 ; MIPS32-NEXT: sw $5, 16($sp) # 4-byte Folded Spill
23 ; MIPS32-NEXT: sw $6, 12($sp) # 4-byte Folded Spill
24 ; MIPS32-NEXT: sw $7, 8($sp) # 4-byte Folded Spill
25 ; MIPS32-NEXT: sw $8, 4($sp) # 4-byte Folded Spill
26 ; MIPS32-NEXT: bnez $1, $BB0_6
28 ; MIPS32-NEXT: $BB0_1: # %entry
29 ; MIPS32-NEXT: lui $1, %hi($JTI0_0)
30 ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload
31 ; MIPS32-NEXT: sll $3, $2, 2
32 ; MIPS32-NEXT: addu $1, $1, $3
33 ; MIPS32-NEXT: lw $1, %lo($JTI0_0)($1)
36 ; MIPS32-NEXT: $BB0_2: # %sw.bb
37 ; MIPS32-NEXT: lw $2, 12($sp) # 4-byte Folded Reload
38 ; MIPS32-NEXT: addiu $sp, $sp, 32
41 ; MIPS32-NEXT: $BB0_3: # %sw.bb1
42 ; MIPS32-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
43 ; MIPS32-NEXT: addiu $sp, $sp, 32
46 ; MIPS32-NEXT: $BB0_4: # %sw.bb2
47 ; MIPS32-NEXT: lw $2, 20($sp) # 4-byte Folded Reload
48 ; MIPS32-NEXT: addiu $sp, $sp, 32
51 ; MIPS32-NEXT: $BB0_5: # %sw.bb3
52 ; MIPS32-NEXT: lw $2, 24($sp) # 4-byte Folded Reload
53 ; MIPS32-NEXT: addiu $sp, $sp, 32
56 ; MIPS32-NEXT: $BB0_6: # %sw.default
58 ; MIPS32-NEXT: # %bb.7: # %sw.epilog
59 ; MIPS32-NEXT: ori $1, $zero, 8
60 ; MIPS32-NEXT: lw $2, 28($sp) # 4-byte Folded Reload
61 ; MIPS32-NEXT: subu $1, $2, $1
62 ; MIPS32-NEXT: lw $3, 24($sp) # 4-byte Folded Reload
63 ; MIPS32-NEXT: sltu $4, $3, $1
64 ; MIPS32-NEXT: ori $5, $zero, 1
65 ; MIPS32-NEXT: and $4, $4, $5
66 ; MIPS32-NEXT: sw $1, 0($sp) # 4-byte Folded Spill
67 ; MIPS32-NEXT: bnez $4, $BB0_13
69 ; MIPS32-NEXT: $BB0_8: # %sw.epilog
70 ; MIPS32-NEXT: lui $1, %hi($JTI0_1)
71 ; MIPS32-NEXT: lw $2, 0($sp) # 4-byte Folded Reload
72 ; MIPS32-NEXT: sll $3, $2, 2
73 ; MIPS32-NEXT: addu $1, $1, $3
74 ; MIPS32-NEXT: lw $1, %lo($JTI0_1)($1)
77 ; MIPS32-NEXT: $BB0_9: # %sw.bb4
78 ; MIPS32-NEXT: lw $2, 12($sp) # 4-byte Folded Reload
79 ; MIPS32-NEXT: addiu $sp, $sp, 32
82 ; MIPS32-NEXT: $BB0_10: # %sw.bb5
83 ; MIPS32-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
84 ; MIPS32-NEXT: addiu $sp, $sp, 32
87 ; MIPS32-NEXT: $BB0_11: # %sw.bb6
88 ; MIPS32-NEXT: lw $2, 20($sp) # 4-byte Folded Reload
89 ; MIPS32-NEXT: addiu $sp, $sp, 32
92 ; MIPS32-NEXT: $BB0_12: # %sw.bb7
93 ; MIPS32-NEXT: lw $2, 24($sp) # 4-byte Folded Reload
94 ; MIPS32-NEXT: addiu $sp, $sp, 32
97 ; MIPS32-NEXT: $BB0_13: # %sw.default8
98 ; MIPS32-NEXT: lw $2, 8($sp) # 4-byte Folded Reload
99 ; MIPS32-NEXT: addiu $sp, $sp, 32
100 ; MIPS32-NEXT: jr $ra
103 ; MIPS32-NEXT: .4byte ($BB0_2)
104 ; MIPS32-NEXT: .4byte ($BB0_3)
105 ; MIPS32-NEXT: .4byte ($BB0_4)
106 ; MIPS32-NEXT: .4byte ($BB0_5)
107 ; MIPS32-NEXT: .4byte ($BB0_2)
108 ; MIPS32-NEXT: .4byte ($BB0_3)
109 ; MIPS32-NEXT: .4byte ($BB0_4)
110 ; MIPS32-NEXT: .4byte ($BB0_5)
111 ; MIPS32-NEXT: $JTI0_1:
112 ; MIPS32-NEXT: .4byte ($BB0_9)
113 ; MIPS32-NEXT: .4byte ($BB0_10)
114 ; MIPS32-NEXT: .4byte ($BB0_11)
115 ; MIPS32-NEXT: .4byte ($BB0_12)
118 ; MIPS32_PIC-LABEL: mod4_0_to_11:
119 ; MIPS32_PIC: # %bb.0: # %entry
120 ; MIPS32_PIC-NEXT: lui $2, %hi(_gp_disp)
121 ; MIPS32_PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
122 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -40
123 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 40
124 ; MIPS32_PIC-NEXT: addu $1, $2, $25
125 ; MIPS32_PIC-NEXT: ori $2, $zero, 7
126 ; MIPS32_PIC-NEXT: ori $3, $zero, 3
127 ; MIPS32_PIC-NEXT: ori $5, $zero, 2
128 ; MIPS32_PIC-NEXT: ori $6, $zero, 1
129 ; MIPS32_PIC-NEXT: ori $7, $zero, 0
130 ; MIPS32_PIC-NEXT: addiu $8, $zero, 65535
131 ; MIPS32_PIC-NEXT: ori $9, $zero, 0
132 ; MIPS32_PIC-NEXT: subu $9, $4, $9
133 ; MIPS32_PIC-NEXT: sltu $2, $2, $9
134 ; MIPS32_PIC-NEXT: and $2, $2, $6
135 ; MIPS32_PIC-NEXT: sw $1, 36($sp) # 4-byte Folded Spill
136 ; MIPS32_PIC-NEXT: sw $4, 32($sp) # 4-byte Folded Spill
137 ; MIPS32_PIC-NEXT: sw $3, 28($sp) # 4-byte Folded Spill
138 ; MIPS32_PIC-NEXT: sw $5, 24($sp) # 4-byte Folded Spill
139 ; MIPS32_PIC-NEXT: sw $6, 20($sp) # 4-byte Folded Spill
140 ; MIPS32_PIC-NEXT: sw $7, 16($sp) # 4-byte Folded Spill
141 ; MIPS32_PIC-NEXT: sw $8, 12($sp) # 4-byte Folded Spill
142 ; MIPS32_PIC-NEXT: sw $9, 8($sp) # 4-byte Folded Spill
143 ; MIPS32_PIC-NEXT: bnez $2, $BB0_6
144 ; MIPS32_PIC-NEXT: nop
145 ; MIPS32_PIC-NEXT: $BB0_1: # %entry
146 ; MIPS32_PIC-NEXT: lw $1, 36($sp) # 4-byte Folded Reload
147 ; MIPS32_PIC-NEXT: lw $2, %got($JTI0_0)($1)
148 ; MIPS32_PIC-NEXT: lw $3, 8($sp) # 4-byte Folded Reload
149 ; MIPS32_PIC-NEXT: sll $4, $3, 2
150 ; MIPS32_PIC-NEXT: addu $2, $2, $4
151 ; MIPS32_PIC-NEXT: lw $2, %lo($JTI0_0)($2)
152 ; MIPS32_PIC-NEXT: addu $2, $2, $1
153 ; MIPS32_PIC-NEXT: jr $2
154 ; MIPS32_PIC-NEXT: nop
155 ; MIPS32_PIC-NEXT: $BB0_2: # %sw.bb
156 ; MIPS32_PIC-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
157 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
158 ; MIPS32_PIC-NEXT: jr $ra
159 ; MIPS32_PIC-NEXT: nop
160 ; MIPS32_PIC-NEXT: $BB0_3: # %sw.bb1
161 ; MIPS32_PIC-NEXT: lw $2, 20($sp) # 4-byte Folded Reload
162 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
163 ; MIPS32_PIC-NEXT: jr $ra
164 ; MIPS32_PIC-NEXT: nop
165 ; MIPS32_PIC-NEXT: $BB0_4: # %sw.bb2
166 ; MIPS32_PIC-NEXT: lw $2, 24($sp) # 4-byte Folded Reload
167 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
168 ; MIPS32_PIC-NEXT: jr $ra
169 ; MIPS32_PIC-NEXT: nop
170 ; MIPS32_PIC-NEXT: $BB0_5: # %sw.bb3
171 ; MIPS32_PIC-NEXT: lw $2, 28($sp) # 4-byte Folded Reload
172 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
173 ; MIPS32_PIC-NEXT: jr $ra
174 ; MIPS32_PIC-NEXT: nop
175 ; MIPS32_PIC-NEXT: $BB0_6: # %sw.default
176 ; MIPS32_PIC-NEXT: .insn
177 ; MIPS32_PIC-NEXT: # %bb.7: # %sw.epilog
178 ; MIPS32_PIC-NEXT: ori $1, $zero, 8
179 ; MIPS32_PIC-NEXT: lw $2, 32($sp) # 4-byte Folded Reload
180 ; MIPS32_PIC-NEXT: subu $1, $2, $1
181 ; MIPS32_PIC-NEXT: lw $3, 28($sp) # 4-byte Folded Reload
182 ; MIPS32_PIC-NEXT: sltu $4, $3, $1
183 ; MIPS32_PIC-NEXT: ori $5, $zero, 1
184 ; MIPS32_PIC-NEXT: and $4, $4, $5
185 ; MIPS32_PIC-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
186 ; MIPS32_PIC-NEXT: bnez $4, $BB0_13
187 ; MIPS32_PIC-NEXT: nop
188 ; MIPS32_PIC-NEXT: $BB0_8: # %sw.epilog
189 ; MIPS32_PIC-NEXT: lw $1, 36($sp) # 4-byte Folded Reload
190 ; MIPS32_PIC-NEXT: lw $2, %got($JTI0_1)($1)
191 ; MIPS32_PIC-NEXT: lw $3, 4($sp) # 4-byte Folded Reload
192 ; MIPS32_PIC-NEXT: sll $4, $3, 2
193 ; MIPS32_PIC-NEXT: addu $2, $2, $4
194 ; MIPS32_PIC-NEXT: lw $2, %lo($JTI0_1)($2)
195 ; MIPS32_PIC-NEXT: addu $2, $2, $1
196 ; MIPS32_PIC-NEXT: jr $2
197 ; MIPS32_PIC-NEXT: nop
198 ; MIPS32_PIC-NEXT: $BB0_9: # %sw.bb4
199 ; MIPS32_PIC-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
200 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
201 ; MIPS32_PIC-NEXT: jr $ra
202 ; MIPS32_PIC-NEXT: nop
203 ; MIPS32_PIC-NEXT: $BB0_10: # %sw.bb5
204 ; MIPS32_PIC-NEXT: lw $2, 20($sp) # 4-byte Folded Reload
205 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
206 ; MIPS32_PIC-NEXT: jr $ra
207 ; MIPS32_PIC-NEXT: nop
208 ; MIPS32_PIC-NEXT: $BB0_11: # %sw.bb6
209 ; MIPS32_PIC-NEXT: lw $2, 24($sp) # 4-byte Folded Reload
210 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
211 ; MIPS32_PIC-NEXT: jr $ra
212 ; MIPS32_PIC-NEXT: nop
213 ; MIPS32_PIC-NEXT: $BB0_12: # %sw.bb7
214 ; MIPS32_PIC-NEXT: lw $2, 28($sp) # 4-byte Folded Reload
215 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
216 ; MIPS32_PIC-NEXT: jr $ra
217 ; MIPS32_PIC-NEXT: nop
218 ; MIPS32_PIC-NEXT: $BB0_13: # %sw.default8
219 ; MIPS32_PIC-NEXT: lw $2, 12($sp) # 4-byte Folded Reload
220 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
221 ; MIPS32_PIC-NEXT: jr $ra
222 ; MIPS32_PIC-NEXT: nop
223 ; MIPS32_PIC: $JTI0_0:
224 ; MIPS32_PIC-NEXT: .gpword ($BB0_2)
225 ; MIPS32_PIC-NEXT: .gpword ($BB0_3)
226 ; MIPS32_PIC-NEXT: .gpword ($BB0_4)
227 ; MIPS32_PIC-NEXT: .gpword ($BB0_5)
228 ; MIPS32_PIC-NEXT: .gpword ($BB0_2)
229 ; MIPS32_PIC-NEXT: .gpword ($BB0_3)
230 ; MIPS32_PIC-NEXT: .gpword ($BB0_4)
231 ; MIPS32_PIC-NEXT: .gpword ($BB0_5)
232 ; MIPS32_PIC-NEXT: $JTI0_1:
233 ; MIPS32_PIC-NEXT: .gpword ($BB0_9)
234 ; MIPS32_PIC-NEXT: .gpword ($BB0_10)
235 ; MIPS32_PIC-NEXT: .gpword ($BB0_11)
236 ; MIPS32_PIC-NEXT: .gpword ($BB0_12)
239 switch i32 %a, label %sw.default [
250 sw.bb: ; preds = %entry, %entry
253 sw.bb1: ; preds = %entry, %entry
256 sw.bb2: ; preds = %entry, %entry
259 sw.bb3: ; preds = %entry, %entry
262 sw.default: ; preds = %entry
265 sw.epilog: ; preds = %sw.default
266 switch i32 %a, label %sw.default8 [
269 i32 10, label %sw.bb6
270 i32 11, label %sw.bb7
273 sw.bb4: ; preds = %sw.epilog
276 sw.bb5: ; preds = %sw.epilog
279 sw.bb6: ; preds = %sw.epilog
282 sw.bb7: ; preds = %sw.epilog
285 sw.default8: ; preds = %sw.epilog