Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux < %s | FileCheck %s
      2 
      3 define void @foo() !prof !1 {
      4 ; Test if a cold block in a loop will be placed at the end of the function
      5 ; chain.
      6 ;
      7 ; CHECK-LABEL: foo:
      8 ; CHECK: callq b
      9 ; CHECK: callq c
     10 ; CHECK: callq e
     11 ; CHECK: callq f
     12 ; CHECK: callq d
     13 
     14 entry:
     15   br label %header
     16 
     17 header:
     18   call void @b()
     19   %call = call zeroext i1 @a()
     20   br i1 %call, label %if.then, label %if.else, !prof !4
     21 
     22 if.then:
     23   call void @c()
     24   br label %if.end
     25 
     26 if.else:
     27   call void @d()
     28   br label %if.end
     29 
     30 if.end:
     31   call void @e()
     32   %call2 = call zeroext i1 @a()
     33   br i1 %call2, label %header, label %end, !prof !5
     34 
     35 end:
     36   call void @f()
     37   ret void
     38 }
     39 
     40 define void @nested_loop_0() !prof !1 {
     41 ; Test if a block that is cold in the inner loop but not cold in the outer loop
     42 ; will merged to the outer loop chain.
     43 ;
     44 ; CHECK-LABEL: nested_loop_0:
     45 ; CHECK: callq c
     46 ; CHECK: callq d
     47 ; CHECK: callq e
     48 ; CHECK: callq b
     49 ; CHECK: callq f
     50 
     51 entry:
     52   br label %header
     53 
     54 header:
     55   call void @b()
     56   %call4 = call zeroext i1 @a()
     57   br i1 %call4, label %header2, label %end
     58 
     59 header2:
     60   call void @c()
     61   %call = call zeroext i1 @a()
     62   br i1 %call, label %if.then, label %if.else, !prof !2
     63 
     64 if.then:
     65   call void @d()
     66   %call3 = call zeroext i1 @a()
     67   br i1 %call3, label %header2, label %header, !prof !3
     68 
     69 if.else:
     70   call void @e()
     71   %call2 = call zeroext i1 @a()
     72   br i1 %call2, label %header2, label %header, !prof !3
     73 
     74 end:
     75   call void @f()
     76   ret void
     77 }
     78 
     79 define void @nested_loop_1() !prof !1 {
     80 ; Test if a cold block in an inner loop will be placed at the end of the
     81 ; function chain.
     82 ;
     83 ; CHECK-LABEL: nested_loop_1:
     84 ; CHECK: callq b
     85 ; CHECK: callq c
     86 ; CHECK: callq e
     87 ; CHECK: callq d
     88 
     89 entry:
     90   br label %header
     91 
     92 header:
     93   call void @b()
     94   br label %header2
     95 
     96 header2:
     97   call void @c()
     98   %call = call zeroext i1 @a()
     99   br i1 %call, label %end, label %if.else, !prof !4
    100 
    101 if.else:
    102   call void @d()
    103   %call2 = call zeroext i1 @a()
    104   br i1 %call2, label %header2, label %header, !prof !5
    105 
    106 end:
    107   call void @e()
    108   ret void
    109 }
    110 
    111 declare zeroext i1 @a()
    112 declare void @b()
    113 declare void @c()
    114 declare void @d()
    115 declare void @e()
    116 declare void @f()
    117 
    118 !1 = !{!"function_entry_count", i64 1}
    119 !2 = !{!"branch_weights", i32 100, i32 1}
    120 !3 = !{!"branch_weights", i32 1, i32 10}
    121 !4 = !{!"branch_weights", i32 1000, i32 1}
    122 !5 = !{!"branch_weights", i32 100, i32 1}
    123