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 %NodeBlock37 8 9 ;CHECK: NodeBlock37: ; preds = %entry 10 ;CHECK-NEXT: %Pivot38 = icmp ult i32 %tmp158, 11 11 ;CHECK-NEXT: br i1 %Pivot38, label %NodeBlock13, label %NodeBlock35 12 13 ;CHECK: NodeBlock35: ; preds = %NodeBlock37 14 ;CHECK-NEXT: %Pivot36 = icmp ult i32 %tmp158, 14 15 ;CHECK-NEXT: br i1 %Pivot36, label %NodeBlock23, label %NodeBlock33 16 17 ;CHECK: NodeBlock33: ; preds = %NodeBlock35 18 ;CHECK-NEXT: %Pivot34 = icmp ult i32 %tmp158, 15 19 ;CHECK-NEXT: br i1 %Pivot34, label %LeafBlock25, label %NodeBlock31 20 21 ;CHECK: NodeBlock31: ; preds = %NodeBlock33 22 ;CHECK-NEXT: %Pivot32 = icmp ult i32 %tmp158, -6 23 ;CHECK-NEXT: br i1 %Pivot32, label %LeafBlock27, label %LeafBlock29 24 25 ;CHECK: LeafBlock29: ; preds = %NodeBlock31 26 ;CHECK-NEXT: %tmp158.off = add i32 %tmp158, 6 27 ;CHECK-NEXT: %SwitchLeaf30 = icmp ule i32 %tmp158.off, 4 28 ;CHECK-NEXT: br i1 %SwitchLeaf30, label %bb338, label %NewDefault 29 30 ;CHECK: LeafBlock27: ; preds = %NodeBlock31 31 ;CHECK-NEXT: %SwitchLeaf28 = icmp eq i32 %tmp158, 15 32 ;CHECK-NEXT: br i1 %SwitchLeaf28, label %bb334, label %NewDefault 33 34 ;CHECK: LeafBlock25: ; preds = %NodeBlock33 35 ;CHECK-NEXT: %SwitchLeaf26 = icmp eq i32 %tmp158, 14 36 ;CHECK-NEXT: br i1 %SwitchLeaf26, label %bb332, label %NewDefault 37 38 ;CHECK: NodeBlock23: ; preds = %NodeBlock35 39 ;CHECK-NEXT: %Pivot24 = icmp ult i32 %tmp158, 12 40 ;CHECK-NEXT: br i1 %Pivot24, label %LeafBlock15, label %NodeBlock21 41 42 ;CHECK: NodeBlock21: ; preds = %NodeBlock23 43 ;CHECK-NEXT: %Pivot22 = icmp ult i32 %tmp158, 13 44 ;CHECK-NEXT: br i1 %Pivot22, label %LeafBlock17, label %LeafBlock19 45 46 ;CHECK: LeafBlock19: ; preds = %NodeBlock21 47 ;CHECK-NEXT: %SwitchLeaf20 = icmp eq i32 %tmp158, 13 48 ;CHECK-NEXT: br i1 %SwitchLeaf20, label %bb330, label %NewDefault 49 50 ;CHECK: LeafBlock17: ; preds = %NodeBlock21 51 ;CHECK-NEXT: %SwitchLeaf18 = icmp eq i32 %tmp158, 12 52 ;CHECK-NEXT: br i1 %SwitchLeaf18, label %bb328, label %NewDefault 53 54 ;CHECK: LeafBlock15: ; preds = %NodeBlock23 55 ;CHECK-NEXT: %SwitchLeaf16 = icmp eq i32 %tmp158, 11 56 ;CHECK-NEXT: br i1 %SwitchLeaf16, label %bb326, label %NewDefault 57 58 ;CHECK: NodeBlock13: ; preds = %NodeBlock37 59 ;CHECK-NEXT: %Pivot14 = icmp ult i32 %tmp158, 8 60 ;CHECK-NEXT: br i1 %Pivot14, label %NodeBlock, label %NodeBlock11 61 62 ;CHECK: NodeBlock11: ; preds = %NodeBlock13 63 ;CHECK-NEXT: %Pivot12 = icmp ult i32 %tmp158, 9 64 ;CHECK-NEXT: br i1 %Pivot12, label %LeafBlock3, label %NodeBlock9 65 66 ;CHECK: NodeBlock9: ; preds = %NodeBlock11 67 ;CHECK-NEXT: %Pivot10 = icmp ult i32 %tmp158, 10 68 ;CHECK-NEXT: br i1 %Pivot10, label %LeafBlock5, label %LeafBlock7 69 70 ;CHECK: LeafBlock7: ; preds = %NodeBlock9 71 ;CHECK-NEXT: %SwitchLeaf8 = icmp eq i32 %tmp158, 10 72 ;CHECK-NEXT: br i1 %SwitchLeaf8, label %bb324, label %NewDefault 73 74 ;CHECK: LeafBlock5: ; preds = %NodeBlock9 75 ;CHECK-NEXT: %SwitchLeaf6 = icmp eq i32 %tmp158, 9 76 ;CHECK-NEXT: br i1 %SwitchLeaf6, label %bb322, label %NewDefault 77 78 ;CHECK: LeafBlock3: ; preds = %NodeBlock11 79 ;CHECK-NEXT: %SwitchLeaf4 = icmp eq i32 %tmp158, 8 80 ;CHECK-NEXT: br i1 %SwitchLeaf4, label %bb338, label %NewDefault 81 82 ;CHECK: NodeBlock: ; preds = %NodeBlock13 83 ;CHECK-NEXT: %Pivot = icmp ult i32 %tmp158, 7 84 ;CHECK-NEXT: br i1 %Pivot, label %LeafBlock, label %LeafBlock1 85 86 ;CHECK: LeafBlock1: ; preds = %NodeBlock 87 ;CHECK-NEXT: %SwitchLeaf2 = icmp eq i32 %tmp158, 7 88 ;CHECK-NEXT: br i1 %SwitchLeaf2, label %bb, label %NewDefault 89 90 ;CHECK: LeafBlock: ; preds = %NodeBlock 91 ;CHECK-NEXT: %SwitchLeaf = icmp ule i32 %tmp158, 6 92 ;CHECK-NEXT: br i1 %SwitchLeaf, label %bb338, label %NewDefault 93 94 define i32 @main(i32 %tmp158) { 95 entry: 96 97 switch i32 %tmp158, label %bb336 [ 98 i32 -2, label %bb338 99 i32 -3, label %bb338 100 i32 -4, label %bb338 101 i32 -5, label %bb338 102 i32 -6, label %bb338 103 i32 0, label %bb338 104 i32 1, label %bb338 105 i32 2, label %bb338 106 i32 3, label %bb338 107 i32 4, label %bb338 108 i32 5, label %bb338 109 i32 6, label %bb338 110 i32 7, label %bb 111 i32 8, label %bb338 112 i32 9, label %bb322 113 i32 10, label %bb324 114 i32 11, label %bb326 115 i32 12, label %bb328 116 i32 13, label %bb330 117 i32 14, label %bb332 118 i32 15, label %bb334 119 ] 120 bb: 121 ret i32 2 122 bb322: 123 ret i32 3 124 bb324: 125 ret i32 4 126 bb326: 127 ret i32 5 128 bb328: 129 ret i32 6 130 bb330: 131 ret i32 7 132 bb332: 133 ret i32 8 134 bb334: 135 ret i32 9 136 bb336: 137 ret i32 10 138 bb338: 139 ret i32 11 140 } 141