Akira Hatanaka | bbd33f6 | 2014-08-07 19:30:13 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=arm-apple-ios -print-machineinstrs=branch-folder \ |
| 2 | ; RUN: %s -o /dev/null 2>&1 | FileCheck %s |
| 3 | |
| 4 | ; Branch probability of tailed-merged block: |
| 5 | ; |
| 6 | ; p(L0_L1 -> L2) = p(entry -> L0) * p(L0 -> L2) + p(entry -> L1) * p(L1 -> L2) |
| 7 | ; = 0.2 * 0.6 + 0.8 * 0.3 = 0.36 |
| 8 | ; p(L0_L1 -> L3) = p(entry -> L0) * p(L0 -> L3) + p(entry -> L1) * p(L1 -> L3) |
| 9 | ; = 0.2 * 0.4 + 0.8 * 0.7 = 0.64 |
| 10 | |
| 11 | ; CHECK: # Machine code for function test0: |
Cong Hou | d97c100 | 2015-12-01 05:29:22 +0000 | [diff] [blame] | 12 | ; CHECK: Successors according to CFG: BB#{{[0-9]+}}({{[0-9a-fx/= ]+}}20.00%) BB#{{[0-9]+}}({{[0-9a-fx/= ]+}}80.00%) |
Akira Hatanaka | bbd33f6 | 2014-08-07 19:30:13 +0000 | [diff] [blame] | 13 | ; CHECK: BB#{{[0-9]+}}: |
| 14 | ; CHECK: BB#{{[0-9]+}}: |
| 15 | ; CHECK: # End machine code for function test0. |
| 16 | |
| 17 | define i32 @test0(i32 %n, i32 %m, i32* nocapture %a, i32* nocapture %b) { |
| 18 | entry: |
| 19 | %cmp = icmp sgt i32 %n, 0 |
| 20 | br i1 %cmp, label %L0, label %L1, !prof !0 |
| 21 | |
| 22 | L0: ; preds = %entry |
| 23 | store i32 12, i32* %a, align 4 |
| 24 | store i32 18, i32* %b, align 4 |
| 25 | %cmp1 = icmp eq i32 %m, 8 |
| 26 | br i1 %cmp1, label %L2, label %L3, !prof !1 |
| 27 | |
| 28 | L1: ; preds = %entry |
| 29 | store i32 14, i32* %a, align 4 |
| 30 | store i32 18, i32* %b, align 4 |
| 31 | %cmp3 = icmp eq i32 %m, 8 |
| 32 | br i1 %cmp3, label %L2, label %L3, !prof !2 |
| 33 | |
| 34 | L2: ; preds = %L1, %L0 |
| 35 | br label %L3 |
| 36 | |
| 37 | L3: ; preds = %L0, %L1, %L2 |
| 38 | %retval.0 = phi i32 [ 100, %L2 ], [ 6, %L1 ], [ 6, %L0 ] |
| 39 | ret i32 %retval.0 |
| 40 | } |
| 41 | |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 42 | !0 = !{!"branch_weights", i32 200, i32 800} |
| 43 | !1 = !{!"branch_weights", i32 600, i32 400} |
| 44 | !2 = !{!"branch_weights", i32 300, i32 700} |