1 ; RUN: llc -march=x86-64 -print-machineinstrs=expand-isel-pseudos %s -o /dev/null 2>&1 | FileCheck %s
7 define void @test(i32 %x) nounwind {
9 switch i32 %x, label %sw.default [
16 i32 1134, label %sw.bb
17 i32 1140, label %sw.bb
31 ; Check if weights are correctly assigned to edges generated from switch
35 ; BB#0 to BB#4: [0, 1133] (65 = 60 + 5)
36 ; BB#0 to BB#5: [1134, UINT32_MAX] (25 = 20 + 5)
37 ; CHECK: Successors according to CFG: BB#4(1550960411) BB#5(596523235)
40 ; BB#4 to BB#1: [155, 159] (50)
41 ; BB#4 to BB#5: [0, 1133] - [155, 159] (15 = 10 + 5)
42 ; CHECK: Successors according to CFG: BB#1(1193046470) BB#7(357913941)
45 ; BB#5 to BB#1: {1140} (10)
46 ; BB#5 to BB#6: [1134, UINT32_MAX] - {1140} (15 = 10 + 5)
47 ; CHECK: Successors according to CFG: BB#1(238609294) BB#6(357913941)
50 ; BB#6 to BB#1: {1134} (10)
51 ; BB#6 to BB#2: [1134, UINT32_MAX] - {1134, 1140} (5)
52 ; CHECK: Successors according to CFG: BB#1(238609294) BB#2(119304647)
57 define void @test2(i32 %x) nounwind {
60 ; In this switch statement, there is an edge from jump table to default
63 switch i32 %x, label %sw.default [
99 ; Check if weights are correctly assigned to edges generated from switch
103 ; BB#0 to BB#6: {0} + [15, UINT32_MAX] (5)
104 ; BB#0 to BB#8: [1, 14] (jump table) (65 = 60 + 5)
105 ; CHECK: Successors according to CFG: BB#6(153391689) BB#8(1994091957)
108 ; BB#8 to BB#1: {1} (10)
109 ; BB#8 to BB#6: [2, 9] (5)
110 ; BB#8 to BB#2: {10} (10)
111 ; BB#8 to BB#3: {11} (10)
112 ; BB#8 to BB#4: {12} (10)
113 ; BB#8 to BB#5: {13, 14} (20)
114 ; CHECK: Successors according to CFG: BB#1(306783378) BB#6(153391689) BB#2(306783378) BB#3(306783378) BB#4(306783378) BB#5(613566756)
119 define void @test3(i32 %x) nounwind {
122 ; In this switch statement, there is no edge from jump table to default
125 switch i32 %x, label %sw.default [
127 i32 11, label %sw.bb2
128 i32 12, label %sw.bb3
129 i32 13, label %sw.bb4
130 i32 14, label %sw.bb5
134 call void @foo(i32 0)
138 call void @foo(i32 2)
142 call void @foo(i32 3)
146 call void @foo(i32 4)
150 call void @foo(i32 5)
154 call void @foo(i32 1)
160 ; Check if weights are correctly assigned to edges generated from switch
164 ; BB#0 to BB#6: [0, 9] + [15, UINT32_MAX] {10}
165 ; BB#0 to BB#8: [10, 14] (jump table) (50)
166 ; CHECK: Successors according to CFG: BB#6(357913941) BB#8(1789569705)
169 ; BB#8 to BB#1: {10} (10)
170 ; BB#8 to BB#2: {11} (10)
171 ; BB#8 to BB#3: {12} (10)
172 ; BB#8 to BB#4: {13} (10)
173 ; BB#8 to BB#5: {14} (10)
174 ; CHECK: Successors according to CFG: BB#1(357913941) BB#2(357913941) BB#3(357913941) BB#4(357913941) BB#5(357913941)
179 define void @test4(i32 %x) nounwind {
182 ; In this switch statement, there is no edge from bit test to default basic
185 switch i32 %x, label %sw.default [
187 i32 111, label %sw.bb2
188 i32 112, label %sw.bb3
189 i32 113, label %sw.bb3
190 i32 114, label %sw.bb2
191 i32 115, label %sw.bb2
195 call void @foo(i32 0)
199 call void @foo(i32 2)
203 call void @foo(i32 3)
207 call void @foo(i32 1)
213 ; Check if weights are correctly assigned to edges generated from switch
217 ; BB#0 to BB#6: [0, 110] + [116, UINT32_MAX] (20)
218 ; BB#0 to BB#7: [111, 115] (bit test) (50)
219 ; CHECK: Successors according to CFG: BB#6(613566756) BB#7(1533916890)
222 ; BB#7 to BB#2: {111, 114, 115} (30)
223 ; BB#7 to BB#3: {112, 113} (20)
224 ; CHECK: Successors according to CFG: BB#2(920350134) BB#3(613566756)
229 define void @test5(i32 %x) nounwind {
232 ; In this switch statement, there is an edge from jump table to default basic
235 switch i32 %x, label %sw.default [
240 i32 31, label %sw.bb5
244 call void @foo(i32 0)
248 call void @foo(i32 1)
252 call void @foo(i32 2)
256 call void @foo(i32 3)
260 call void @foo(i32 4)
264 call void @foo(i32 5)
270 ; Check if weights are correctly assigned to edges generated from switch
274 ; BB#0 to BB#6: [10, UINT32_MAX] (15)
275 ; BB#0 to BB#8: [1, 5, 7, 9] (jump table) (45)
276 ; CHECK: Successors according to CFG: BB#8(536870912) BB#9(1610612734)
279 !1 = !{!"branch_weights", i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10}
280 !2 = !{!"branch_weights", i32 10, i32 10, i32 10, i32 10, i32 10, i32 10}
281 !3 = !{!"branch_weights", i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10}