1 ; RUN: opt < %s -lowerswitch -S | FileCheck %s
2 ; RUN: opt < %s -passes=lowerswitch -S | FileCheck %s
4 ; We have switch on input.
5 ; On output we should got binary comparison tree. Check that all is fine.
8 ;CHECK-NEXT: br label %NodeBlock19
10 ;CHECK: NodeBlock19: ; preds = %entry
11 ;CHECK-NEXT: %Pivot20 = icmp slt i32 %tmp158, 10
12 ;CHECK-NEXT: br i1 %Pivot20, label %NodeBlock5, label %NodeBlock17
14 ;CHECK: NodeBlock17: ; preds = %NodeBlock19
15 ;CHECK-NEXT: %Pivot18 = icmp slt i32 %tmp158, 13
16 ;CHECK-NEXT: br i1 %Pivot18, label %NodeBlock9, label %NodeBlock15
18 ;CHECK: NodeBlock15: ; preds = %NodeBlock17
19 ;CHECK-NEXT: %Pivot16 = icmp slt i32 %tmp158, 14
20 ;CHECK-NEXT: br i1 %Pivot16, label %bb330, label %NodeBlock13
22 ;CHECK: NodeBlock13: ; preds = %NodeBlock15
23 ;CHECK-NEXT: %Pivot14 = icmp slt i32 %tmp158, 15
24 ;CHECK-NEXT: br i1 %Pivot14, label %bb332, label %LeafBlock11
26 ;CHECK: LeafBlock11: ; preds = %NodeBlock13
27 ;CHECK-NEXT: %SwitchLeaf12 = icmp eq i32 %tmp158, 15
28 ;CHECK-NEXT: br i1 %SwitchLeaf12, label %bb334, label %NewDefault
30 ;CHECK: NodeBlock9: ; preds = %NodeBlock17
31 ;CHECK-NEXT: %Pivot10 = icmp slt i32 %tmp158, 11
32 ;CHECK-NEXT: br i1 %Pivot10, label %bb324, label %NodeBlock7
34 ;CHECK: NodeBlock7: ; preds = %NodeBlock9
35 ;CHECK-NEXT: %Pivot8 = icmp slt i32 %tmp158, 12
36 ;CHECK-NEXT: br i1 %Pivot8, label %bb326, label %bb328
38 ;CHECK: NodeBlock5: ; preds = %NodeBlock19
39 ;CHECK-NEXT: %Pivot6 = icmp slt i32 %tmp158, 7
40 ;CHECK-NEXT: br i1 %Pivot6, label %NodeBlock, label %NodeBlock3
42 ;CHECK: NodeBlock3: ; preds = %NodeBlock5
43 ;CHECK-NEXT: %Pivot4 = icmp slt i32 %tmp158, 8
44 ;CHECK-NEXT: br i1 %Pivot4, label %bb, label %NodeBlock1
46 ;CHECK: NodeBlock1: ; preds = %NodeBlock3
47 ;CHECK-NEXT: %Pivot2 = icmp slt i32 %tmp158, 9
48 ;CHECK-NEXT: br i1 %Pivot2, label %bb338, label %bb322
50 ;CHECK: NodeBlock: ; preds = %NodeBlock5
51 ;CHECK-NEXT: %Pivot = icmp slt i32 %tmp158, 0
52 ;CHECK-NEXT: br i1 %Pivot, label %LeafBlock, label %bb338
54 ;CHECK: LeafBlock: ; preds = %NodeBlock
55 ;CHECK-NEXT: %tmp158.off = add i32 %tmp158, 6
56 ;CHECK-NEXT: %SwitchLeaf = icmp ule i32 %tmp158.off, 4
57 ;CHECK-NEXT: br i1 %SwitchLeaf, label %bb338, label %NewDefault
59 define i32 @main(i32 %tmp158) {
62 switch i32 %tmp158, label %bb336 [