Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -mtriple=x86_64-- -print-machineinstrs=expand-isel-pseudos %s -o /dev/null 2>&1 | FileCheck %s
      2 
      3 declare void @foo(i32)
      4 
      5 ; CHECK-LABEL: test
      6 
      7 define void @test(i32 %x) nounwind {
      8 entry:
      9   switch i32 %x, label %sw.default [
     10     i32 1, label %sw.bb
     11     i32 155, label %sw.bb
     12     i32 156, label %sw.bb
     13     i32 157, label %sw.bb
     14     i32 158, label %sw.bb
     15     i32 159, label %sw.bb
     16     i32 1134, label %sw.bb
     17     i32 1140, label %sw.bb
     18   ], !prof !1
     19 
     20 sw.bb:
     21   call void @foo(i32 0)
     22   br label %sw.epilog
     23 
     24 sw.default:
     25   call void @foo(i32 1)
     26   br label %sw.epilog
     27 
     28 sw.epilog:
     29   ret void
     30 
     31 ; Check if weights are correctly assigned to edges generated from switch
     32 ; statement.
     33 ;
     34 ; CHECK: bb.0{{[0-9a-zA-Z.]*}}:
     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: %bb.4(0x5c71c71c), %bb.5(0x238e38e4)
     38 ;
     39 ; CHECK: bb.4{{[0-9a-zA-Z.]*}}:
     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: %bb.1(0x62762762), %bb.7(0x1d89d89e)
     43 ;
     44 ; CHECK: bb.5{{[0-9a-zA-Z.]*}}:
     45 ; %bb.5 to %bb.1: {1140} (10)
     46 ; %bb.5 to %bb.6: [1134, UINT32_MAX] - {1140} (15 = 10 + 5)
     47 ; CHECK: successors: %bb.1(0x33333333), %bb.6(0x4ccccccd)
     48 ;
     49 ; CHECK: bb.6{{[0-9a-zA-Z.]*}}:
     50 ; %bb.6 to %bb.1: {1134} (10)
     51 ; %bb.6 to %bb.2: [1134, UINT32_MAX] - {1134, 1140} (5)
     52 ; CHECK: successors: %bb.1(0x55555555), %bb.2(0x2aaaaaab)
     53 }
     54 
     55 ; CHECK-LABEL: test2
     56 
     57 define void @test2(i32 %x) nounwind {
     58 entry:
     59 
     60 ; In this switch statement, there is an edge from jump table to default
     61 ; statement.
     62 
     63   switch i32 %x, label %sw.default [
     64     i32 1, label %sw.bb
     65     i32 10, label %sw.bb2
     66     i32 11, label %sw.bb3
     67     i32 12, label %sw.bb4
     68     i32 13, label %sw.bb5
     69     i32 14, label %sw.bb5
     70   ], !prof !3
     71 
     72 sw.bb:
     73   call void @foo(i32 0)
     74   br label %sw.epilog
     75 
     76 sw.bb2:
     77   call void @foo(i32 2)
     78   br label %sw.epilog
     79 
     80 sw.bb3:
     81   call void @foo(i32 3)
     82   br label %sw.epilog
     83 
     84 sw.bb4:
     85   call void @foo(i32 4)
     86   br label %sw.epilog
     87 
     88 sw.bb5:
     89   call void @foo(i32 5)
     90   br label %sw.epilog
     91 
     92 sw.default:
     93   call void @foo(i32 1)
     94   br label %sw.epilog
     95 
     96 sw.epilog:
     97   ret void
     98 
     99 ; Check if weights are correctly assigned to edges generated from switch
    100 ; statement.
    101 ;
    102 ; CHECK: bb.0{{[0-9a-zA-Z.]*}}:
    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: %bb.6(0x09249249), %bb.8(0x76db6db7)
    106 ;
    107 ; CHECK: bb.8{{[0-9a-zA-Z.]*}}:
    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: %bb.1(0x13b13b14), %bb.6(0x09d89d8a), %bb.2(0x13b13b14), %bb.3(0x13b13b14), %bb.4(0x13b13b14), %bb.5(0x27627628)
    115 }
    116 
    117 ; CHECK-LABEL: test3
    118 
    119 define void @test3(i32 %x) nounwind {
    120 entry:
    121 
    122 ; In this switch statement, there is no edge from jump table to default
    123 ; statement.
    124 
    125   switch i32 %x, label %sw.default [
    126     i32 10, label %sw.bb
    127     i32 11, label %sw.bb2
    128     i32 12, label %sw.bb3
    129     i32 13, label %sw.bb4
    130     i32 14, label %sw.bb5
    131   ], !prof !2
    132 
    133 sw.bb:
    134   call void @foo(i32 0)
    135   br label %sw.epilog
    136 
    137 sw.bb2:
    138   call void @foo(i32 2)
    139   br label %sw.epilog
    140 
    141 sw.bb3:
    142   call void @foo(i32 3)
    143   br label %sw.epilog
    144 
    145 sw.bb4:
    146   call void @foo(i32 4)
    147   br label %sw.epilog
    148 
    149 sw.bb5:
    150   call void @foo(i32 5)
    151   br label %sw.epilog
    152 
    153 sw.default:
    154   call void @foo(i32 1)
    155   br label %sw.epilog
    156 
    157 sw.epilog:
    158   ret void
    159 
    160 ; Check if weights are correctly assigned to edges generated from switch
    161 ; statement.
    162 ;
    163 ; CHECK: bb.0{{[0-9a-zA-Z.]*}}:
    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: %bb.6(0x15555555), %bb.8(0x6aaaaaab)
    167 ;
    168 ; CHECK: bb.8{{[0-9a-zA-Z.]*}}:
    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: %bb.1(0x1999999a), %bb.2(0x1999999a), %bb.3(0x1999999a), %bb.4(0x1999999a), %bb.5(0x1999999a)
    175 }
    176 
    177 ; CHECK-LABEL: test4
    178 
    179 define void @test4(i32 %x) nounwind {
    180 entry:
    181 
    182 ; In this switch statement, there is no edge from bit test to default basic
    183 ; block.
    184 
    185   switch i32 %x, label %sw.default [
    186     i32 1, label %sw.bb
    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
    192   ], !prof !3
    193 
    194 sw.bb:
    195   call void @foo(i32 0)
    196   br label %sw.epilog
    197 
    198 sw.bb2:
    199   call void @foo(i32 2)
    200   br label %sw.epilog
    201 
    202 sw.bb3:
    203   call void @foo(i32 3)
    204   br label %sw.epilog
    205 
    206 sw.default:
    207   call void @foo(i32 1)
    208   br label %sw.epilog
    209 
    210 sw.epilog:
    211   ret void
    212 
    213 ; Check if weights are correctly assigned to edges generated from switch
    214 ; statement.
    215 ;
    216 ; CHECK: bb.0{{[0-9a-zA-Z.]*}}:
    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: %bb.6(0x24924925), %bb.7(0x5b6db6db)
    220 ;
    221 ; CHECK: bb.7{{[0-9a-zA-Z.]*}}:
    222 ; %bb.7 to %bb.2: {111, 114, 115} (30)
    223 ; %bb.7 to %bb.3: {112, 113} (20)
    224 ; CHECK: successors: %bb.2(0x4ccccccd), %bb.3(0x33333333)
    225 }
    226 
    227 ; CHECK-LABEL: test5
    228 
    229 define void @test5(i32 %x) nounwind {
    230 entry:
    231 
    232 ; In this switch statement, there is an edge from jump table to default basic
    233 ; block.
    234 
    235   switch i32 %x, label %sw.default [
    236     i32 4, label %sw.bb
    237     i32 20, label %sw.bb2
    238     i32 28, label %sw.bb3
    239     i32 36, label %sw.bb4
    240     i32 124, label %sw.bb5
    241   ], !prof !2
    242 
    243 sw.bb:
    244   call void @foo(i32 0)
    245   br label %sw.epilog
    246 
    247 sw.bb2:
    248   call void @foo(i32 1)
    249   br label %sw.epilog
    250 
    251 sw.bb3:
    252   call void @foo(i32 2)
    253   br label %sw.epilog
    254 
    255 sw.bb4:
    256   call void @foo(i32 3)
    257   br label %sw.epilog
    258 
    259 sw.bb5:
    260   call void @foo(i32 4)
    261   br label %sw.epilog
    262 
    263 sw.default:
    264   call void @foo(i32 5)
    265   br label %sw.epilog
    266 
    267 sw.epilog:
    268   ret void
    269 
    270 ; Check if weights are correctly assigned to edges generated from switch
    271 ; statement.
    272 ;
    273 ; CHECK: bb.0{{[0-9a-zA-Z.]*}}:
    274 ; %bb.0 to %bb.6: [10, UINT32_MAX] (15)
    275 ; %bb.0 to %bb.8: [4, 20, 28, 36] (jump table) (45)
    276 ; CHECK: successors: %bb.8(0x20000001), %bb.9(0x5fffffff)
    277 }
    278 
    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} 
    282