1
; Test the static branch probability heuristics for no-return functions.
2
; RUN: opt < %s -analyze -branch-prob | FileCheck %s
4
declare void @abort() noreturn
6
define i32 @test1(i32 %a, i32 %b) {
7
; CHECK: Printing analysis {{.*}} for function 'test1'
9
%cond = icmp eq i32 %a, 42
10
br i1 %cond, label %exit, label %abort
11
; CHECK: edge entry -> exit probability is 1048575 / 1048576
12
; CHECK: edge entry -> abort probability is 1 / 1048576
15
call void @abort() noreturn
22
define i32 @test2(i32 %a, i32 %b) {
23
; CHECK: Printing analysis {{.*}} for function 'test2'
25
switch i32 %a, label %exit [i32 1, label %case_a
29
; CHECK: edge entry -> exit probability is 1048575 / 1048579
30
; CHECK: edge entry -> case_a probability is 1 / 1048579
31
; CHECK: edge entry -> case_b probability is 1 / 1048579
32
; CHECK: edge entry -> case_c probability is 1 / 1048579
33
; CHECK: edge entry -> case_d probability is 1 / 1048579
45
call void @abort() noreturn
52
define i32 @test3(i32 %a, i32 %b) {
53
; CHECK: Printing analysis {{.*}} for function 'test3'
54
; Make sure we unify across multiple conditional branches.
56
%cond1 = icmp eq i32 %a, 42
57
br i1 %cond1, label %exit, label %dom
58
; CHECK: edge entry -> exit probability is 1048575 / 1048576
59
; CHECK: edge entry -> dom probability is 1 / 1048576
62
%cond2 = icmp ult i32 %a, 42
63
br i1 %cond2, label %idom1, label %idom2
64
; CHECK: edge dom -> idom1 probability is 1 / 2
65
; CHECK: edge dom -> idom2 probability is 1 / 2
74
call void @abort() noreturn