1 ; RUN: llc -mtriple=x86_64-linux-gnu %s -o - -jump-table-density=25 | FileCheck %s --check-prefix=DENSE --check-prefix=CHECK
2 ; RUN: llc -mtriple=x86_64-linux-gnu %s -o - -jump-table-density=10 | FileCheck %s --check-prefix=SPARSE --check-prefix=CHECK
6 define void @sparse(i32 %x) {
8 switch i32 %x, label %return [
14 bb0: tail call void @g(i32 0) br label %return
15 bb1: tail call void @g(i32 1) br label %return
16 bb2: tail call void @g(i32 1) br label %return
19 ; Should pivot around 400 for two subtrees with two jump tables each.
29 define void @med(i32 %x) {
31 switch i32 %x, label %return [
38 bb0: tail call void @g(i32 0) br label %return
39 bb1: tail call void @g(i32 1) br label %return
40 bb2: tail call void @g(i32 1) br label %return
41 bb3: tail call void @g(i32 2) br label %return
44 ; Lowered as a jump table when sparse, and branches when dense.
60 define void @dense(i32 %x) {
62 switch i32 %x, label %return [
69 bb0: tail call void @g(i32 0) br label %return
70 bb1: tail call void @g(i32 1) br label %return
71 bb2: tail call void @g(i32 1) br label %return
72 bb3: tail call void @g(i32 2) br label %return
75 ; Lowered as a jump table when sparse, and branches when dense.
83 define void @dense_optsize(i32 %x) optsize {
85 switch i32 %x, label %return [
92 bb0: tail call void @g(i32 0) br label %return
93 bb1: tail call void @g(i32 1) br label %return
94 bb2: tail call void @g(i32 1) br label %return
95 bb3: tail call void @g(i32 2) br label %return
98 ; Lowered as branches.
99 ; CHECK-LABEL: dense_optsize
109 define void @dense_pgso(i32 %x) !prof !14 {
111 switch i32 %x, label %return [
118 bb0: tail call void @g(i32 0) br label %return
119 bb1: tail call void @g(i32 1) br label %return
120 bb2: tail call void @g(i32 1) br label %return
121 bb3: tail call void @g(i32 2) br label %return
124 ; Lowered as branches.
125 ; CHECK-LABEL: dense_pgso
135 !llvm.module.flags = !{!0}
136 !0 = !{i32 1, !"ProfileSummary", !1}
137 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
138 !2 = !{!"ProfileFormat", !"InstrProf"}
139 !3 = !{!"TotalCount", i64 10000}
140 !4 = !{!"MaxCount", i64 10}
141 !5 = !{!"MaxInternalCount", i64 1}
142 !6 = !{!"MaxFunctionCount", i64 1000}
143 !7 = !{!"NumCounts", i64 3}
144 !8 = !{!"NumFunctions", i64 3}
145 !9 = !{!"DetailedSummary", !10}
146 !10 = !{!11, !12, !13}
147 !11 = !{i32 10000, i64 100, i32 1}
148 !12 = !{i32 999000, i64 100, i32 1}
149 !13 = !{i32 999999, i64 1, i32 2}
150 !14 = !{!"function_entry_count", i64 0}