1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -unify-loop-exits -enable-new-pm=0 -S | FileCheck %s
3 ; RUN: opt < %s -passes='lowerswitch,unify-loop-exits' -S | FileCheck %s
5 define void @nested(i1 %PredB3, i1 %PredB4, i1 %PredA4, i1 %PredA3, i32 %X, i32 %Y, i32 %Z) {
6 ; CHECK-LABEL: @nested(
8 ; CHECK-NEXT: br label [[A1:%.*]]
10 ; CHECK-NEXT: br label [[B1:%.*]]
12 ; CHECK-NEXT: br label [[B2:%.*]]
14 ; CHECK-NEXT: [[X_INC:%.*]] = add i32 [[X:%.*]], 1
15 ; CHECK-NEXT: br label [[B3:%.*]]
17 ; CHECK-NEXT: br i1 [[PREDB3:%.*]], label [[B4:%.*]], label [[LOOP_EXIT_GUARD1:%.*]]
19 ; CHECK-NEXT: br i1 [[PREDB4:%.*]], label [[B1]], label [[LOOP_EXIT_GUARD1]]
21 ; CHECK-NEXT: br label [[A4:%.*]]
23 ; CHECK-NEXT: br label [[A4]]
25 ; CHECK-NEXT: [[A4_PHI:%.*]] = phi i32 [ [[Y:%.*]], [[A3:%.*]] ], [ [[X_INC_MOVED:%.*]], [[A2:%.*]] ]
26 ; CHECK-NEXT: br i1 [[PREDA4:%.*]], label [[LOOP_EXIT_GUARD:%.*]], label [[A5:%.*]]
28 ; CHECK-NEXT: br i1 [[PREDA3:%.*]], label [[LOOP_EXIT_GUARD]], label [[A1]]
30 ; CHECK-NEXT: br label [[EXIT:%.*]]
32 ; CHECK-NEXT: [[EXIT_PHI:%.*]] = phi i32 [ [[Z:%.*]], [[C:%.*]] ], [ [[EXIT_PHI_MOVED:%.*]], [[LOOP_EXIT_GUARD]] ]
33 ; CHECK-NEXT: ret void
34 ; CHECK: loop.exit.guard:
35 ; CHECK-NEXT: [[GUARD_C:%.*]] = phi i1 [ true, [[A4]] ], [ false, [[A5]] ]
36 ; CHECK-NEXT: [[EXIT_PHI_MOVED]] = phi i32 [ undef, [[A4]] ], [ [[A4_PHI]], [[A5]] ]
37 ; CHECK-NEXT: br i1 [[GUARD_C]], label [[C]], label [[EXIT]]
38 ; CHECK: loop.exit.guard1:
39 ; CHECK-NEXT: [[GUARD_A3:%.*]] = phi i1 [ true, [[B3]] ], [ false, [[B4]] ]
40 ; CHECK-NEXT: [[X_INC_MOVED]] = phi i32 [ [[X_INC]], [[B3]] ], [ [[X_INC]], [[B4]] ]
41 ; CHECK-NEXT: br i1 [[GUARD_A3]], label [[A3]], label [[A2]]
53 %X.inc = add i32 %X, 1
57 br i1 %PredB3, label %B4, label %A3
60 br i1 %PredB4, label %B1, label %A2
69 %A4.phi = phi i32 [%Y, %A3], [%X.inc, %A2]
70 br i1 %PredA4, label %C, label %A5
73 br i1 %PredA3, label %exit, label %A1
79 %exit.phi = phi i32 [%A4.phi, %A5], [%Z, %C]