mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-14 07:31:53 +00:00
715dbbbc3c
Currently, when edge weights are assigned to edges that are created when lowering switch statement, the weight on the edge to default statement (let's call it "default weight" here) is not considered. We need to distribute this weight properly. However, without value profiling, we have no idea how to distribute it. In this patch, I applied the heuristic that this weight is evenly distributed to successors. For example, given a switch statement with cases 1,2,3,5,10,11,20, and every edge from switch to each successor has weight 10. If there is a binary search tree built to test if n < 10, then its two out-edges will have weight 4x10+10/2 = 45 and 3x10 + 10/2 = 35 respectively (currently they are 40 and 30 without considering the default weight). Each distribution (which is 5 here) will be stored in each SwitchWorkListItem for further distribution. There are some exceptions: For a jump table header which doesn't have any edge to default statement, we don't distribute the default weight to it. For a bit test header which covers a contiguous range and hence has no edges to default statement, we don't distribute the default weight to it. When the branch checks a single value or a contiguous range with no edge to default statement, we don't distribute the default weight to it. In other cases, the default weight is evenly distributed to successors. Differential Revision: http://reviews.llvm.org/D12418 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246522 91177308-0d34-0410-b5e6-96231b3b80d8
38 lines
696 B
LLVM
38 lines
696 B
LLVM
; RUN: llc -mtriple=x86_64-apple-darwin11 < %s | FileCheck %s
|
|
|
|
; Check that the cases which lead to unreachable are checked after "10"
|
|
|
|
define void @test1(i32 %x) nounwind uwtable ssp {
|
|
entry:
|
|
switch i32 %x, label %if.end7 [
|
|
i32 0, label %if.then
|
|
i32 10, label %if.then2
|
|
i32 20, label %if.then5
|
|
]
|
|
|
|
; CHECK-LABEL: test1:
|
|
; CHECK-NOT: unr
|
|
; CHECK: cmpl $10
|
|
; CHECK: cmpl $20
|
|
; CHECK: bar
|
|
|
|
if.then:
|
|
tail call void @unr(i32 23) noreturn nounwind
|
|
unreachable
|
|
|
|
if.then2:
|
|
tail call void @bar(i32 42) nounwind
|
|
br label %if.end7
|
|
|
|
if.then5:
|
|
tail call void @unr(i32 5) noreturn nounwind
|
|
unreachable
|
|
|
|
if.end7:
|
|
ret void
|
|
}
|
|
|
|
declare void @unr(i32) noreturn
|
|
|
|
declare void @bar(i32)
|