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
3 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -relocation-model=pic -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32_PIC
5 define i32 @mod4_0_to_11(i32 %a) {
6 ; MIPS32-LABEL: mod4_0_to_11:
7 ; MIPS32: # %bb.0: # %entry
8 ; MIPS32-NEXT: addiu $sp, $sp, -32
9 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
10 ; MIPS32-NEXT: sw $4, 4($sp) # 4-byte Folded Spill
11 ; MIPS32-NEXT: ori $1, $zero, 7
12 ; MIPS32-NEXT: ori $2, $zero, 3
13 ; MIPS32-NEXT: sw $2, 8($sp) # 4-byte Folded Spill
14 ; MIPS32-NEXT: ori $2, $zero, 2
15 ; MIPS32-NEXT: sw $2, 12($sp) # 4-byte Folded Spill
16 ; MIPS32-NEXT: ori $2, $zero, 1
17 ; MIPS32-NEXT: sw $2, 16($sp) # 4-byte Folded Spill
18 ; MIPS32-NEXT: ori $2, $zero, 0
19 ; MIPS32-NEXT: sw $2, 20($sp) # 4-byte Folded Spill
20 ; MIPS32-NEXT: addiu $2, $zero, 65535
21 ; MIPS32-NEXT: sw $2, 24($sp) # 4-byte Folded Spill
22 ; MIPS32-NEXT: ori $2, $zero, 0
23 ; MIPS32-NEXT: subu $2, $4, $2
24 ; MIPS32-NEXT: sw $2, 28($sp) # 4-byte Folded Spill
25 ; MIPS32-NEXT: sltu $1, $1, $2
26 ; MIPS32-NEXT: andi $1, $1, 1
27 ; MIPS32-NEXT: bnez $1, $BB0_6
29 ; MIPS32-NEXT: $BB0_1: # %entry
30 ; MIPS32-NEXT: lw $2, 28($sp) # 4-byte Folded Reload
31 ; MIPS32-NEXT: lui $1, %hi($JTI0_0)
32 ; MIPS32-NEXT: sll $2, $2, 2
33 ; MIPS32-NEXT: addu $1, $1, $2
34 ; MIPS32-NEXT: lw $1, %lo($JTI0_0)($1)
37 ; MIPS32-NEXT: $BB0_2: # %sw.bb
38 ; MIPS32-NEXT: lw $2, 20($sp) # 4-byte Folded Reload
39 ; MIPS32-NEXT: addiu $sp, $sp, 32
42 ; MIPS32-NEXT: $BB0_3: # %sw.bb1
43 ; MIPS32-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
44 ; MIPS32-NEXT: addiu $sp, $sp, 32
47 ; MIPS32-NEXT: $BB0_4: # %sw.bb2
48 ; MIPS32-NEXT: lw $2, 12($sp) # 4-byte Folded Reload
49 ; MIPS32-NEXT: addiu $sp, $sp, 32
52 ; MIPS32-NEXT: $BB0_5: # %sw.bb3
53 ; MIPS32-NEXT: lw $2, 8($sp) # 4-byte Folded Reload
54 ; MIPS32-NEXT: addiu $sp, $sp, 32
57 ; MIPS32-NEXT: $BB0_6: # %sw.default
58 ; MIPS32-NEXT: j $BB0_7
60 ; MIPS32-NEXT: $BB0_7: # %sw.epilog
61 ; MIPS32-NEXT: lw $1, 8($sp) # 4-byte Folded Reload
62 ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload
63 ; MIPS32-NEXT: ori $3, $zero, 8
64 ; MIPS32-NEXT: subu $2, $2, $3
65 ; MIPS32-NEXT: sw $2, 0($sp) # 4-byte Folded Spill
66 ; MIPS32-NEXT: sltu $1, $1, $2
67 ; MIPS32-NEXT: andi $1, $1, 1
68 ; MIPS32-NEXT: bnez $1, $BB0_13
70 ; MIPS32-NEXT: $BB0_8: # %sw.epilog
71 ; MIPS32-NEXT: lw $2, 0($sp) # 4-byte Folded Reload
72 ; MIPS32-NEXT: lui $1, %hi($JTI0_1)
73 ; MIPS32-NEXT: sll $2, $2, 2
74 ; MIPS32-NEXT: addu $1, $1, $2
75 ; MIPS32-NEXT: lw $1, %lo($JTI0_1)($1)
78 ; MIPS32-NEXT: $BB0_9: # %sw.bb4
79 ; MIPS32-NEXT: lw $2, 20($sp) # 4-byte Folded Reload
80 ; MIPS32-NEXT: addiu $sp, $sp, 32
83 ; MIPS32-NEXT: $BB0_10: # %sw.bb5
84 ; MIPS32-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
85 ; MIPS32-NEXT: addiu $sp, $sp, 32
88 ; MIPS32-NEXT: $BB0_11: # %sw.bb6
89 ; MIPS32-NEXT: lw $2, 12($sp) # 4-byte Folded Reload
90 ; MIPS32-NEXT: addiu $sp, $sp, 32
93 ; MIPS32-NEXT: $BB0_12: # %sw.bb7
94 ; MIPS32-NEXT: lw $2, 8($sp) # 4-byte Folded Reload
95 ; MIPS32-NEXT: addiu $sp, $sp, 32
98 ; MIPS32-NEXT: $BB0_13: # %sw.default8
99 ; MIPS32-NEXT: lw $2, 24($sp) # 4-byte Folded Reload
100 ; MIPS32-NEXT: addiu $sp, $sp, 32
101 ; MIPS32-NEXT: jr $ra
104 ; MIPS32_PIC-LABEL: mod4_0_to_11:
105 ; MIPS32_PIC: # %bb.0: # %entry
106 ; MIPS32_PIC-NEXT: lui $2, %hi(_gp_disp)
107 ; MIPS32_PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
108 ; MIPS32_PIC-NEXT: addiu $sp, $sp, -40
109 ; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 40
110 ; MIPS32_PIC-NEXT: addu $1, $2, $25
111 ; MIPS32_PIC-NEXT: sw $1, 8($sp) # 4-byte Folded Spill
112 ; MIPS32_PIC-NEXT: sw $4, 12($sp) # 4-byte Folded Spill
113 ; MIPS32_PIC-NEXT: ori $1, $zero, 7
114 ; MIPS32_PIC-NEXT: ori $2, $zero, 3
115 ; MIPS32_PIC-NEXT: sw $2, 16($sp) # 4-byte Folded Spill
116 ; MIPS32_PIC-NEXT: ori $2, $zero, 2
117 ; MIPS32_PIC-NEXT: sw $2, 20($sp) # 4-byte Folded Spill
118 ; MIPS32_PIC-NEXT: ori $2, $zero, 1
119 ; MIPS32_PIC-NEXT: sw $2, 24($sp) # 4-byte Folded Spill
120 ; MIPS32_PIC-NEXT: ori $2, $zero, 0
121 ; MIPS32_PIC-NEXT: sw $2, 28($sp) # 4-byte Folded Spill
122 ; MIPS32_PIC-NEXT: addiu $2, $zero, 65535
123 ; MIPS32_PIC-NEXT: sw $2, 32($sp) # 4-byte Folded Spill
124 ; MIPS32_PIC-NEXT: ori $2, $zero, 0
125 ; MIPS32_PIC-NEXT: subu $2, $4, $2
126 ; MIPS32_PIC-NEXT: sw $2, 36($sp) # 4-byte Folded Spill
127 ; MIPS32_PIC-NEXT: sltu $1, $1, $2
128 ; MIPS32_PIC-NEXT: andi $1, $1, 1
129 ; MIPS32_PIC-NEXT: bnez $1, $BB0_6
130 ; MIPS32_PIC-NEXT: nop
131 ; MIPS32_PIC-NEXT: $BB0_1: # %entry
132 ; MIPS32_PIC-NEXT: lw $2, 8($sp) # 4-byte Folded Reload
133 ; MIPS32_PIC-NEXT: lw $3, 36($sp) # 4-byte Folded Reload
134 ; MIPS32_PIC-NEXT: lw $1, %got($JTI0_0)($2)
135 ; MIPS32_PIC-NEXT: sll $3, $3, 2
136 ; MIPS32_PIC-NEXT: addu $1, $1, $3
137 ; MIPS32_PIC-NEXT: lw $1, %lo($JTI0_0)($1)
138 ; MIPS32_PIC-NEXT: addu $1, $1, $2
139 ; MIPS32_PIC-NEXT: jr $1
140 ; MIPS32_PIC-NEXT: nop
141 ; MIPS32_PIC-NEXT: $BB0_2: # %sw.bb
142 ; MIPS32_PIC-NEXT: lw $2, 28($sp) # 4-byte Folded Reload
143 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
144 ; MIPS32_PIC-NEXT: jr $ra
145 ; MIPS32_PIC-NEXT: nop
146 ; MIPS32_PIC-NEXT: $BB0_3: # %sw.bb1
147 ; MIPS32_PIC-NEXT: lw $2, 24($sp) # 4-byte Folded Reload
148 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
149 ; MIPS32_PIC-NEXT: jr $ra
150 ; MIPS32_PIC-NEXT: nop
151 ; MIPS32_PIC-NEXT: $BB0_4: # %sw.bb2
152 ; MIPS32_PIC-NEXT: lw $2, 20($sp) # 4-byte Folded Reload
153 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
154 ; MIPS32_PIC-NEXT: jr $ra
155 ; MIPS32_PIC-NEXT: nop
156 ; MIPS32_PIC-NEXT: $BB0_5: # %sw.bb3
157 ; MIPS32_PIC-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
158 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
159 ; MIPS32_PIC-NEXT: jr $ra
160 ; MIPS32_PIC-NEXT: nop
161 ; MIPS32_PIC-NEXT: $BB0_6: # %sw.default
162 ; MIPS32_PIC-NEXT: b $BB0_7
163 ; MIPS32_PIC-NEXT: nop
164 ; MIPS32_PIC-NEXT: $BB0_7: # %sw.epilog
165 ; MIPS32_PIC-NEXT: lw $1, 16($sp) # 4-byte Folded Reload
166 ; MIPS32_PIC-NEXT: lw $2, 12($sp) # 4-byte Folded Reload
167 ; MIPS32_PIC-NEXT: ori $3, $zero, 8
168 ; MIPS32_PIC-NEXT: subu $2, $2, $3
169 ; MIPS32_PIC-NEXT: sw $2, 4($sp) # 4-byte Folded Spill
170 ; MIPS32_PIC-NEXT: sltu $1, $1, $2
171 ; MIPS32_PIC-NEXT: andi $1, $1, 1
172 ; MIPS32_PIC-NEXT: bnez $1, $BB0_13
173 ; MIPS32_PIC-NEXT: nop
174 ; MIPS32_PIC-NEXT: $BB0_8: # %sw.epilog
175 ; MIPS32_PIC-NEXT: lw $2, 8($sp) # 4-byte Folded Reload
176 ; MIPS32_PIC-NEXT: lw $3, 4($sp) # 4-byte Folded Reload
177 ; MIPS32_PIC-NEXT: lw $1, %got($JTI0_1)($2)
178 ; MIPS32_PIC-NEXT: sll $3, $3, 2
179 ; MIPS32_PIC-NEXT: addu $1, $1, $3
180 ; MIPS32_PIC-NEXT: lw $1, %lo($JTI0_1)($1)
181 ; MIPS32_PIC-NEXT: addu $1, $1, $2
182 ; MIPS32_PIC-NEXT: jr $1
183 ; MIPS32_PIC-NEXT: nop
184 ; MIPS32_PIC-NEXT: $BB0_9: # %sw.bb4
185 ; MIPS32_PIC-NEXT: lw $2, 28($sp) # 4-byte Folded Reload
186 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
187 ; MIPS32_PIC-NEXT: jr $ra
188 ; MIPS32_PIC-NEXT: nop
189 ; MIPS32_PIC-NEXT: $BB0_10: # %sw.bb5
190 ; MIPS32_PIC-NEXT: lw $2, 24($sp) # 4-byte Folded Reload
191 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
192 ; MIPS32_PIC-NEXT: jr $ra
193 ; MIPS32_PIC-NEXT: nop
194 ; MIPS32_PIC-NEXT: $BB0_11: # %sw.bb6
195 ; MIPS32_PIC-NEXT: lw $2, 20($sp) # 4-byte Folded Reload
196 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
197 ; MIPS32_PIC-NEXT: jr $ra
198 ; MIPS32_PIC-NEXT: nop
199 ; MIPS32_PIC-NEXT: $BB0_12: # %sw.bb7
200 ; MIPS32_PIC-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
201 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
202 ; MIPS32_PIC-NEXT: jr $ra
203 ; MIPS32_PIC-NEXT: nop
204 ; MIPS32_PIC-NEXT: $BB0_13: # %sw.default8
205 ; MIPS32_PIC-NEXT: lw $2, 32($sp) # 4-byte Folded Reload
206 ; MIPS32_PIC-NEXT: addiu $sp, $sp, 40
207 ; MIPS32_PIC-NEXT: jr $ra
208 ; MIPS32_PIC-NEXT: nop
212 switch i32 %a, label %sw.default [
223 sw.bb: ; preds = %entry, %entry
226 sw.bb1: ; preds = %entry, %entry
229 sw.bb2: ; preds = %entry, %entry
232 sw.bb3: ; preds = %entry, %entry
235 sw.default: ; preds = %entry
238 sw.epilog: ; preds = %sw.default
239 switch i32 %a, label %sw.default8 [
242 i32 10, label %sw.bb6
243 i32 11, label %sw.bb7
246 sw.bb4: ; preds = %sw.epilog
249 sw.bb5: ; preds = %sw.epilog
252 sw.bb6: ; preds = %sw.epilog
255 sw.bb7: ; preds = %sw.epilog
258 sw.default8: ; preds = %sw.epilog