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 @loop_1(i1 %PredEntry, i1 %PredB, i1 %PredC, i1 %PredD) {
6 ; CHECK-LABEL: @loop_1(
8 ; CHECK-NEXT: br i1 [[PREDENTRY:%.*]], label [[A:%.*]], label [[G:%.*]]
10 ; CHECK-NEXT: br label [[B:%.*]]
12 ; CHECK-NEXT: br i1 [[PREDB:%.*]], label [[C:%.*]], label [[LOOP_EXIT_GUARD:%.*]]
14 ; CHECK-NEXT: br i1 [[PREDC:%.*]], label [[D:%.*]], label [[LOOP_EXIT_GUARD]]
16 ; CHECK-NEXT: br i1 [[PREDD:%.*]], label [[A]], label [[LOOP_EXIT_GUARD]]
18 ; CHECK-NEXT: br label [[EXIT:%.*]]
20 ; CHECK-NEXT: br label [[EXIT]]
22 ; CHECK-NEXT: br label [[F:%.*]]
24 ; CHECK-NEXT: ret void
25 ; CHECK: loop.exit.guard:
26 ; CHECK-NEXT: [[GUARD_E:%.*]] = phi i1 [ true, [[B]] ], [ false, [[C]] ], [ false, [[D]] ]
27 ; CHECK-NEXT: br i1 [[GUARD_E]], label [[E:%.*]], label [[F]]
30 br i1 %PredEntry, label %A, label %G
36 br i1 %PredB, label %C, label %E
39 br i1 %PredC, label %D, label %F
42 br i1 %PredD, label %A, label %F
57 define void @loop_2(i1 %PredA, i1 %PredB, i1 %PredC) {
58 ; CHECK-LABEL: @loop_2(
60 ; CHECK-NEXT: br label [[A:%.*]]
62 ; CHECK-NEXT: br i1 [[PREDA:%.*]], label [[B:%.*]], label [[LOOP_EXIT_GUARD:%.*]]
64 ; CHECK-NEXT: br i1 [[PREDB:%.*]], label [[C:%.*]], label [[LOOP_EXIT_GUARD]]
66 ; CHECK-NEXT: br i1 [[PREDC:%.*]], label [[D:%.*]], label [[LOOP_EXIT_GUARD]]
68 ; CHECK-NEXT: br label [[A]]
70 ; CHECK-NEXT: br label [[EXIT:%.*]]
72 ; CHECK-NEXT: br label [[EXIT]]
74 ; CHECK-NEXT: br label [[EXIT]]
76 ; CHECK-NEXT: ret void
77 ; CHECK: loop.exit.guard:
78 ; CHECK-NEXT: [[GUARD_X:%.*]] = phi i1 [ true, [[A]] ], [ false, [[B]] ], [ false, [[C]] ]
79 ; CHECK-NEXT: [[GUARD_Y:%.*]] = phi i1 [ false, [[A]] ], [ true, [[B]] ], [ false, [[C]] ]
80 ; CHECK-NEXT: br i1 [[GUARD_X]], label [[X:%.*]], label [[LOOP_EXIT_GUARD1:%.*]]
81 ; CHECK: loop.exit.guard1:
82 ; CHECK-NEXT: br i1 [[GUARD_Y]], label [[Y:%.*]], label [[Z:%.*]]
88 br i1 %PredA, label %B, label %X
91 br i1 %PredB, label %C, label %Y
94 br i1 %PredC, label %D, label %Z