• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -analyze -block-freq | FileCheck %s
2
3; CHECK-LABEL: Printing analysis {{.*}} for function 'loop_with_branch':
4; CHECK-NEXT: block-frequency-info: loop_with_branch
5define void @loop_with_branch(i32 %a) {
6; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
7entry:
8  %skip_loop = call i1 @foo0(i32 %a)
9  br i1 %skip_loop, label %skip, label %header, !prof !0
10
11; CHECK-NEXT: skip: float = 0.25,
12skip:
13  br label %exit
14
15; CHECK-NEXT: header: float = 4.5,
16header:
17  %i = phi i32 [ 0, %entry ], [ %i.next, %back ]
18  %i.next = add i32 %i, 1
19  %choose = call i2 @foo1(i32 %i)
20  switch i2 %choose, label %exit [ i2 0, label %left
21                                   i2 1, label %right ], !prof !1
22
23; CHECK-NEXT: left: float = 1.5,
24left:
25  br label %back
26
27; CHECK-NEXT: right: float = 2.25,
28right:
29  br label %back
30
31; CHECK-NEXT: back: float = 3.75,
32back:
33  br label %header
34
35; CHECK-NEXT: exit: float = 1.0, int = [[ENTRY]]
36exit:
37  ret void
38}
39
40declare i1 @foo0(i32)
41declare i2 @foo1(i32)
42
43!0 = !{!"branch_weights", i32 1, i32 3}
44!1 = !{!"branch_weights", i32 1, i32 2, i32 3}
45