llvm.org GIT mirror llvm / 51f40a7
Make the unreachable probability much much heavier. The previous probability wouldn't be considered "hot" in some weird loop structures or other compounding probability patterns. This makes it much harder to confuse, but isn't really a principled fix. I'd actually like it if we could model a zero probability, as it would make this much easier to reason about. Suggestions for how to do this better are welcome. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147142 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 8 years ago
2 changed file(s) with 12 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
6464 ///
6565 /// This is the weight for a branch not being taken toward a block that
6666 /// terminates (eventually) in unreachable. Such a branch is essentially never
67 /// taken.
68 static const uint32_t UR_NONTAKEN_WEIGHT = 1023;
67 /// taken. Set the weight to an absurdly high value so that nested loops don't
68 /// easily subsume it.
69 static const uint32_t UR_NONTAKEN_WEIGHT = 1024*1024 - 1;
6970
7071 static const uint32_t PH_TAKEN_WEIGHT = 20;
7172 static const uint32_t PH_NONTAKEN_WEIGHT = 12;
77 entry:
88 %cond = icmp eq i32 %a, 42
99 br i1 %cond, label %exit, label %abort
10 ; CHECK: edge entry -> exit probability is 1023 / 1024
11 ; CHECK: edge entry -> abort probability is 1 / 1024
10 ; CHECK: edge entry -> exit probability is 1048575 / 1048576
11 ; CHECK: edge entry -> abort probability is 1 / 1048576
1212
1313 abort:
1414 call void @abort() noreturn
2525 i32 2, label %case_b
2626 i32 3, label %case_c
2727 i32 4, label %case_d]
28 ; CHECK: edge entry -> exit probability is 1023 / 1027
29 ; CHECK: edge entry -> case_a probability is 1 / 1027
30 ; CHECK: edge entry -> case_b probability is 1 / 1027
31 ; CHECK: edge entry -> case_c probability is 1 / 1027
32 ; CHECK: edge entry -> case_d probability is 1 / 1027
28 ; CHECK: edge entry -> exit probability is 1048575 / 1048579
29 ; CHECK: edge entry -> case_a probability is 1 / 1048579
30 ; CHECK: edge entry -> case_b probability is 1 / 1048579
31 ; CHECK: edge entry -> case_c probability is 1 / 1048579
32 ; CHECK: edge entry -> case_d probability is 1 / 1048579
3333
3434 case_a:
3535 br label %case_b
5454 entry:
5555 %cond1 = icmp eq i32 %a, 42
5656 br i1 %cond1, label %exit, label %dom
57 ; CHECK: edge entry -> exit probability is 1023 / 1024
58 ; CHECK: edge entry -> dom probability is 1 / 1024
57 ; CHECK: edge entry -> exit probability is 1048575 / 1048576
58 ; CHECK: edge entry -> dom probability is 1 / 1048576
5959
6060 dom:
6161 %cond2 = icmp ult i32 %a, 42