1; RUN: opt < %s -scalar-evolution -analyze -enable-new-pm=0 | FileCheck %s
2; RUN: opt < %s "-passes=print<scalar-evolution>" -disable-output 2>&1 | FileCheck %s
3
4; One side exit dominating the latch, exact backedge taken count is known.
5define void @test_01() {
6
7; CHECK-LABEL: Determining loop execution counts for: @test_01
8; CHECK-NEXT:  Loop %loop: <multiple exits> backedge-taken count is 50
9
10entry:
11  br label %loop
12
13loop:
14  %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
15  %side.cond = icmp slt i32 %iv, 50
16  br i1 %side.cond, label %backedge, label %side.exit
17
18backedge:
19  %iv.next = add i32 %iv, 1
20  %loop.cond = icmp slt i32 %iv, 100
21  br i1 %loop.cond, label %loop, label %exit
22
23exit:
24  ret void
25
26side.exit:
27  ret void
28}
29
30define void @test_02(i1 %c) {
31
32; CHECK-LABEL: Determining loop execution counts for: @test_02
33; CHECK-NEXT:  Loop %loop: <multiple exits> backedge-taken count is 50
34
35entry:
36  br label %loop
37
38loop:
39  %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
40  br i1 %c, label %if.true, label %if.false
41
42if.true:
43  br label %merge
44
45if.false:
46  br label %merge
47
48merge:
49  %side.cond = icmp slt i32 %iv, 50
50  br i1 %side.cond, label %backedge, label %side.exit
51
52backedge:
53  %iv.next = add i32 %iv, 1
54  %loop.cond = icmp slt i32 %iv, 100
55  br i1 %loop.cond, label %loop, label %exit
56
57exit:
58  ret void
59
60side.exit:
61  ret void
62}
63