|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py |
| 2 | +; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s |
| 3 | + |
| 4 | +@b = dso_local global i32 5, align 4 |
| 5 | +@__const.f.g = private unnamed_addr constant [1 x [4 x i16]] [[4 x i16] [i16 1, i16 0, i16 0, i16 0]], align 2 |
| 6 | +@a = common dso_local global i32 0, align 4 |
| 7 | +@c = common dso_local global i32 0, align 4 |
| 8 | +@d = common dso_local global i32 0, align 4 |
| 9 | +@e = common dso_local global i32 0, align 4 |
| 10 | + |
| 11 | +; When inner.loop is taken as an exiting block of outer.loop, we cannot use the |
| 12 | +; addrec of %storemerge1921.3, which is {3, +, -1}<inner.loop>, to calculate the |
| 13 | +; exit count because it doesn't belong to outer.loop. |
| 14 | +define dso_local i32 @f() { |
| 15 | +; CHECK-LABEL: 'f' |
| 16 | +; CHECK-NEXT: Classifying expressions for: @f |
| 17 | +; CHECK-NEXT: %storemerge23 = phi i32 [ 3, %entry ], [ %dec16, %for.inc13.3 ] |
| 18 | +; CHECK-NEXT: --> {3,+,-1}<nsw><%outer.loop> U: [-2147483648,4) S: [-2147483648,4) Exits: 3 LoopDispositions: { %outer.loop: Computable, %for.cond6: Invariant, %inner.loop: Invariant } |
| 19 | +; CHECK-NEXT: %storemerge1921 = phi i32 [ 3, %outer.loop ], [ %dec, %for.end ] |
| 20 | +; CHECK-NEXT: --> {3,+,-1}<nuw><nsw><%for.cond6> U: [3,4) S: [3,4) Exits: <<Unknown>> LoopDispositions: { %for.cond6: Computable, %outer.loop: Variant } |
| 21 | +; CHECK-NEXT: %idxprom20 = zext i32 %storemerge1921 to i64 |
| 22 | +; CHECK-NEXT: --> {3,+,4294967295}<nuw><nsw><%for.cond6> U: [3,4) S: [3,4) Exits: <<Unknown>> LoopDispositions: { %for.cond6: Computable, %outer.loop: Variant } |
| 23 | +; CHECK-NEXT: %arrayidx7 = getelementptr inbounds [1 x [4 x i16]], [1 x [4 x i16]]* @__const.f.g, i64 0, i64 0, i64 %idxprom20 |
| 24 | +; CHECK-NEXT: --> {(6 + @__const.f.g)<nuw>,+,8589934590}<nuw><%for.cond6> U: [6,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %for.cond6: Computable, %outer.loop: Variant } |
| 25 | +; CHECK-NEXT: %i = load i16, i16* %arrayidx7, align 2 |
| 26 | +; CHECK-NEXT: --> %i U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond6: Variant, %outer.loop: Variant } |
| 27 | +; CHECK-NEXT: %storemerge1822.lcssa.ph = phi i32 [ 0, %for.cond6 ] |
| 28 | +; CHECK-NEXT: --> 0 U: [0,1) S: [0,1) |
| 29 | +; CHECK-NEXT: %storemerge1822.lcssa.ph32 = phi i32 [ 3, %inner.loop ] |
| 30 | +; CHECK-NEXT: --> 3 U: [3,4) S: [3,4) |
| 31 | +; CHECK-NEXT: %storemerge1822.lcssa = phi i32 [ %storemerge1822.lcssa.ph, %if.end.loopexit ], [ %storemerge1822.lcssa.ph32, %if.end.loopexit31 ] |
| 32 | +; CHECK-NEXT: --> %storemerge1822.lcssa U: [0,4) S: [0,4) |
| 33 | +; CHECK-NEXT: %i1 = load i32, i32* @e, align 4 |
| 34 | +; CHECK-NEXT: --> %i1 U: full-set S: full-set |
| 35 | +; CHECK-NEXT: %i2 = load volatile i32, i32* @b, align 4 |
| 36 | +; CHECK-NEXT: --> %i2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond6: Variant, %outer.loop: Variant } |
| 37 | +; CHECK-NEXT: %dec = add nsw i32 %storemerge1921, -1 |
| 38 | +; CHECK-NEXT: --> {2,+,-1}<nsw><%for.cond6> U: [2,3) S: [2,3) Exits: <<Unknown>> LoopDispositions: { %for.cond6: Computable, %outer.loop: Variant } |
| 39 | +; CHECK-NEXT: %inc.lcssa.lcssa = phi i32 [ 4, %for.inc13.3 ] |
| 40 | +; CHECK-NEXT: --> 4 U: [4,5) S: [4,5) |
| 41 | +; CHECK-NEXT: %retval.0 = phi i32 [ %i1, %if.end ], [ 0, %cleanup.loopexit ] |
| 42 | +; CHECK-NEXT: --> %retval.0 U: full-set S: full-set |
| 43 | +; CHECK-NEXT: %storemerge1921.3 = phi i32 [ 3, %for.end ], [ %dec.3, %for.end.3 ] |
| 44 | +; CHECK-NEXT: --> {3,+,-1}<nuw><nsw><%inner.loop> U: [3,4) S: [3,4) Exits: <<Unknown>> LoopDispositions: { %inner.loop: Computable, %outer.loop: Variant } |
| 45 | +; CHECK-NEXT: %idxprom20.3 = zext i32 %storemerge1921.3 to i64 |
| 46 | +; CHECK-NEXT: --> {3,+,4294967295}<nuw><nsw><%inner.loop> U: [3,4) S: [3,4) Exits: <<Unknown>> LoopDispositions: { %inner.loop: Computable, %outer.loop: Variant } |
| 47 | +; CHECK-NEXT: %arrayidx7.3 = getelementptr inbounds [1 x [4 x i16]], [1 x [4 x i16]]* @__const.f.g, i64 0, i64 0, i64 %idxprom20.3 |
| 48 | +; CHECK-NEXT: --> {(6 + @__const.f.g)<nuw>,+,8589934590}<nuw><%inner.loop> U: [6,-1) S: [-9223372036854775808,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %inner.loop: Computable, %outer.loop: Variant } |
| 49 | +; CHECK-NEXT: %i7 = load i16, i16* %arrayidx7.3, align 2 |
| 50 | +; CHECK-NEXT: --> %i7 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner.loop: Variant, %outer.loop: Variant } |
| 51 | +; CHECK-NEXT: %i8 = load volatile i32, i32* @b, align 4 |
| 52 | +; CHECK-NEXT: --> %i8 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %inner.loop: Variant, %outer.loop: Variant } |
| 53 | +; CHECK-NEXT: %dec.3 = add nsw i32 %storemerge1921.3, -1 |
| 54 | +; CHECK-NEXT: --> {2,+,-1}<nsw><%inner.loop> U: [2,3) S: [2,3) Exits: <<Unknown>> LoopDispositions: { %inner.loop: Computable, %outer.loop: Variant } |
| 55 | +; CHECK-NEXT: %storemerge1921.lcssa25.3 = phi i32 [ %storemerge1921.3, %for.end.3 ] |
| 56 | +; CHECK-NEXT: --> %storemerge1921.lcssa25.3 U: [3,4) S: [3,4) Exits: <<Unknown>> LoopDispositions: { %outer.loop: Variant, %for.cond6: Invariant, %inner.loop: Invariant } |
| 57 | +; CHECK-NEXT: %dec16 = add nsw i32 %storemerge23, -1 |
| 58 | +; CHECK-NEXT: --> {2,+,-1}<nw><%outer.loop> U: full-set S: full-set Exits: 2 LoopDispositions: { %outer.loop: Computable, %for.cond6: Invariant, %inner.loop: Invariant } |
| 59 | +; CHECK-NEXT: Determining loop execution counts for: @f |
| 60 | +; CHECK-NEXT: Loop %for.cond6: <multiple exits> Unpredictable backedge-taken count. |
| 61 | +; CHECK-NEXT: exit count for for.cond6: 0 |
| 62 | +; CHECK-NEXT: exit count for for.end: ***COULDNOTCOMPUTE*** |
| 63 | +; CHECK-NEXT: Loop %for.cond6: max backedge-taken count is 0 |
| 64 | +; CHECK-NEXT: Loop %for.cond6: Unpredictable predicated backedge-taken count. |
| 65 | +; CHECK-NEXT: Loop %inner.loop: <multiple exits> Unpredictable backedge-taken count. |
| 66 | +; CHECK-NEXT: exit count for inner.loop: 0 |
| 67 | +; CHECK-NEXT: exit count for for.end.3: ***COULDNOTCOMPUTE*** |
| 68 | +; CHECK-NEXT: Loop %inner.loop: max backedge-taken count is 0 |
| 69 | +; CHECK-NEXT: Loop %inner.loop: Unpredictable predicated backedge-taken count. |
| 70 | +; CHECK-NEXT: Loop %outer.loop: <multiple exits> backedge-taken count is 0 |
| 71 | +; CHECK-NEXT: exit count for for.cond6: 0 |
| 72 | +; CHECK-NEXT: exit count for inner.loop: 0 |
| 73 | +; CHECK-NEXT: exit count for for.inc13.3: 2 |
| 74 | +; CHECK-NEXT: Loop %outer.loop: max backedge-taken count is 0 |
| 75 | +; CHECK-NEXT: Loop %outer.loop: Predicated backedge-taken count is 0 |
| 76 | +; CHECK-NEXT: Predicates: |
| 77 | +; CHECK: Loop %outer.loop: Trip multiple is 0 |
| 78 | +; |
| 79 | +entry: |
| 80 | + store i32 3, i32* @a, align 4 |
| 81 | + br label %outer.loop |
| 82 | + |
| 83 | +outer.loop: ; preds = %for.inc13.3, %entry |
| 84 | + %storemerge23 = phi i32 [ 3, %entry ], [ %dec16, %for.inc13.3 ] |
| 85 | + br label %for.cond6 |
| 86 | + |
| 87 | +for.cond6: ; preds = %for.end, %outer.loop |
| 88 | + %storemerge1921 = phi i32 [ 3, %outer.loop ], [ %dec, %for.end ] |
| 89 | + %idxprom20 = zext i32 %storemerge1921 to i64 |
| 90 | + %arrayidx7 = getelementptr inbounds [1 x [4 x i16]], [1 x [4 x i16]]* @__const.f.g, i64 0, i64 0, i64 %idxprom20 |
| 91 | + %i = load i16, i16* %arrayidx7, align 2 |
| 92 | + %tobool8 = icmp eq i16 %i, 0 |
| 93 | + br i1 %tobool8, label %if.end.loopexit, label %for.end |
| 94 | + |
| 95 | +if.end.loopexit: ; preds = %for.cond6 |
| 96 | + %storemerge1822.lcssa.ph = phi i32 [ 0, %for.cond6 ] |
| 97 | + br label %if.end |
| 98 | + |
| 99 | +if.end.loopexit31: ; preds = %inner.loop |
| 100 | + %storemerge1822.lcssa.ph32 = phi i32 [ 3, %inner.loop ] |
| 101 | + br label %if.end |
| 102 | + |
| 103 | +if.end: ; preds = %if.end.loopexit31, %if.end.loopexit |
| 104 | + %storemerge1822.lcssa = phi i32 [ %storemerge1822.lcssa.ph, %if.end.loopexit ], [ %storemerge1822.lcssa.ph32, %if.end.loopexit31 ] |
| 105 | + store i32 %storemerge1822.lcssa, i32* @c, align 4 |
| 106 | + store i32 2, i32* @d, align 4 |
| 107 | + %i1 = load i32, i32* @e, align 4 |
| 108 | + br label %cleanup |
| 109 | + |
| 110 | +for.end: ; preds = %for.cond6 |
| 111 | + %i2 = load volatile i32, i32* @b, align 4 |
| 112 | + %tobool9 = icmp eq i32 %i2, 0 |
| 113 | + %dec = add nsw i32 %storemerge1921, -1 |
| 114 | + br i1 %tobool9, label %for.cond6, label %inner.loop |
| 115 | + |
| 116 | +cleanup.loopexit: ; preds = %for.inc13.3 |
| 117 | + %inc.lcssa.lcssa = phi i32 [ 4, %for.inc13.3 ] |
| 118 | + store i32 %inc.lcssa.lcssa, i32* @c, align 4 |
| 119 | + br label %cleanup |
| 120 | + |
| 121 | +cleanup: ; preds = %cleanup.loopexit, %if.end |
| 122 | + %retval.0 = phi i32 [ %i1, %if.end ], [ 0, %cleanup.loopexit ] |
| 123 | + ret i32 %retval.0 |
| 124 | + |
| 125 | +inner.loop: ; preds = %for.end.3, %for.end |
| 126 | + %storemerge1921.3 = phi i32 [ 3, %for.end ], [ %dec.3, %for.end.3 ] |
| 127 | + %idxprom20.3 = zext i32 %storemerge1921.3 to i64 |
| 128 | + %arrayidx7.3 = getelementptr inbounds [1 x [4 x i16]], [1 x [4 x i16]]* @__const.f.g, i64 0, i64 0, i64 %idxprom20.3 |
| 129 | + %i7 = load i16, i16* %arrayidx7.3, align 2 |
| 130 | + %tobool8.3 = icmp eq i16 %i7, 0 |
| 131 | + br i1 %tobool8.3, label %if.end.loopexit31, label %for.end.3 |
| 132 | + |
| 133 | +for.end.3: ; preds = %inner.loop |
| 134 | + %i8 = load volatile i32, i32* @b, align 4 |
| 135 | + %tobool9.3 = icmp eq i32 %i8, 0 |
| 136 | + %dec.3 = add nsw i32 %storemerge1921.3, -1 |
| 137 | + br i1 %tobool9.3, label %inner.loop, label %for.inc13.3 |
| 138 | + |
| 139 | +for.inc13.3: ; preds = %for.end.3 |
| 140 | + %storemerge1921.lcssa25.3 = phi i32 [ %storemerge1921.3, %for.end.3 ] |
| 141 | + store i32 %storemerge1921.lcssa25.3, i32* @d, align 4 |
| 142 | + %dec16 = add nsw i32 %storemerge23, -1 |
| 143 | + store i32 %dec16, i32* @a, align 4 |
| 144 | + %tobool = icmp eq i32 %dec16, 0 |
| 145 | + br i1 %tobool, label %cleanup.loopexit, label %outer.loop |
| 146 | +} |
0 commit comments