1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes='lowerswitch,unify-loop-exits' -S | FileCheck %s
4 define void @loop_1(i32 %Value, i1 %PredEntry, 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 label [[NODEBLOCK:%.*]]
13 ; CHECK-NEXT: [[PIVOT:%.*]] = icmp slt i32 [[VALUE:%.*]], 1
14 ; CHECK-NEXT: br i1 [[PIVOT]], label [[LEAFBLOCK:%.*]], label [[LEAFBLOCK1:%.*]]
16 ; CHECK-NEXT: [[SWITCHLEAF2:%.*]] = icmp eq i32 [[VALUE]], 1
17 ; CHECK-NEXT: br i1 [[SWITCHLEAF2]], label [[D:%.*]], label [[LOOP_EXIT_GUARD:%.*]]
19 ; CHECK-NEXT: [[SWITCHLEAF:%.*]] = icmp eq i32 [[VALUE]], 0
20 ; CHECK-NEXT: br i1 [[SWITCHLEAF]], label [[C:%.*]], label [[LOOP_EXIT_GUARD]]
22 ; CHECK-NEXT: br label [[D]]
24 ; CHECK-NEXT: br i1 [[PREDD:%.*]], label [[A]], label [[LOOP_EXIT_GUARD]]
26 ; CHECK-NEXT: br label [[EXIT:%.*]]
28 ; CHECK-NEXT: br label [[EXIT]]
30 ; CHECK-NEXT: br label [[EXIT]]
32 ; CHECK-NEXT: ret void
33 ; CHECK: loop.exit.guard:
34 ; CHECK-NEXT: [[GUARD_X:%.*]] = phi i1 [ true, [[LEAFBLOCK1]] ], [ true, [[LEAFBLOCK]] ], [ false, [[D]] ]
35 ; CHECK-NEXT: br i1 [[GUARD_X]], label [[X:%.*]], label [[Y:%.*]]
38 br i1 %PredEntry, label %A, label %G
44 switch i32 %Value, label %X [
53 br i1 %PredD, label %A, label %Y