|
| 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 |
| 3 | + |
| 4 | +declare i1 @cond() |
| 5 | + |
| 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: max backedge-taken count is 2147483647 |
| 24 | +; CHECK-NEXT: Loop %inner: Unpredictable predicated backedge-taken count. |
| 25 | +; CHECK-NEXT: Loop %outer: <multiple exits> Unpredictable backedge-taken count. |
| 26 | +; CHECK-NEXT: exit count for inner: ***COULDNOTCOMPUTE*** |
| 27 | +; CHECK-NEXT: exit count for outer.backedge: ***COULDNOTCOMPUTE*** |
| 28 | +; CHECK-NEXT: Loop %outer: Unpredictable max backedge-taken count. |
| 29 | +; CHECK-NEXT: Loop %outer: Unpredictable predicated backedge-taken count. |
| 30 | +; |
| 31 | +entry: |
| 32 | + %b_is_non_negative = icmp sge i32 %b, 0 |
| 33 | + br i1 %b_is_non_negative, label %outer, label %failure |
| 34 | + |
| 35 | +outer: |
| 36 | + %outer.iv = phi i32 [0, %entry], [%iv.next, %outer.backedge] |
| 37 | + br label %inner |
| 38 | + |
| 39 | +inner: |
| 40 | + %iv = phi i32 [0, %outer], [%iv.next, %inner.backedge] |
| 41 | + %signed_cond = icmp slt i32 %iv, %b |
| 42 | + br i1 %signed_cond, label %inner.backedge, label %side.exit |
| 43 | + |
| 44 | +inner.backedge: |
| 45 | + %iv.next = add nuw nsw i32 %iv, 1 |
| 46 | + %inner.loop.cond = call i1 @cond() |
| 47 | + br i1 %inner.loop.cond, label %inner, label %outer.backedge |
| 48 | + |
| 49 | +outer.backedge: |
| 50 | + %outer.loop.cond = call i1 @cond() |
| 51 | + br i1 %outer.loop.cond, label %outer, label %exit |
| 52 | + |
| 53 | +failure: |
| 54 | + unreachable |
| 55 | + |
| 56 | +side.exit: |
| 57 | + ret i32 0 |
| 58 | + |
| 59 | +exit: |
| 60 | + ret i32 1 |
| 61 | +} |
| 62 | + |
| 63 | +; FIXME: both outer.iv and iv here can be proved non-negative. |
| 64 | +define i32 @test_02(i32 %a, i32 %b) { |
| 65 | +; CHECK-LABEL: 'test_02' |
| 66 | +; CHECK-NEXT: Classifying expressions for: @test_02 |
| 67 | +; CHECK-NEXT: %outer.iv = phi i32 [ 0, %entry ], [ %iv.next, %outer.backedge ] |
| 68 | +; CHECK-NEXT: --> %outer.iv U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %outer: Variant, %inner: Invariant } |
| 69 | +; CHECK-NEXT: %iv = phi i32 [ %outer.iv, %outer ], [ %iv.next, %inner.backedge ] |
| 70 | +; CHECK-NEXT: --> {%outer.iv,+,1}<nuw><nsw><%inner> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner: Computable, %outer: Variant } |
| 71 | +; CHECK-NEXT: %iv.next = add nuw nsw i32 %iv, 1 |
| 72 | +; CHECK-NEXT: --> {(1 + %outer.iv),+,1}<nw><%inner> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner: Computable, %outer: Variant } |
| 73 | +; CHECK-NEXT: %inner.loop.cond = call i1 @cond() |
| 74 | +; CHECK-NEXT: --> %inner.loop.cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner: Variant, %outer: Variant } |
| 75 | +; CHECK-NEXT: %outer.loop.cond = call i1 @cond() |
| 76 | +; CHECK-NEXT: --> %outer.loop.cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %outer: Variant, %inner: Invariant } |
| 77 | +; CHECK-NEXT: Determining loop execution counts for: @test_02 |
| 78 | +; CHECK-NEXT: Loop %inner: <multiple exits> Unpredictable backedge-taken count. |
| 79 | +; CHECK-NEXT: exit count for inner: ((-1 * %outer.iv) + (%b smax %outer.iv)) |
| 80 | +; CHECK-NEXT: exit count for inner.backedge: ***COULDNOTCOMPUTE*** |
| 81 | +; CHECK-NEXT: Loop %inner: max backedge-taken count is -1 |
| 82 | +; CHECK-NEXT: Loop %inner: Unpredictable predicated backedge-taken count. |
| 83 | +; CHECK-NEXT: Loop %outer: <multiple exits> Unpredictable backedge-taken count. |
| 84 | +; CHECK-NEXT: exit count for inner: ***COULDNOTCOMPUTE*** |
| 85 | +; CHECK-NEXT: exit count for outer.backedge: ***COULDNOTCOMPUTE*** |
| 86 | +; CHECK-NEXT: Loop %outer: Unpredictable max backedge-taken count. |
| 87 | +; CHECK-NEXT: Loop %outer: Unpredictable predicated backedge-taken count. |
| 88 | +; |
| 89 | +entry: |
| 90 | + %b_is_non_negative = icmp sge i32 %b, 0 |
| 91 | + br i1 %b_is_non_negative, label %outer, label %failure |
| 92 | + |
| 93 | +outer: |
| 94 | + %outer.iv = phi i32 [0, %entry], [%iv.next, %outer.backedge] |
| 95 | + br label %inner |
| 96 | + |
| 97 | +inner: |
| 98 | + %iv = phi i32 [%outer.iv, %outer], [%iv.next, %inner.backedge] |
| 99 | + %signed_cond = icmp slt i32 %iv, %b |
| 100 | + br i1 %signed_cond, label %inner.backedge, label %side.exit |
| 101 | + |
| 102 | +inner.backedge: |
| 103 | + %iv.next = add nuw nsw i32 %iv, 1 |
| 104 | + %inner.loop.cond = call i1 @cond() |
| 105 | + br i1 %inner.loop.cond, label %inner, label %outer.backedge |
| 106 | + |
| 107 | +outer.backedge: |
| 108 | + %outer.loop.cond = call i1 @cond() |
| 109 | + br i1 %outer.loop.cond, label %outer, label %exit |
| 110 | + |
| 111 | +failure: |
| 112 | + unreachable |
| 113 | + |
| 114 | +side.exit: |
| 115 | + ret i32 0 |
| 116 | + |
| 117 | +exit: |
| 118 | + ret i32 1 |
| 119 | +} |
0 commit comments