llvm.org GIT mirror
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).
 64 64 /// 65 65 /// This is the weight for a branch not being taken toward a block that 66 66 /// 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; 69 70 70 71 static const uint32_t PH_TAKEN_WEIGHT = 20; 71 72 static const uint32_t PH_NONTAKEN_WEIGHT = 12;
 7 7 entry: 8 8 %cond = icmp eq i32 %a, 42 9 9 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 12 12 13 13 abort: 14 14 call void @abort() noreturn 25 25 i32 2, label %case_b 26 26 i32 3, label %case_c 27 27 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 33 33 34 34 case_a: 35 35 br label %case_b 54 54 entry: 55 55 %cond1 = icmp eq i32 %a, 42 56 56 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 59 59 60 60 dom: 61 61 %cond2 = icmp ult i32 %a, 42