[PATCH] D30633: [BPI] Unreachable branch has 0 probability
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 5 21:24:04 PST 2017
skatkov created this revision.
As unlikely as possible is actually 0 probability.
So let's use 0 as UR_TAKEN_WEIGHT constant.
https://reviews.llvm.org/D30633
Files:
lib/Analysis/BranchProbabilityInfo.cpp
test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
test/Analysis/BranchProbabilityInfo/noreturn.ll
test/CodeGen/X86/switch-order-weight.ll
Index: test/CodeGen/X86/switch-order-weight.ll
===================================================================
--- test/CodeGen/X86/switch-order-weight.ll
+++ test/CodeGen/X86/switch-order-weight.ll
@@ -13,8 +13,8 @@
; CHECK-LABEL: test1:
; CHECK-NOT: unr
; CHECK: cmpl $10
-; CHECK: cmpl $20
; CHECK: bar
+; CHECK: cmpl $20
if.then:
tail call void @unr(i32 23) noreturn nounwind
Index: test/Analysis/BranchProbabilityInfo/noreturn.ll
===================================================================
--- test/Analysis/BranchProbabilityInfo/noreturn.ll
+++ test/Analysis/BranchProbabilityInfo/noreturn.ll
@@ -9,8 +9,8 @@
entry:
%cond = icmp eq i32 %a, 42
br i1 %cond, label %exit, label %abort
-; CHECK: edge entry -> exit probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
-; CHECK: edge entry -> abort probability is 0x00000800 / 0x80000000 = 0.00%
+; CHECK: edge entry -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
+; CHECK: edge entry -> abort probability is 0x00000000 / 0x80000000 = 0.00%
abort:
call void @abort() noreturn
@@ -27,11 +27,11 @@
i32 2, label %case_b
i32 3, label %case_c
i32 4, label %case_d]
-; CHECK: edge entry -> exit probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
-; CHECK: edge entry -> case_a probability is 0x00000200 / 0x80000000 = 0.00%
-; CHECK: edge entry -> case_b probability is 0x00000200 / 0x80000000 = 0.00%
-; CHECK: edge entry -> case_c probability is 0x00000200 / 0x80000000 = 0.00%
-; CHECK: edge entry -> case_d probability is 0x00000200 / 0x80000000 = 0.00%
+; CHECK: edge entry -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
+; CHECK: edge entry -> case_a probability is 0x00000000 / 0x80000000 = 0.00%
+; CHECK: edge entry -> case_b probability is 0x00000000 / 0x80000000 = 0.00%
+; CHECK: edge entry -> case_c probability is 0x00000000 / 0x80000000 = 0.00%
+; CHECK: edge entry -> case_d probability is 0x00000000 / 0x80000000 = 0.00%
case_a:
br label %case_b
@@ -56,8 +56,8 @@
entry:
%cond1 = icmp eq i32 %a, 42
br i1 %cond1, label %exit, label %dom
-; CHECK: edge entry -> exit probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
-; CHECK: edge entry -> dom probability is 0x00000800 / 0x80000000 = 0.00%
+; CHECK: edge entry -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
+; CHECK: edge entry -> dom probability is 0x00000000 / 0x80000000 = 0.00%
dom:
%cond2 = icmp ult i32 %a, 42
@@ -87,8 +87,8 @@
entry:
%cmp = icmp sge i32 %idx, %limit
br i1 %cmp, label %if.then, label %if.end
-; CHECK: edge entry -> if.then probability is 0x00000800 / 0x80000000 = 0.00%
-; CHECK: edge entry -> if.end probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
+; CHECK: edge entry -> if.then probability is 0x00000000 / 0x80000000 = 0.00%
+; CHECK: edge entry -> if.end probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
if.then: ; preds = %entry
%exception = call i8* @__cxa_allocate_exception(i64 1) #0
Index: test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
===================================================================
--- test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
+++ test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
@@ -9,8 +9,8 @@
%cond = icmp eq i32 %a, 42
br i1 %cond, label %exit, label %deopt
-; CHECK: edge entry -> exit probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
-; CHECK: edge entry -> deopt probability is 0x00000800 / 0x80000000 = 0.00%
+; CHECK: edge entry -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
+; CHECK: edge entry -> deopt probability is 0x00000000 / 0x80000000 = 0.00%
deopt:
%rval = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"() ]
Index: lib/Analysis/BranchProbabilityInfo.cpp
===================================================================
--- lib/Analysis/BranchProbabilityInfo.cpp
+++ lib/Analysis/BranchProbabilityInfo.cpp
@@ -62,7 +62,7 @@
///
/// This is the weight for a branch being taken to a block that terminates
/// (eventually) in unreachable. These are predicted as unlikely as possible.
-static const uint32_t UR_TAKEN_WEIGHT = 1;
+static const uint32_t UR_TAKEN_WEIGHT = 0;
/// \brief Unreachable-terminating branch not-taken weight.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30633.90644.patch
Type: text/x-patch
Size: 4437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170306/a562e707/attachment.bin>
More information about the llvm-commits
mailing list