1 ; RUN: llc -mtriple=x86_64-linux-gnu -stop-after=finalize-isel < %s | FileCheck %s
3 define i32 @foo(i32 %n) !prof !1 {
5 switch i32 %n, label %bb_default [
13 ; CHECK: successors: %[[PEELED_CASE_LABEL:.*]](0x5999999a), %[[PEELED_SWITCH_LABEL:.*]](0x26666666)
14 ; CHECK: %[[VAL:[0-9]+]]:gr32 = COPY $edi
15 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 18568, implicit-def $eflags
16 ; CHECK: JCC_1 %[[PEELED_CASE_LABEL]], 4, implicit $eflags
17 ; CHECK: JMP_1 %[[PEELED_SWITCH_LABEL]]
18 ; CHECK: [[PEELED_SWITCH_LABEL]].{{[a-zA-Z0-9.]+}}:
19 ; CHECK: successors: %[[BB1_LABEL:.*]](0x0206d3a0), %[[BB2_LABEL:.*]](0x7df92c60)
20 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 18311, implicit-def $eflags
21 ; CHECK: JCC_1 %[[BB2_LABEL]], 15, implicit $eflags
22 ; CHECK: JMP_1 %[[BB1_LABEL]]
23 ; CHECK: [[BB1_LABEL]].{{[a-zA-Z0-9.]+}}:
24 ; CHECK: successors: %[[CASE2_LABEL:.*]](0x35e50d5b), %[[BB3_LABEL:.*]](0x4a1af2a5)
25 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], -8826, implicit-def $eflags
26 ; CHECK: JCC_1 %[[CASE2_LABEL]], 4, implicit $eflags
27 ; CHECK: JMP_1 %[[BB3_LABEL]]
28 ; CHECK: [[BB3_LABEL]]
29 ; CHECK: successors: %[[CASE5_LABEL:.*]](0x45d173c8), %[[BB4_LABEL:.*]](0x3a2e8c38)
30 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 129, implicit-def $eflags
31 ; CHECK: JCC_1 %[[CASE5_LABEL]], 4, implicit $eflags
32 ; CHECK: JMP_1 %[[BB4_LABEL]]
33 ; CHECK: [[BB4_LABEL:.*]].{{[a-zA-Z0-9.]+}}:
34 ; CHECK: successors: %[[CASE1_LABEL:.*]](0x66666666), %[[DEFAULT_BB_LABEL:.*]](0x1999999a)
35 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 8, implicit-def $eflags
36 ; CHECK: JCC_1 %[[CASE1_LABEL]], 4, implicit $eflags
37 ; CHECK: JMP_1 %[[DEFAULT_BB_LABEL]]
38 ; CHECK: [[BB2_LABEL]].{{[a-zA-Z0-9.]+}}:
39 ; CHECK: successors: %[[CASE3_LABEL:.*]](0x7fe44107), %[[DEFAULT_BB_LABEL]](0x001bbef9)
40 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 18312, implicit-def $eflags
41 ; CHECK: JCC_1 %[[CASE3_LABEL]], 4, implicit $eflags
42 ; CHECK: JMP_1 %[[DEFAULT_BB_LABEL]]
58 %retval = phi i32 [ 0, %bb_default ], [ 5, %bb5 ], [ 4, %bb4 ], [ 3, %bb3 ], [ 2, %bb2 ], [ 1, %bb1 ]
62 ; Test the peeling of the merged cases value 85 and 86.
63 define i32 @foo1(i32 %n) !prof !1 {
65 switch i32 %n, label %bb_default [
75 ; CHECK: successors: %[[PEELED_CASE_LABEL:.*]](0x59999999), %[[PEELED_SWITCH_LABEL:.*]](0x26666667)
76 ; CHECK: %[[VAL:[0-9]+]]:gr32 = COPY $edi
77 ; CHECK: %{{[0-9]+}}:gr32 = ADD32ri %{{[0-9]+}}, -85, implicit-def dead $eflags
78 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %{{[0-9]+}}, 2, implicit-def $eflags
79 ; CHECK: JCC_1 %[[PEELED_CASE_LABEL]], 2, implicit $eflags
80 ; CHECK: JMP_1 %[[PEELED_SWITCH_LABEL]]
81 ; CHECK: [[PEELED_SWITCH_LABEL]].{{[a-zA-Z0-9.]+}}:
82 ; CHECK: successors: %[[BB1_LABEL:.*]](0x0088888a), %[[BB2_LABEL:.*]](0x7f777776)
83 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 4, implicit-def $eflags
84 ; CHECK: JCC_1 %[[BB2_LABEL]], 15, implicit $eflags
85 ; CHECK: JMP_1 %[[BB1_LABEL]]
86 ; CHECK: [[BB1_LABEL]].{{[a-zA-Z0-9.]+}}:
87 ; CHECK: successors: %[[CASE4_LABEL:.*]](0x7f775a4f), %[[BB3_LABEL:.*]](0x0088a5b1)
88 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 1, implicit-def $eflags
89 ; CHECK: JCC_1 %[[CASE4_LABEL]], 4, implicit $eflags
90 ; CHECK: JMP_1 %[[BB3_LABEL]]
91 ; CHECK: [[BB3_LABEL]].{{[a-zA-Z0-9.]+}}:
92 ; CHECK: successors: %[[CASE1_LABEL:.*]](0x66666666), %[[DEFAULT_BB_LABEL:.*]](0x1999999a)
93 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], -40, implicit-def $eflags
94 ; CHECK: JCC_1 %[[CASE1_LABEL]], 4, implicit $eflags
95 ; CHECK: JMP_1 %[[DEFAULT_BB_LABEL]]
96 ; CHECK: [[BB2_LABEL]].{{[a-zA-Z0-9.]+}}:
97 ; CHECK: successors: %[[CASE5_LABEL:.*]](0x00000000), %[[BB4_LABEL:.*]](0x80000000)
98 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 5, implicit-def $eflags
99 ; CHECK: JCC_1 %[[CASE5_LABEL]], 4, implicit $eflags
100 ; CHECK: JMP_1 %[[BB4_LABEL]]
101 ; CHECK: [[BB4_LABEL]].{{[a-zA-Z0-9.]+}}:
102 ; CHECK: successors: %[[CASE6_LABEL:.*]](0x00000000), %[[BB5_LABEL:.*]](0x80000000)
103 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 7, implicit-def $eflags
104 ; CHECK: JCC_1 %[[CASE6_LABEL]], 4, implicit $eflags
105 ; CHECK: JMP_1 %[[BB5_LABEL]]
106 ; CHECK: [[BB5_LABEL]].{{[a-zA-Z0-9.]+}}:
107 ; CHECK: successors: %[[CASE7_LABEL:.*]](0x00000000), %[[DEFAULT_BB_LABEL]](0x80000000)
108 ; CHECK: %{{[0-9]+}}:gr32 = SUB32ri %[[VAL]], 49, implicit-def $eflags
109 ; CHECK: JCC_1 %[[CASE7_LABEL]], 4, implicit $eflags
110 ; CHECK: JMP_1 %[[DEFAULT_BB_LABEL]]
129 %retval = phi i32 [ 0, %bb_default ], [ 6, %bb6 ], [ 5, %bb5 ], [ 4, %bb4 ], [ 3, %bb3 ], [ 2, %bb2 ], [ 1, %bb1 ]
132 !1 = !{!"function_entry_count", i64 100000}
133 !2 = !{!"branch_weights", i32 50, i32 100, i32 200, i32 29500, i32 70000, i32 150}
134 !3 = !{!"branch_weights", i32 50, i32 100, i32 500, i32 69500, i32 29850, i32 0, i32 0, i32 0}