1 ; RUN: opt < %s -analyze -block-freq | FileCheck %s
3 declare void @g(i32 %x)
5 ; CHECK-LABEL: Printing analysis {{.*}} for function 'branch_weight_0':
6 ; CHECK-NEXT: block-frequency-info: branch_weight_0
7 define void @branch_weight_0(i32 %a) {
8 ; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
12 ; Check that we get 1,4 instead of 0,3.
13 ; CHECK-NEXT: for.body: float = 4.0,
15 %i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
18 %cmp = icmp ugt i32 %inc, %a
19 br i1 %cmp, label %for.end, label %for.body, !prof !0
21 ; CHECK-NEXT: for.end: float = 1.0, int = [[ENTRY]]
26 !0 = metadata !{metadata !"branch_weights", i32 0, i32 3}
28 ; CHECK-LABEL: Printing analysis {{.*}} for function 'infinite_loop'
29 ; CHECK-NEXT: block-frequency-info: infinite_loop
30 define void @infinite_loop(i1 %x) {
31 ; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
33 br i1 %x, label %for.body, label %for.end, !prof !1
35 ; Check that the loop scale maxes out at 4096, giving 2048 here.
36 ; CHECK-NEXT: for.body: float = 2048.0,
38 %i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
43 ; Check that the exit weight is half of entry, since half is lost in the
44 ; infinite loop above.
45 ; CHECK-NEXT: for.end: float = 0.5,
50 !1 = metadata !{metadata !"branch_weights", i32 1, i32 1}