aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-11-20 11:22:06 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-11-20 11:22:06 +0000
commitb0dadb9dd52aed7a82e24542be8adf881d91c929 (patch)
tree7defe5f020aa6b712f470af483b765183b2da9f7 /test
parenta91a3e04895f2049f7607cfe6fd1aa7b276ed3da (diff)
The logic for breaking the CFG in the presence of hot successors didn't
properly account for the *global* probability of the edge being taken. This manifested as a very large number of unconditional branches to blocks being merged against the CFG even though they weren't particularly hot within the CFG. The fix is to check whether the edge being merged is both locally hot relative to other successors for the source block, and globally hot compared to other (unmerged) predecessors of the destination block. This introduces a new crasher on GCC single-source, but it's currently behind a flag, and Ben has offered to work on the reduction. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGen/X86/block-placement.ll36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CodeGen/X86/block-placement.ll b/test/CodeGen/X86/block-placement.ll
index 16e98edcd1..b488cddaac 100644
--- a/test/CodeGen/X86/block-placement.ll
+++ b/test/CodeGen/X86/block-placement.ll
@@ -439,3 +439,39 @@ if.end:
}
!1 = metadata !{metadata !"branch_weights", i32 1000, i32 1}
+
+declare i32 @f()
+declare i32 @g()
+declare i32 @h(i32 %x)
+
+define i32 @test_global_cfg_break_profitability() {
+; Check that our metrics for the profitability of a CFG break are global rather
+; than local. A successor may be very hot, but if the current block isn't, it
+; doesn't matter. Within this test the 'then' block is slightly warmer than the
+; 'else' block, but not nearly enough to merit merging it with the exit block
+; even though the probability of 'then' branching to the 'exit' block is very
+; high.
+; CHECK: test_global_cfg_break_profitability
+; CHECK: calll f
+; CHECK: calll g
+; CHECK: calll h
+; CHECK: ret
+
+entry:
+ br i1 undef, label %then, label %else, !prof !2
+
+then:
+ %then.result = call i32 @f()
+ br label %exit
+
+else:
+ %else.result = call i32 @g()
+ br label %exit
+
+exit:
+ %result = phi i32 [ %then.result, %then ], [ %else.result, %else ]
+ %result2 = call i32 @h(i32 %result)
+ ret i32 %result
+}
+
+!2 = metadata !{metadata !"branch_weights", i32 3, i32 1}