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 @loop_1(i1 %PredEntry, i1 %PredB, i1 %PredC, i1 %PredD) {
5 ; CHECK-LABEL: @loop_1(
7 ; CHECK-NEXT: br i1 [[PREDENTRY:%.*]], label [[A:%.*]], label [[G:%.*]]
9 ; CHECK-NEXT: br label [[B:%.*]]
11 ; CHECK-NEXT: br i1 [[PREDB:%.*]], label [[C:%.*]], label [[LOOP_EXIT_GUARD:%.*]]
13 ; CHECK-NEXT: br i1 [[PREDC:%.*]], label [[D:%.*]], label [[LOOP_EXIT_GUARD]]
15 ; CHECK-NEXT: br i1 [[PREDD:%.*]], label [[A]], label [[LOOP_EXIT_GUARD]]
17 ; CHECK-NEXT: br label [[EXIT:%.*]]
19 ; CHECK-NEXT: br label [[EXIT]]
21 ; CHECK-NEXT: br label [[F:%.*]]
23 ; CHECK-NEXT: ret void
24 ; CHECK: loop.exit.guard:
25 ; CHECK-NEXT: [[GUARD_E:%.*]] = phi i1 [ true, [[B]] ], [ false, [[C]] ], [ false, [[D]] ]
26 ; CHECK-NEXT: br i1 [[GUARD_E]], label [[E:%.*]], label [[F]]
29 br i1 %PredEntry, label %A, label %G
35 br i1 %PredB, label %C, label %E
38 br i1 %PredC, label %D, label %F
41 br i1 %PredD, label %A, label %F
56 define void @loop_2(i1 %PredA, i1 %PredB, i1 %PredC) {
57 ; CHECK-LABEL: @loop_2(
59 ; CHECK-NEXT: br label [[A:%.*]]
61 ; CHECK-NEXT: br i1 [[PREDA:%.*]], label [[B:%.*]], label [[LOOP_EXIT_GUARD:%.*]]
63 ; CHECK-NEXT: br i1 [[PREDB:%.*]], label [[C:%.*]], label [[LOOP_EXIT_GUARD]]
65 ; CHECK-NEXT: br i1 [[PREDC:%.*]], label [[D:%.*]], label [[LOOP_EXIT_GUARD]]
67 ; CHECK-NEXT: br label [[A]]
69 ; CHECK-NEXT: br label [[EXIT:%.*]]
71 ; CHECK-NEXT: br label [[EXIT]]
73 ; CHECK-NEXT: br label [[EXIT]]
75 ; CHECK-NEXT: ret void
76 ; CHECK: loop.exit.guard:
77 ; CHECK-NEXT: [[GUARD_X:%.*]] = phi i1 [ true, [[A]] ], [ false, [[B]] ], [ false, [[C]] ]
78 ; CHECK-NEXT: [[GUARD_Y:%.*]] = phi i1 [ false, [[A]] ], [ true, [[B]] ], [ false, [[C]] ]
79 ; CHECK-NEXT: br i1 [[GUARD_X]], label [[X:%.*]], label [[LOOP_EXIT_GUARD1:%.*]]
80 ; CHECK: loop.exit.guard1:
81 ; CHECK-NEXT: br i1 [[GUARD_Y]], label [[Y:%.*]], label [[Z:%.*]]
87 br i1 %PredA, label %B, label %X
90 br i1 %PredB, label %C, label %Y
93 br i1 %PredC, label %D, label %Z