1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
5 define i1 @phi_i1(i1 %cnd, i1 %a, i1 %b) {
7 br i1 %cnd, label %cond.true, label %cond.false
9 cond.true: ; preds = %entry
12 cond.false: ; preds = %entry
15 cond.end: ; preds = %cond.false, %cond.true
16 %cond = phi i1 [ %a, %cond.true ], [ %b, %cond.false ]
20 define i8 @phi_i8(i1 %cnd, i8 %a, i8 %b) {
22 br i1 %cnd, label %cond.true, label %cond.false
24 cond.true: ; preds = %entry
27 cond.false: ; preds = %entry
30 cond.end: ; preds = %cond.false, %cond.true
31 %cond = phi i8 [ %a, %cond.true ], [ %b, %cond.false ]
35 define i16 @phi_i16(i1 %cnd, i16 %a, i16 %b) {
37 br i1 %cnd, label %cond.true, label %cond.false
39 cond.true: ; preds = %entry
42 cond.false: ; preds = %entry
45 cond.end: ; preds = %cond.false, %cond.true
46 %cond = phi i16 [ %a, %cond.true ], [ %b, %cond.false ]
50 define i32 @phi_i32(i1 %cnd, i32 %a, i32 %b) {
52 br i1 %cnd, label %cond.true, label %cond.false
54 cond.true: ; preds = %entry
57 cond.false: ; preds = %entry
60 cond.end: ; preds = %cond.false, %cond.true
61 %cond = phi i32 [ %a, %cond.true ], [ %b, %cond.false ]
65 define i64 @phi_i64(i1 %cnd, i64 %a, i64 %b) {
67 br i1 %cnd, label %cond.true, label %cond.false
69 cond.true: ; preds = %entry
72 cond.false: ; preds = %entry
75 cond.end: ; preds = %cond.false, %cond.true
76 %cond = phi i64 [ %a, %cond.true ], [ %b, %cond.false ]
80 define void @phi_ambiguous_i64_in_fpr(i1 %cnd, ptr %i64_ptr_a, ptr %i64_ptr_b, ptr %i64_ptr_c) {
82 %0 = load i64, ptr %i64_ptr_a, align 8
83 %1 = load i64, ptr %i64_ptr_b, align 8
84 br i1 %cnd, label %cond.true, label %cond.false
86 cond.true: ; preds = %entry
89 cond.false: ; preds = %entry
92 cond.end: ; preds = %cond.false, %cond.true
93 %cond = phi i64 [ %0, %cond.true ], [ %1, %cond.false ]
94 store i64 %cond, ptr %i64_ptr_c, align 8
98 define float @phi_float(i1 %cnd, float %a, float %b) {
100 br i1 %cnd, label %cond.true, label %cond.false
102 cond.true: ; preds = %entry
105 cond.false: ; preds = %entry
108 cond.end: ; preds = %cond.false, %cond.true
109 %cond = phi float [ %a, %cond.true ], [ %b, %cond.false ]
113 define void @phi_ambiguous_float_in_gpr(i1 %cnd, ptr %f32_ptr_a, ptr %f32_ptr_b, ptr %f32_ptr_c) {
115 %0 = load float, ptr %f32_ptr_a, align 4
116 %1 = load float, ptr %f32_ptr_b, align 4
117 br i1 %cnd, label %cond.true, label %cond.false
119 cond.true: ; preds = %entry
122 cond.false: ; preds = %entry
125 cond.end: ; preds = %cond.false, %cond.true
126 %cond = phi float [ %0, %cond.true ], [ %1, %cond.false ]
127 store float %cond, ptr %f32_ptr_c, align 4
131 define double @phi_double(double %a, double %b, i1 %cnd) {
133 br i1 %cnd, label %cond.true, label %cond.false
135 cond.true: ; preds = %entry
138 cond.false: ; preds = %entry
141 cond.end: ; preds = %cond.false, %cond.true
142 %cond = phi double [ %a, %cond.true ], [ %b, %cond.false ]
150 tracksRegLiveness: true
152 ; MIPS32-LABEL: name: phi_i1
153 ; MIPS32: bb.0.entry:
154 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
155 ; MIPS32: liveins: $a0, $a1, $a2
156 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
157 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
158 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
159 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
160 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
161 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
163 ; MIPS32: bb.1.cond.true:
164 ; MIPS32: successors: %bb.3(0x80000000)
166 ; MIPS32: bb.2.cond.false:
167 ; MIPS32: successors: %bb.3(0x80000000)
168 ; MIPS32: bb.3.cond.end:
169 ; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY1]](s32), %bb.1, [[COPY2]](s32), %bb.2
170 ; MIPS32: $v0 = COPY [[PHI]](s32)
171 ; MIPS32: RetRA implicit $v0
173 liveins: $a0, $a1, $a2
176 %0:_(s1) = G_TRUNC %3(s32)
178 %1:_(s1) = G_TRUNC %4(s32)
180 %2:_(s1) = G_TRUNC %5(s32)
181 G_BRCOND %0(s1), %bb.2
190 %6:_(s1) = G_PHI %1(s1), %bb.2, %2(s1), %bb.3
191 %7:_(s32) = G_ANYEXT %6(s1)
199 tracksRegLiveness: true
201 ; MIPS32-LABEL: name: phi_i8
202 ; MIPS32: bb.0.entry:
203 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
204 ; MIPS32: liveins: $a0, $a1, $a2
205 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
206 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
207 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
208 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
209 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
210 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
212 ; MIPS32: bb.1.cond.true:
213 ; MIPS32: successors: %bb.3(0x80000000)
215 ; MIPS32: bb.2.cond.false:
216 ; MIPS32: successors: %bb.3(0x80000000)
217 ; MIPS32: bb.3.cond.end:
218 ; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY1]](s32), %bb.1, [[COPY2]](s32), %bb.2
219 ; MIPS32: $v0 = COPY [[PHI]](s32)
220 ; MIPS32: RetRA implicit $v0
222 liveins: $a0, $a1, $a2
225 %0:_(s1) = G_TRUNC %3(s32)
227 %1:_(s8) = G_TRUNC %4(s32)
229 %2:_(s8) = G_TRUNC %5(s32)
230 G_BRCOND %0(s1), %bb.2
239 %6:_(s8) = G_PHI %1(s8), %bb.2, %2(s8), %bb.3
240 %7:_(s32) = G_ANYEXT %6(s8)
248 tracksRegLiveness: true
250 ; MIPS32-LABEL: name: phi_i16
251 ; MIPS32: bb.0.entry:
252 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
253 ; MIPS32: liveins: $a0, $a1, $a2
254 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
255 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
256 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
257 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
258 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
259 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
261 ; MIPS32: bb.1.cond.true:
262 ; MIPS32: successors: %bb.3(0x80000000)
264 ; MIPS32: bb.2.cond.false:
265 ; MIPS32: successors: %bb.3(0x80000000)
266 ; MIPS32: bb.3.cond.end:
267 ; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY1]](s32), %bb.1, [[COPY2]](s32), %bb.2
268 ; MIPS32: $v0 = COPY [[PHI]](s32)
269 ; MIPS32: RetRA implicit $v0
271 liveins: $a0, $a1, $a2
274 %0:_(s1) = G_TRUNC %3(s32)
276 %1:_(s16) = G_TRUNC %4(s32)
278 %2:_(s16) = G_TRUNC %5(s32)
279 G_BRCOND %0(s1), %bb.2
288 %6:_(s16) = G_PHI %1(s16), %bb.2, %2(s16), %bb.3
289 %7:_(s32) = G_ANYEXT %6(s16)
297 tracksRegLiveness: true
299 ; MIPS32-LABEL: name: phi_i32
300 ; MIPS32: bb.0.entry:
301 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
302 ; MIPS32: liveins: $a0, $a1, $a2
303 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
304 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
305 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
306 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
307 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
308 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
310 ; MIPS32: bb.1.cond.true:
311 ; MIPS32: successors: %bb.3(0x80000000)
313 ; MIPS32: bb.2.cond.false:
314 ; MIPS32: successors: %bb.3(0x80000000)
315 ; MIPS32: bb.3.cond.end:
316 ; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY1]](s32), %bb.1, [[COPY2]](s32), %bb.2
317 ; MIPS32: $v0 = COPY [[PHI]](s32)
318 ; MIPS32: RetRA implicit $v0
320 liveins: $a0, $a1, $a2
323 %0:_(s1) = G_TRUNC %3(s32)
326 G_BRCOND %0(s1), %bb.2
335 %4:_(s32) = G_PHI %1(s32), %bb.2, %2(s32), %bb.3
343 tracksRegLiveness: true
345 - { id: 0, offset: 20, size: 4, alignment: 4, isImmutable: true }
346 - { id: 1, offset: 16, size: 4, alignment: 8, isImmutable: true }
348 ; MIPS32-LABEL: name: phi_i64
349 ; MIPS32: bb.0.entry:
350 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
351 ; MIPS32: liveins: $a0, $a2, $a3
352 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
353 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a2
354 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a3
355 ; MIPS32: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY1]](s32), [[COPY2]](s32)
356 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
357 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
358 ; MIPS32: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.1
359 ; MIPS32: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX1]](p0) :: (load (s32) from %fixed-stack.1)
360 ; MIPS32: [[MV1:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[LOAD]](s32), [[LOAD1]](s32)
361 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
362 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
363 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
365 ; MIPS32: bb.1.cond.true:
366 ; MIPS32: successors: %bb.3(0x80000000)
368 ; MIPS32: bb.2.cond.false:
369 ; MIPS32: successors: %bb.3(0x80000000)
370 ; MIPS32: bb.3.cond.end:
371 ; MIPS32: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[MV]](s64), %bb.1, [[MV1]](s64), %bb.2
372 ; MIPS32: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[PHI]](s64)
373 ; MIPS32: $v0 = COPY [[UV]](s32)
374 ; MIPS32: $v1 = COPY [[UV1]](s32)
375 ; MIPS32: RetRA implicit $v0, implicit $v1
377 liveins: $a0, $a2, $a3
380 %0:_(s1) = G_TRUNC %3(s32)
383 %1:_(s64) = G_MERGE_VALUES %4(s32), %5(s32)
384 %8:_(p0) = G_FRAME_INDEX %fixed-stack.1
385 %6:_(s32) = G_LOAD %8(p0) :: (load (s32) from %fixed-stack.1, align 8)
386 %9:_(p0) = G_FRAME_INDEX %fixed-stack.0
387 %7:_(s32) = G_LOAD %9(p0) :: (load (s32) from %fixed-stack.0)
388 %2:_(s64) = G_MERGE_VALUES %6(s32), %7(s32)
389 G_BRCOND %0(s1), %bb.2
398 %10:_(s64) = G_PHI %1(s64), %bb.2, %2(s64), %bb.3
399 %11:_(s32), %12:_(s32) = G_UNMERGE_VALUES %10(s64)
402 RetRA implicit $v0, implicit $v1
406 name: phi_ambiguous_i64_in_fpr
408 tracksRegLiveness: true
410 ; MIPS32-LABEL: name: phi_ambiguous_i64_in_fpr
411 ; MIPS32: bb.0.entry:
412 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
413 ; MIPS32: liveins: $a0, $a1, $a2, $a3
414 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
415 ; MIPS32: [[COPY1:%[0-9]+]]:_(p0) = COPY $a1
416 ; MIPS32: [[COPY2:%[0-9]+]]:_(p0) = COPY $a2
417 ; MIPS32: [[COPY3:%[0-9]+]]:_(p0) = COPY $a3
418 ; MIPS32: [[LOAD:%[0-9]+]]:_(s64) = G_LOAD [[COPY1]](p0) :: (load (s64) from %ir.i64_ptr_a)
419 ; MIPS32: [[LOAD1:%[0-9]+]]:_(s64) = G_LOAD [[COPY2]](p0) :: (load (s64) from %ir.i64_ptr_b)
420 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
421 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
422 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
424 ; MIPS32: bb.1.cond.true:
425 ; MIPS32: successors: %bb.3(0x80000000)
427 ; MIPS32: bb.2.cond.false:
428 ; MIPS32: successors: %bb.3(0x80000000)
429 ; MIPS32: bb.3.cond.end:
430 ; MIPS32: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[LOAD]](s64), %bb.1, [[LOAD1]](s64), %bb.2
431 ; MIPS32: G_STORE [[PHI]](s64), [[COPY3]](p0) :: (store (s64) into %ir.i64_ptr_c)
434 liveins: $a0, $a1, $a2, $a3
437 %0:_(s1) = G_TRUNC %4(s32)
441 %5:_(s64) = G_LOAD %1(p0) :: (load (s64) from %ir.i64_ptr_a)
442 %6:_(s64) = G_LOAD %2(p0) :: (load (s64) from %ir.i64_ptr_b)
443 G_BRCOND %0(s1), %bb.2
452 %7:_(s64) = G_PHI %5(s64), %bb.2, %6(s64), %bb.3
453 G_STORE %7(s64), %3(p0) :: (store (s64) into %ir.i64_ptr_c)
460 tracksRegLiveness: true
462 ; MIPS32-LABEL: name: phi_float
463 ; MIPS32: bb.0.entry:
464 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
465 ; MIPS32: liveins: $a0, $a1, $a2
466 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
467 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
468 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2
469 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
470 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
471 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
473 ; MIPS32: bb.1.cond.true:
474 ; MIPS32: successors: %bb.3(0x80000000)
476 ; MIPS32: bb.2.cond.false:
477 ; MIPS32: successors: %bb.3(0x80000000)
478 ; MIPS32: bb.3.cond.end:
479 ; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[COPY1]](s32), %bb.1, [[COPY2]](s32), %bb.2
480 ; MIPS32: $f0 = COPY [[PHI]](s32)
481 ; MIPS32: RetRA implicit $f0
483 liveins: $a0, $a1, $a2
486 %0:_(s1) = G_TRUNC %3(s32)
489 G_BRCOND %0(s1), %bb.2
498 %4:_(s32) = G_PHI %1(s32), %bb.2, %2(s32), %bb.3
504 name: phi_ambiguous_float_in_gpr
506 tracksRegLiveness: true
508 ; MIPS32-LABEL: name: phi_ambiguous_float_in_gpr
509 ; MIPS32: bb.0.entry:
510 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
511 ; MIPS32: liveins: $a0, $a1, $a2, $a3
512 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
513 ; MIPS32: [[COPY1:%[0-9]+]]:_(p0) = COPY $a1
514 ; MIPS32: [[COPY2:%[0-9]+]]:_(p0) = COPY $a2
515 ; MIPS32: [[COPY3:%[0-9]+]]:_(p0) = COPY $a3
516 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY1]](p0) :: (load (s32) from %ir.f32_ptr_a)
517 ; MIPS32: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[COPY2]](p0) :: (load (s32) from %ir.f32_ptr_b)
518 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
519 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
520 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
522 ; MIPS32: bb.1.cond.true:
523 ; MIPS32: successors: %bb.3(0x80000000)
525 ; MIPS32: bb.2.cond.false:
526 ; MIPS32: successors: %bb.3(0x80000000)
527 ; MIPS32: bb.3.cond.end:
528 ; MIPS32: [[PHI:%[0-9]+]]:_(s32) = G_PHI [[LOAD]](s32), %bb.1, [[LOAD1]](s32), %bb.2
529 ; MIPS32: G_STORE [[PHI]](s32), [[COPY3]](p0) :: (store (s32) into %ir.f32_ptr_c)
532 liveins: $a0, $a1, $a2, $a3
535 %0:_(s1) = G_TRUNC %4(s32)
539 %5:_(s32) = G_LOAD %1(p0) :: (load (s32) from %ir.f32_ptr_a)
540 %6:_(s32) = G_LOAD %2(p0) :: (load (s32) from %ir.f32_ptr_b)
541 G_BRCOND %0(s1), %bb.2
550 %7:_(s32) = G_PHI %5(s32), %bb.2, %6(s32), %bb.3
551 G_STORE %7(s32), %3(p0) :: (store (s32) into %ir.f32_ptr_c)
558 tracksRegLiveness: true
560 - { id: 0, offset: 16, size: 4, alignment: 8, isImmutable: true }
562 ; MIPS32-LABEL: name: phi_double
563 ; MIPS32: bb.0.entry:
564 ; MIPS32: successors: %bb.1(0x40000000), %bb.2(0x40000000)
565 ; MIPS32: liveins: $d6, $d7
566 ; MIPS32: [[COPY:%[0-9]+]]:_(s64) = COPY $d6
567 ; MIPS32: [[COPY1:%[0-9]+]]:_(s64) = COPY $d7
568 ; MIPS32: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
569 ; MIPS32: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %fixed-stack.0, align 8)
570 ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
571 ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], [[C]]
572 ; MIPS32: G_BRCOND [[AND]](s32), %bb.1
574 ; MIPS32: bb.1.cond.true:
575 ; MIPS32: successors: %bb.3(0x80000000)
577 ; MIPS32: bb.2.cond.false:
578 ; MIPS32: successors: %bb.3(0x80000000)
579 ; MIPS32: bb.3.cond.end:
580 ; MIPS32: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[COPY]](s64), %bb.1, [[COPY1]](s64), %bb.2
581 ; MIPS32: $d0 = COPY [[PHI]](s64)
582 ; MIPS32: RetRA implicit $d0
588 %4:_(p0) = G_FRAME_INDEX %fixed-stack.0
589 %3:_(s32) = G_LOAD %4(p0) :: (load (s32) from %fixed-stack.0, align 8)
590 %2:_(s1) = G_TRUNC %3(s32)
591 G_BRCOND %2(s1), %bb.2
600 %5:_(s64) = G_PHI %0(s64), %bb.2, %1(s64), %bb.3