1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
6 define i32 @test_01(i32 %a, i32 %b) {
7 ; CHECK-LABEL: 'test_01'
8 ; CHECK-NEXT: Classifying expressions for: @test_01
9 ; CHECK-NEXT: %outer.iv = phi i32 [ 0, %entry ], [ %iv.next, %outer.backedge ]
10 ; CHECK-NEXT: --> %outer.iv U: [0,-2147483647) S: [0,-2147483647) Exits: <<Unknown>> LoopDispositions: { %outer: Variant, %inner: Invariant }
11 ; CHECK-NEXT: %iv = phi i32 [ 0, %outer ], [ %iv.next, %inner.backedge ]
12 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%inner> U: [0,-2147483648) S: [0,-2147483648) Exits: <<Unknown>> LoopDispositions: { %inner: Computable, %outer: Variant }
13 ; CHECK-NEXT: %iv.next = add nuw nsw i32 %iv, 1
14 ; CHECK-NEXT: --> {1,+,1}<nuw><%inner> U: [1,-2147483647) S: [1,-2147483647) Exits: <<Unknown>> LoopDispositions: { %inner: Computable, %outer: Variant }
15 ; CHECK-NEXT: %inner.loop.cond = call i1 @cond()
16 ; CHECK-NEXT: --> %inner.loop.cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner: Variant, %outer: Variant }
17 ; CHECK-NEXT: %outer.loop.cond = call i1 @cond()
18 ; CHECK-NEXT: --> %outer.loop.cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %outer: Variant, %inner: Invariant }
19 ; CHECK-NEXT: Determining loop execution counts for: @test_01
20 ; CHECK-NEXT: Loop %inner: <multiple exits> Unpredictable backedge-taken count.
21 ; CHECK-NEXT: exit count for inner: %b
22 ; CHECK-NEXT: exit count for inner.backedge: ***COULDNOTCOMPUTE***
23 ; CHECK-NEXT: Loop %inner: constant max backedge-taken count is 2147483647
24 ; CHECK-NEXT: Loop %inner: symbolic max backedge-taken count is %b
25 ; CHECK-NEXT: symbolic max exit count for inner: %b
26 ; CHECK-NEXT: symbolic max exit count for inner.backedge: ***COULDNOTCOMPUTE***
27 ; CHECK-NEXT: Loop %inner: Unpredictable predicated backedge-taken count.
28 ; CHECK-NEXT: Loop %outer: <multiple exits> Unpredictable backedge-taken count.
29 ; CHECK-NEXT: exit count for inner: ***COULDNOTCOMPUTE***
30 ; CHECK-NEXT: exit count for outer.backedge: ***COULDNOTCOMPUTE***
31 ; CHECK-NEXT: Loop %outer: Unpredictable constant max backedge-taken count.
32 ; CHECK-NEXT: Loop %outer: Unpredictable symbolic max backedge-taken count.
33 ; CHECK-NEXT: symbolic max exit count for inner: ***COULDNOTCOMPUTE***
34 ; CHECK-NEXT: symbolic max exit count for outer.backedge: ***COULDNOTCOMPUTE***
35 ; CHECK-NEXT: Loop %outer: Unpredictable predicated backedge-taken count.
38 %b_is_non_negative = icmp sge i32 %b, 0
39 br i1 %b_is_non_negative, label %outer, label %failure
42 %outer.iv = phi i32 [0, %entry], [%iv.next, %outer.backedge]
46 %iv = phi i32 [0, %outer], [%iv.next, %inner.backedge]
47 %signed_cond = icmp slt i32 %iv, %b
48 br i1 %signed_cond, label %inner.backedge, label %side.exit
51 %iv.next = add nuw nsw i32 %iv, 1
52 %inner.loop.cond = call i1 @cond()
53 br i1 %inner.loop.cond, label %inner, label %outer.backedge
56 %outer.loop.cond = call i1 @cond()
57 br i1 %outer.loop.cond, label %outer, label %exit
69 ; FIXME: both outer.iv and iv here can be proved non-negative.
70 define i32 @test_02(i32 %a, i32 %b) {
71 ; CHECK-LABEL: 'test_02'
72 ; CHECK-NEXT: Classifying expressions for: @test_02
73 ; CHECK-NEXT: %outer.iv = phi i32 [ 0, %entry ], [ %iv.next, %outer.backedge ]
74 ; CHECK-NEXT: --> %outer.iv U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %outer: Variant, %inner: Invariant }
75 ; CHECK-NEXT: %iv = phi i32 [ %outer.iv, %outer ], [ %iv.next, %inner.backedge ]
76 ; CHECK-NEXT: --> {%outer.iv,+,1}<nuw><nsw><%inner> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner: Computable, %outer: Variant }
77 ; CHECK-NEXT: %iv.next = add nuw nsw i32 %iv, 1
78 ; CHECK-NEXT: --> {(1 + %outer.iv),+,1}<nw><%inner> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner: Computable, %outer: Variant }
79 ; CHECK-NEXT: %inner.loop.cond = call i1 @cond()
80 ; CHECK-NEXT: --> %inner.loop.cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner: Variant, %outer: Variant }
81 ; CHECK-NEXT: %outer.loop.cond = call i1 @cond()
82 ; CHECK-NEXT: --> %outer.loop.cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %outer: Variant, %inner: Invariant }
83 ; CHECK-NEXT: Determining loop execution counts for: @test_02
84 ; CHECK-NEXT: Loop %inner: <multiple exits> Unpredictable backedge-taken count.
85 ; CHECK-NEXT: exit count for inner: ((-1 * %outer.iv) + (%b smax %outer.iv))
86 ; CHECK-NEXT: exit count for inner.backedge: ***COULDNOTCOMPUTE***
87 ; CHECK-NEXT: Loop %inner: constant max backedge-taken count is -1
88 ; CHECK-NEXT: Loop %inner: symbolic max backedge-taken count is ((-1 * %outer.iv) + (%b smax %outer.iv))
89 ; CHECK-NEXT: symbolic max exit count for inner: ((-1 * %outer.iv) + (%b smax %outer.iv))
90 ; CHECK-NEXT: symbolic max exit count for inner.backedge: ***COULDNOTCOMPUTE***
91 ; CHECK-NEXT: Loop %inner: Unpredictable predicated backedge-taken count.
92 ; CHECK-NEXT: Loop %outer: <multiple exits> Unpredictable backedge-taken count.
93 ; CHECK-NEXT: exit count for inner: ***COULDNOTCOMPUTE***
94 ; CHECK-NEXT: exit count for outer.backedge: ***COULDNOTCOMPUTE***
95 ; CHECK-NEXT: Loop %outer: Unpredictable constant max backedge-taken count.
96 ; CHECK-NEXT: Loop %outer: Unpredictable symbolic max backedge-taken count.
97 ; CHECK-NEXT: symbolic max exit count for inner: ***COULDNOTCOMPUTE***
98 ; CHECK-NEXT: symbolic max exit count for outer.backedge: ***COULDNOTCOMPUTE***
99 ; CHECK-NEXT: Loop %outer: Unpredictable predicated backedge-taken count.
102 %b_is_non_negative = icmp sge i32 %b, 0
103 br i1 %b_is_non_negative, label %outer, label %failure
106 %outer.iv = phi i32 [0, %entry], [%iv.next, %outer.backedge]
110 %iv = phi i32 [%outer.iv, %outer], [%iv.next, %inner.backedge]
111 %signed_cond = icmp slt i32 %iv, %b
112 br i1 %signed_cond, label %inner.backedge, label %side.exit
115 %iv.next = add nuw nsw i32 %iv, 1
116 %inner.loop.cond = call i1 @cond()
117 br i1 %inner.loop.cond, label %inner, label %outer.backedge
120 %outer.loop.cond = call i1 @cond()
121 br i1 %outer.loop.cond, label %outer, label %exit