1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
llvm-mirror/test/Analysis/BranchProbabilityInfo/deopt-intrinsic.ll
Serguei Katkov 23f153bff9 [BPI] Reduce the probability of unreachable edge to minimal value greater than 0
The probability of edge coming to unreachable block should be as low as possible.
The change reduces the probability to minimal value greater than zero.

The bug https://bugs.llvm.org/show_bug.cgi?id=32214 show the example when
the probability of edge coming to unreachable block is greater than for edge
coming to out of the loop and it causes incorrect loop rotation.

Please note that with this change the behavior of unreachable heuristic is a bit different
than others. Specifically, before this change the sum of probabilities
coming to unreachable blocks have the same weight for all branches
(it was just split over all edges of this block coming to unreachable blocks).
With this change it might be slightly different but not to much due to probability of
taken branch to unreachable block is really small.

Reviewers: chandlerc, sanjoy, vsk, congh, junbuml, davidxl, dexonsmith
Reviewed By: chandlerc, dexonsmith
Subscribers: reames, llvm-commits
Differential Revision: https://reviews.llvm.org/D30633

llvm-svn: 303327
2017-05-18 06:11:56 +00:00

22 lines
649 B
LLVM

; RUN: opt -analyze -branch-prob < %s | FileCheck %s
; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
declare i32 @llvm.experimental.deoptimize.i32(...)
define i32 @test1(i32 %a, i32 %b) {
; CHECK-LABEL: Printing analysis {{.*}} for function 'test1':
entry:
%cond = icmp eq i32 %a, 42
br i1 %cond, label %exit, label %deopt
; CHECK: edge entry -> exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
; CHECK: edge entry -> deopt probability is 0x00000001 / 0x80000000 = 0.00%
deopt:
%rval = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"() ]
ret i32 %rval
exit:
ret i32 %b
}