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(i32 %Value, i1 %PredEntry, 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 label [[NODEBLOCK:%.*]]
14 ; CHECK-NEXT: [[PIVOT:%.*]] = icmp slt i32 [[VALUE:%.*]], 1
15 ; CHECK-NEXT: br i1 [[PIVOT]], label [[LEAFBLOCK:%.*]], label [[LEAFBLOCK1:%.*]]
17 ; CHECK-NEXT: [[SWITCHLEAF2:%.*]] = icmp eq i32 [[VALUE]], 1
18 ; CHECK-NEXT: br i1 [[SWITCHLEAF2]], label [[D:%.*]], label [[LOOP_EXIT_GUARD:%.*]]
20 ; CHECK-NEXT: [[SWITCHLEAF:%.*]] = icmp eq i32 [[VALUE]], 0
21 ; CHECK-NEXT: br i1 [[SWITCHLEAF]], label [[C:%.*]], label [[LOOP_EXIT_GUARD]]
23 ; CHECK-NEXT: br label [[D]]
25 ; CHECK-NEXT: br i1 [[PREDD:%.*]], label [[A]], label [[LOOP_EXIT_GUARD]]
27 ; CHECK-NEXT: br label [[X:%.*]]
29 ; CHECK-NEXT: br label [[EXIT:%.*]]
31 ; CHECK-NEXT: br label [[EXIT]]
33 ; CHECK-NEXT: br label [[EXIT]]
35 ; CHECK-NEXT: ret void
36 ; CHECK: loop.exit.guard:
37 ; CHECK-NEXT: [[GUARD_NEWDEFAULT:%.*]] = phi i1 [ true, [[LEAFBLOCK1]] ], [ true, [[LEAFBLOCK]] ], [ false, [[D]] ]
38 ; CHECK-NEXT: br i1 [[GUARD_NEWDEFAULT]], label [[NEWDEFAULT:%.*]], label [[Y:%.*]]
41 br i1 %PredEntry, label %A, label %G
47 switch i32 %Value, label %X [
56 br i1 %PredD, label %A, label %Y