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
4 define i1 @phi_i1(i1 %cnd, i1 %a, i1 %b) {
5 ; MIPS32-LABEL: phi_i1:
6 ; MIPS32: # %bb.0: # %entry
7 ; MIPS32-NEXT: addiu $sp, $sp, -16
8 ; MIPS32-NEXT: .cfi_def_cfa_offset 16
9 ; MIPS32-NEXT: sw $5, 8($sp) # 4-byte Folded Spill
10 ; MIPS32-NEXT: sw $6, 12($sp) # 4-byte Folded Spill
11 ; MIPS32-NEXT: andi $1, $4, 1
12 ; MIPS32-NEXT: bnez $1, $BB0_2
14 ; MIPS32-NEXT: # %bb.1: # %entry
15 ; MIPS32-NEXT: j $BB0_3
17 ; MIPS32-NEXT: $BB0_2: # %cond.true
18 ; MIPS32-NEXT: lw $1, 8($sp) # 4-byte Folded Reload
19 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
20 ; MIPS32-NEXT: j $BB0_4
22 ; MIPS32-NEXT: $BB0_3: # %cond.false
23 ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload
24 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
25 ; MIPS32-NEXT: j $BB0_4
27 ; MIPS32-NEXT: $BB0_4: # %cond.end
28 ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload
29 ; MIPS32-NEXT: addiu $sp, $sp, 16
33 br i1 %cnd, label %cond.true, label %cond.false
42 %cond = phi i1 [ %a, %cond.true ], [ %b, %cond.false ]
46 define i8 @phi_i8(i1 %cnd, i8 %a, i8 %b) {
47 ; MIPS32-LABEL: phi_i8:
48 ; MIPS32: # %bb.0: # %entry
49 ; MIPS32-NEXT: addiu $sp, $sp, -16
50 ; MIPS32-NEXT: .cfi_def_cfa_offset 16
51 ; MIPS32-NEXT: sw $5, 8($sp) # 4-byte Folded Spill
52 ; MIPS32-NEXT: sw $6, 12($sp) # 4-byte Folded Spill
53 ; MIPS32-NEXT: andi $1, $4, 1
54 ; MIPS32-NEXT: bnez $1, $BB1_2
56 ; MIPS32-NEXT: # %bb.1: # %entry
57 ; MIPS32-NEXT: j $BB1_3
59 ; MIPS32-NEXT: $BB1_2: # %cond.true
60 ; MIPS32-NEXT: lw $1, 8($sp) # 4-byte Folded Reload
61 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
62 ; MIPS32-NEXT: j $BB1_4
64 ; MIPS32-NEXT: $BB1_3: # %cond.false
65 ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload
66 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
67 ; MIPS32-NEXT: j $BB1_4
69 ; MIPS32-NEXT: $BB1_4: # %cond.end
70 ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload
71 ; MIPS32-NEXT: addiu $sp, $sp, 16
75 br i1 %cnd, label %cond.true, label %cond.false
84 %cond = phi i8 [ %a, %cond.true ], [ %b, %cond.false ]
88 define i16 @phi_i16(i1 %cnd, i16 %a, i16 %b) {
89 ; MIPS32-LABEL: phi_i16:
90 ; MIPS32: # %bb.0: # %entry
91 ; MIPS32-NEXT: addiu $sp, $sp, -16
92 ; MIPS32-NEXT: .cfi_def_cfa_offset 16
93 ; MIPS32-NEXT: sw $5, 8($sp) # 4-byte Folded Spill
94 ; MIPS32-NEXT: sw $6, 12($sp) # 4-byte Folded Spill
95 ; MIPS32-NEXT: andi $1, $4, 1
96 ; MIPS32-NEXT: bnez $1, $BB2_2
98 ; MIPS32-NEXT: # %bb.1: # %entry
99 ; MIPS32-NEXT: j $BB2_3
101 ; MIPS32-NEXT: $BB2_2: # %cond.true
102 ; MIPS32-NEXT: lw $1, 8($sp) # 4-byte Folded Reload
103 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
104 ; MIPS32-NEXT: j $BB2_4
106 ; MIPS32-NEXT: $BB2_3: # %cond.false
107 ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload
108 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
109 ; MIPS32-NEXT: j $BB2_4
111 ; MIPS32-NEXT: $BB2_4: # %cond.end
112 ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload
113 ; MIPS32-NEXT: addiu $sp, $sp, 16
114 ; MIPS32-NEXT: jr $ra
117 br i1 %cnd, label %cond.true, label %cond.false
126 %cond = phi i16 [ %a, %cond.true ], [ %b, %cond.false ]
130 define i32 @phi_i32(i1 %cnd, i32 %a, i32 %b) {
131 ; MIPS32-LABEL: phi_i32:
132 ; MIPS32: # %bb.0: # %entry
133 ; MIPS32-NEXT: addiu $sp, $sp, -16
134 ; MIPS32-NEXT: .cfi_def_cfa_offset 16
135 ; MIPS32-NEXT: sw $5, 8($sp) # 4-byte Folded Spill
136 ; MIPS32-NEXT: sw $6, 12($sp) # 4-byte Folded Spill
137 ; MIPS32-NEXT: andi $1, $4, 1
138 ; MIPS32-NEXT: bnez $1, $BB3_2
140 ; MIPS32-NEXT: # %bb.1: # %entry
141 ; MIPS32-NEXT: j $BB3_3
143 ; MIPS32-NEXT: $BB3_2: # %cond.true
144 ; MIPS32-NEXT: lw $1, 8($sp) # 4-byte Folded Reload
145 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
146 ; MIPS32-NEXT: j $BB3_4
148 ; MIPS32-NEXT: $BB3_3: # %cond.false
149 ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload
150 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
151 ; MIPS32-NEXT: j $BB3_4
153 ; MIPS32-NEXT: $BB3_4: # %cond.end
154 ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload
155 ; MIPS32-NEXT: addiu $sp, $sp, 16
156 ; MIPS32-NEXT: jr $ra
159 br i1 %cnd, label %cond.true, label %cond.false
168 %cond = phi i32 [ %a, %cond.true ], [ %b, %cond.false ]
172 define i64 @phi_i64(i1 %cnd, i64 %a, i64 %b) {
173 ; MIPS32-LABEL: phi_i64:
174 ; MIPS32: # %bb.0: # %entry
175 ; MIPS32-NEXT: addiu $sp, $sp, -24
176 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
177 ; MIPS32-NEXT: sw $6, 8($sp) # 4-byte Folded Spill
178 ; MIPS32-NEXT: sw $7, 12($sp) # 4-byte Folded Spill
179 ; MIPS32-NEXT: addiu $1, $sp, 40
180 ; MIPS32-NEXT: lw $1, 0($1)
181 ; MIPS32-NEXT: sw $1, 16($sp) # 4-byte Folded Spill
182 ; MIPS32-NEXT: addiu $1, $sp, 44
183 ; MIPS32-NEXT: lw $1, 0($1)
184 ; MIPS32-NEXT: sw $1, 20($sp) # 4-byte Folded Spill
185 ; MIPS32-NEXT: andi $1, $4, 1
186 ; MIPS32-NEXT: bnez $1, $BB4_2
188 ; MIPS32-NEXT: # %bb.1: # %entry
189 ; MIPS32-NEXT: j $BB4_3
191 ; MIPS32-NEXT: $BB4_2: # %cond.true
192 ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload
193 ; MIPS32-NEXT: lw $2, 8($sp) # 4-byte Folded Reload
194 ; MIPS32-NEXT: sw $2, 0($sp) # 4-byte Folded Spill
195 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
196 ; MIPS32-NEXT: j $BB4_4
198 ; MIPS32-NEXT: $BB4_3: # %cond.false
199 ; MIPS32-NEXT: lw $1, 20($sp) # 4-byte Folded Reload
200 ; MIPS32-NEXT: lw $2, 16($sp) # 4-byte Folded Reload
201 ; MIPS32-NEXT: sw $2, 0($sp) # 4-byte Folded Spill
202 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
203 ; MIPS32-NEXT: j $BB4_4
205 ; MIPS32-NEXT: $BB4_4: # %cond.end
206 ; MIPS32-NEXT: lw $2, 0($sp) # 4-byte Folded Reload
207 ; MIPS32-NEXT: lw $3, 4($sp) # 4-byte Folded Reload
208 ; MIPS32-NEXT: addiu $sp, $sp, 24
209 ; MIPS32-NEXT: jr $ra
212 br i1 %cnd, label %cond.true, label %cond.false
221 %cond = phi i64 [ %a, %cond.true ], [ %b, %cond.false ]
225 define void @phi_ambiguous_i64_in_fpr(i1 %cnd, ptr %i64_ptr_a, ptr %i64_ptr_b, ptr %i64_ptr_c) {
226 ; MIPS32-LABEL: phi_ambiguous_i64_in_fpr:
227 ; MIPS32: # %bb.0: # %entry
228 ; MIPS32-NEXT: addiu $sp, $sp, -32
229 ; MIPS32-NEXT: .cfi_def_cfa_offset 32
230 ; MIPS32-NEXT: sw $7, 12($sp) # 4-byte Folded Spill
231 ; MIPS32-NEXT: ldc1 $f0, 0($5)
232 ; MIPS32-NEXT: sdc1 $f0, 16($sp) # 8-byte Folded Spill
233 ; MIPS32-NEXT: ldc1 $f0, 0($6)
234 ; MIPS32-NEXT: sdc1 $f0, 24($sp) # 8-byte Folded Spill
235 ; MIPS32-NEXT: andi $1, $4, 1
236 ; MIPS32-NEXT: bnez $1, $BB5_2
238 ; MIPS32-NEXT: # %bb.1: # %entry
239 ; MIPS32-NEXT: j $BB5_3
241 ; MIPS32-NEXT: $BB5_2: # %cond.true
242 ; MIPS32-NEXT: ldc1 $f0, 16($sp) # 8-byte Folded Reload
243 ; MIPS32-NEXT: sdc1 $f0, 0($sp) # 8-byte Folded Spill
244 ; MIPS32-NEXT: j $BB5_4
246 ; MIPS32-NEXT: $BB5_3: # %cond.false
247 ; MIPS32-NEXT: ldc1 $f0, 24($sp) # 8-byte Folded Reload
248 ; MIPS32-NEXT: sdc1 $f0, 0($sp) # 8-byte Folded Spill
249 ; MIPS32-NEXT: j $BB5_4
251 ; MIPS32-NEXT: $BB5_4: # %cond.end
252 ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload
253 ; MIPS32-NEXT: ldc1 $f0, 0($sp) # 8-byte Folded Reload
254 ; MIPS32-NEXT: sdc1 $f0, 0($1)
255 ; MIPS32-NEXT: addiu $sp, $sp, 32
256 ; MIPS32-NEXT: jr $ra
259 %0 = load i64, ptr %i64_ptr_a, align 8
260 %1 = load i64, ptr %i64_ptr_b, align 8
261 br i1 %cnd, label %cond.true, label %cond.false
270 %cond = phi i64 [ %0, %cond.true ], [ %1, %cond.false ]
271 store i64 %cond, ptr %i64_ptr_c, align 8
275 define float @phi_float(i1 %cnd, float %a, float %b) {
276 ; MIPS32-LABEL: phi_float:
277 ; MIPS32: # %bb.0: # %entry
278 ; MIPS32-NEXT: addiu $sp, $sp, -16
279 ; MIPS32-NEXT: .cfi_def_cfa_offset 16
280 ; MIPS32-NEXT: sw $5, 8($sp) # 4-byte Folded Spill
281 ; MIPS32-NEXT: sw $6, 12($sp) # 4-byte Folded Spill
282 ; MIPS32-NEXT: andi $1, $4, 1
283 ; MIPS32-NEXT: bnez $1, $BB6_2
285 ; MIPS32-NEXT: # %bb.1: # %entry
286 ; MIPS32-NEXT: j $BB6_3
288 ; MIPS32-NEXT: $BB6_2: # %cond.true
289 ; MIPS32-NEXT: lw $1, 8($sp) # 4-byte Folded Reload
290 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
291 ; MIPS32-NEXT: j $BB6_4
293 ; MIPS32-NEXT: $BB6_3: # %cond.false
294 ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload
295 ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill
296 ; MIPS32-NEXT: j $BB6_4
298 ; MIPS32-NEXT: $BB6_4: # %cond.end
299 ; MIPS32-NEXT: lw $1, 4($sp) # 4-byte Folded Reload
300 ; MIPS32-NEXT: mtc1 $1, $f0
301 ; MIPS32-NEXT: addiu $sp, $sp, 16
302 ; MIPS32-NEXT: jr $ra
305 br i1 %cnd, label %cond.true, label %cond.false
314 %cond = phi float [ %a, %cond.true ], [ %b, %cond.false ]
318 define void @phi_ambiguous_float_in_gpr(i1 %cnd, ptr %f32_ptr_a, ptr %f32_ptr_b, ptr %f32_ptr_c) {
319 ; MIPS32-LABEL: phi_ambiguous_float_in_gpr:
320 ; MIPS32: # %bb.0: # %entry
321 ; MIPS32-NEXT: addiu $sp, $sp, -16
322 ; MIPS32-NEXT: .cfi_def_cfa_offset 16
323 ; MIPS32-NEXT: sw $7, 4($sp) # 4-byte Folded Spill
324 ; MIPS32-NEXT: lw $1, 0($5)
325 ; MIPS32-NEXT: sw $1, 8($sp) # 4-byte Folded Spill
326 ; MIPS32-NEXT: lw $1, 0($6)
327 ; MIPS32-NEXT: sw $1, 12($sp) # 4-byte Folded Spill
328 ; MIPS32-NEXT: andi $1, $4, 1
329 ; MIPS32-NEXT: bnez $1, $BB7_2
331 ; MIPS32-NEXT: # %bb.1: # %entry
332 ; MIPS32-NEXT: j $BB7_3
334 ; MIPS32-NEXT: $BB7_2: # %cond.true
335 ; MIPS32-NEXT: lw $1, 8($sp) # 4-byte Folded Reload
336 ; MIPS32-NEXT: sw $1, 0($sp) # 4-byte Folded Spill
337 ; MIPS32-NEXT: j $BB7_4
339 ; MIPS32-NEXT: $BB7_3: # %cond.false
340 ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload
341 ; MIPS32-NEXT: sw $1, 0($sp) # 4-byte Folded Spill
342 ; MIPS32-NEXT: j $BB7_4
344 ; MIPS32-NEXT: $BB7_4: # %cond.end
345 ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload
346 ; MIPS32-NEXT: lw $1, 0($sp) # 4-byte Folded Reload
347 ; MIPS32-NEXT: sw $1, 0($2)
348 ; MIPS32-NEXT: addiu $sp, $sp, 16
349 ; MIPS32-NEXT: jr $ra
352 %0 = load float, ptr %f32_ptr_a, align 4
353 %1 = load float, ptr %f32_ptr_b, align 4
354 br i1 %cnd, label %cond.true, label %cond.false
363 %cond = phi float [ %0, %cond.true ], [ %1, %cond.false ]
364 store float %cond, ptr %f32_ptr_c, align 4
368 define double @phi_double(double %a, double %b, i1 %cnd) {
369 ; MIPS32-LABEL: phi_double:
370 ; MIPS32: # %bb.0: # %entry
371 ; MIPS32-NEXT: addiu $sp, $sp, -24
372 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
373 ; MIPS32-NEXT: sdc1 $f12, 8($sp) # 8-byte Folded Spill
374 ; MIPS32-NEXT: sdc1 $f14, 16($sp) # 8-byte Folded Spill
375 ; MIPS32-NEXT: addiu $1, $sp, 40
376 ; MIPS32-NEXT: lw $1, 0($1)
377 ; MIPS32-NEXT: andi $1, $1, 1
378 ; MIPS32-NEXT: bnez $1, $BB8_2
380 ; MIPS32-NEXT: # %bb.1: # %entry
381 ; MIPS32-NEXT: j $BB8_3
383 ; MIPS32-NEXT: $BB8_2: # %cond.true
384 ; MIPS32-NEXT: ldc1 $f0, 8($sp) # 8-byte Folded Reload
385 ; MIPS32-NEXT: sdc1 $f0, 0($sp) # 8-byte Folded Spill
386 ; MIPS32-NEXT: j $BB8_4
388 ; MIPS32-NEXT: $BB8_3: # %cond.false
389 ; MIPS32-NEXT: ldc1 $f0, 16($sp) # 8-byte Folded Reload
390 ; MIPS32-NEXT: sdc1 $f0, 0($sp) # 8-byte Folded Spill
391 ; MIPS32-NEXT: j $BB8_4
393 ; MIPS32-NEXT: $BB8_4: # %cond.end
394 ; MIPS32-NEXT: ldc1 $f0, 0($sp) # 8-byte Folded Reload
395 ; MIPS32-NEXT: addiu $sp, $sp, 24
396 ; MIPS32-NEXT: jr $ra
399 br i1 %cnd, label %cond.true, label %cond.false
408 %cond = phi double [ %a, %cond.true ], [ %b, %cond.false ]