1 ; RUN: opt < %s -lowerswitch -S | FileCheck %s 2 3 ; We have switch on input. 4 ; On output we should got binary comparison tree. Check that all is fine. 5 6 ;CHECK: entry: 7 ;CHECK-NEXT: br label %NodeBlock19 8 9 ;CHECK: NodeBlock19: ; preds = %entry 10 ;CHECK-NEXT: %Pivot20 = icmp slt i32 %tmp158, 10 11 ;CHECK-NEXT: br i1 %Pivot20, label %NodeBlock5, label %NodeBlock17 12 13 ;CHECK: NodeBlock17: ; preds = %NodeBlock19 14 ;CHECK-NEXT: %Pivot18 = icmp slt i32 %tmp158, 13 15 ;CHECK-NEXT: br i1 %Pivot18, label %NodeBlock9, label %NodeBlock15 16 17 ;CHECK: NodeBlock15: ; preds = %NodeBlock17 18 ;CHECK-NEXT: %Pivot16 = icmp slt i32 %tmp158, 14 19 ;CHECK-NEXT: br i1 %Pivot16, label %bb330, label %NodeBlock13 20 21 ;CHECK: NodeBlock13: ; preds = %NodeBlock15 22 ;CHECK-NEXT: %Pivot14 = icmp slt i32 %tmp158, 15 23 ;CHECK-NEXT: br i1 %Pivot14, label %bb332, label %LeafBlock11 24 25 ;CHECK: LeafBlock11: ; preds = %NodeBlock13 26 ;CHECK-NEXT: %SwitchLeaf12 = icmp eq i32 %tmp158, 15 27 ;CHECK-NEXT: br i1 %SwitchLeaf12, label %bb334, label %NewDefault 28 29 ;CHECK: NodeBlock9: ; preds = %NodeBlock17 30 ;CHECK-NEXT: %Pivot10 = icmp slt i32 %tmp158, 11 31 ;CHECK-NEXT: br i1 %Pivot10, label %bb324, label %NodeBlock7 32 33 ;CHECK: NodeBlock7: ; preds = %NodeBlock9 34 ;CHECK-NEXT: %Pivot8 = icmp slt i32 %tmp158, 12 35 ;CHECK-NEXT: br i1 %Pivot8, label %bb326, label %bb328 36 37 ;CHECK: NodeBlock5: ; preds = %NodeBlock19 38 ;CHECK-NEXT: %Pivot6 = icmp slt i32 %tmp158, 7 39 ;CHECK-NEXT: br i1 %Pivot6, label %NodeBlock, label %NodeBlock3 40 41 ;CHECK: NodeBlock3: ; preds = %NodeBlock5 42 ;CHECK-NEXT: %Pivot4 = icmp slt i32 %tmp158, 8 43 ;CHECK-NEXT: br i1 %Pivot4, label %bb, label %NodeBlock1 44 45 ;CHECK: NodeBlock1: ; preds = %NodeBlock3 46 ;CHECK-NEXT: %Pivot2 = icmp slt i32 %tmp158, 9 47 ;CHECK-NEXT: br i1 %Pivot2, label %bb338, label %bb322 48 49 ;CHECK: NodeBlock: ; preds = %NodeBlock5 50 ;CHECK-NEXT: %Pivot = icmp slt i32 %tmp158, 0 51 ;CHECK-NEXT: br i1 %Pivot, label %LeafBlock, label %bb338 52 53 ;CHECK: LeafBlock: ; preds = %NodeBlock 54 ;CHECK-NEXT: %tmp158.off = add i32 %tmp158, 6 55 ;CHECK-NEXT: %SwitchLeaf = icmp ule i32 %tmp158.off, 4 56 ;CHECK-NEXT: br i1 %SwitchLeaf, label %bb338, label %NewDefault 57 58 define i32 @main(i32 %tmp158) { 59 entry: 60 61 switch i32 %tmp158, label %bb336 [ 62 i32 -2, label %bb338 63 i32 -3, label %bb338 64 i32 -4, label %bb338 65 i32 -5, label %bb338 66 i32 -6, label %bb338 67 i32 0, label %bb338 68 i32 1, label %bb338 69 i32 2, label %bb338 70 i32 3, label %bb338 71 i32 4, label %bb338 72 i32 5, label %bb338 73 i32 6, label %bb338 74 i32 7, label %bb 75 i32 8, label %bb338 76 i32 9, label %bb322 77 i32 10, label %bb324 78 i32 11, label %bb326 79 i32 12, label %bb328 80 i32 13, label %bb330 81 i32 14, label %bb332 82 i32 15, label %bb334 83 ] 84 bb: 85 ret i32 2 86 bb322: 87 ret i32 3 88 bb324: 89 ret i32 4 90 bb326: 91 ret i32 5 92 bb328: 93 ret i32 6 94 bb330: 95 ret i32 7 96 bb332: 97 ret i32 8 98 bb334: 99 ret i32 9 100 bb336: 101 ret i32 10 102 bb338: 103 ret i32 11 104 } 105