1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes='lower-switch,unify-loop-exits' -S | FileCheck %s
4 define void @nested(i1 %PredB3, i1 %PredB4, i1 %PredA4, i1 %PredA3, i32 %X, i32 %Y, i32 %Z) {
5 ; CHECK-LABEL: @nested(
7 ; CHECK-NEXT: br label [[A1:%.*]]
9 ; CHECK-NEXT: br label [[B1:%.*]]
11 ; CHECK-NEXT: br label [[B2:%.*]]
13 ; CHECK-NEXT: [[X_INC:%.*]] = add i32 [[X:%.*]], 1
14 ; CHECK-NEXT: br label [[B3:%.*]]
16 ; CHECK-NEXT: br i1 [[PREDB3:%.*]], label [[B4:%.*]], label [[LOOP_EXIT_GUARD1:%.*]]
18 ; CHECK-NEXT: br i1 [[PREDB4:%.*]], label [[B1]], label [[LOOP_EXIT_GUARD1]]
20 ; CHECK-NEXT: br label [[A4:%.*]]
22 ; CHECK-NEXT: br label [[A4]]
24 ; CHECK-NEXT: [[A4_PHI:%.*]] = phi i32 [ [[Y:%.*]], [[A3:%.*]] ], [ [[X_INC_MOVED:%.*]], [[A2:%.*]] ]
25 ; CHECK-NEXT: br i1 [[PREDA4:%.*]], label [[LOOP_EXIT_GUARD:%.*]], label [[A5:%.*]]
27 ; CHECK-NEXT: br i1 [[PREDA3:%.*]], label [[LOOP_EXIT_GUARD]], label [[A1]]
29 ; CHECK-NEXT: br label [[EXIT:%.*]]
31 ; CHECK-NEXT: [[EXIT_PHI:%.*]] = phi i32 [ [[Z:%.*]], [[C:%.*]] ], [ [[EXIT_PHI_MOVED:%.*]], [[LOOP_EXIT_GUARD]] ]
32 ; CHECK-NEXT: ret void
33 ; CHECK: loop.exit.guard:
34 ; CHECK-NEXT: [[EXIT_PHI_MOVED]] = phi i32 [ undef, [[A4]] ], [ [[A4_PHI]], [[A5]] ]
35 ; CHECK-NEXT: [[GUARD_C:%.*]] = phi i1 [ true, [[A4]] ], [ false, [[A5]] ]
36 ; CHECK-NEXT: br i1 [[GUARD_C]], label [[C]], label [[EXIT]]
37 ; CHECK: loop.exit.guard1:
38 ; CHECK-NEXT: [[X_INC_MOVED]] = phi i32 [ [[X_INC]], [[B3]] ], [ [[X_INC]], [[B4]] ]
39 ; CHECK-NEXT: [[GUARD_A3:%.*]] = phi i1 [ true, [[B3]] ], [ false, [[B4]] ]
40 ; CHECK-NEXT: br i1 [[GUARD_A3]], label [[A3]], label [[A2]]
52 %X.inc = add i32 %X, 1
56 br i1 %PredB3, label %B4, label %A3
59 br i1 %PredB4, label %B1, label %A2
68 %A4.phi = phi i32 [%Y, %A3], [%X.inc, %A2]
69 br i1 %PredA4, label %C, label %A5
72 br i1 %PredA3, label %exit, label %A1
78 %exit.phi = phi i32 [%A4.phi, %A5], [%Z, %C]