1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
define void @s32_max1(i32 %n, ptr %p) {
; CHECK-LABEL: 's32_max1'
; CHECK-NEXT: Determining loop execution counts for: @s32_max1
; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((1 + %n) smax %n))
; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is 1, actual taken count either this or zero.
; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((1 + %n) smax %n)), actual taken count either this or zero.
; CHECK-NEXT: Loop %do.body: Predicated backedge-taken count is ((-1 * %n) + ((1 + %n) smax %n))
; CHECK-NEXT: Predicates:
; CHECK: Loop %do.body: Trip multiple is 1
;
entry:
%add = add i32 %n, 1
br label %do.body
do.body:
%i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
%arrayidx = getelementptr i32, ptr %p, i32 %i.0
store i32 %i.0, ptr %arrayidx, align 4
%inc = add i32 %i.0, 1
%cmp = icmp slt i32 %i.0, %add
br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 1 times
do.end:
ret void
}
define void @s32_max2(i32 %n, ptr %p) {
; CHECK-LABEL: 's32_max2'
; CHECK-NEXT: Determining loop execution counts for: @s32_max2
; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((2 + %n) smax %n))
; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is 2, actual taken count either this or zero.
; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((2 + %n) smax %n)), actual taken count either this or zero.
; CHECK-NEXT: Loop %do.body: Predicated backedge-taken count is ((-1 * %n) + ((2 + %n) smax %n))
; CHECK-NEXT: Predicates:
; CHECK: Loop %do.body: Trip multiple is 1
;
entry:
%add = add i32 %n, 2
br label %do.body
do.body:
%i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
%arrayidx = getelementptr i32, ptr %p, i32 %i.0
store i32 %i.0, ptr %arrayidx, align 4
%inc = add i32 %i.0, 1
%cmp = icmp slt i32 %i.0, %add
br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 2 times
do.end:
ret void
}
define void @s32_maxx(i32 %n, i32 %x, ptr %p) {
; CHECK-LABEL: 's32_maxx'
; CHECK-NEXT: Determining loop execution counts for: @s32_maxx
; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((%n + %x) smax %n))
; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is -1
; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((%n + %x) smax %n))
; CHECK-NEXT: Loop %do.body: Predicated backedge-taken count is ((-1 * %n) + ((%n + %x) smax %n))
; CHECK-NEXT: Predicates:
; CHECK: Loop %do.body: Trip multiple is 1
;
entry:
%add = add i32 %x, %n
br label %do.body
do.body:
%i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
%arrayidx = getelementptr i32, ptr %p, i32 %i.0
store i32 %i.0, ptr %arrayidx, align 4
%inc = add i32 %i.0, 1
%cmp = icmp slt i32 %i.0, %add
br i1 %cmp, label %do.body, label %do.end ; taken either 0 or x times
do.end:
ret void
}
define void @s32_max2_unpredictable_exit(i32 %n, i32 %x, ptr %p) {
; CHECK-LABEL: 's32_max2_unpredictable_exit'
; CHECK-NEXT: Determining loop execution counts for: @s32_max2_unpredictable_exit
; CHECK-NEXT: Loop %do.body: <multiple exits> backedge-taken count is (((-1 * %n) + ((2 + %n) smax %n)) umin ((-1 * %n) + %x))
; CHECK-NEXT: exit count for do.body: ((-1 * %n) + %x)
; CHECK-NEXT: exit count for if.end: ((-1 * %n) + ((2 + %n) smax %n))
; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is 2
; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is (((-1 * %n) + ((2 + %n) smax %n)) umin ((-1 * %n) + %x))
; CHECK-NEXT: symbolic max exit count for do.body: ((-1 * %n) + %x)
; CHECK-NEXT: symbolic max exit count for if.end: ((-1 * %n) + ((2 + %n) smax %n))
; CHECK-NEXT: Loop %do.body: Predicated backedge-taken count is (((-1 * %n) + ((2 + %n) smax %n)) umin ((-1 * %n) + %x))
; CHECK-NEXT: Predicates:
; CHECK: Loop %do.body: Trip multiple is 1
;
entry:
%add = add i32 %n, 2
br label %do.body
do.body:
%i.0 = phi i32 [ %n, %entry ], [ %inc, %if.end ]
%cmp = icmp eq i32 %i.0, %x
br i1 %cmp, label %do.end, label %if.end ; unpredictable
if.end:
%arrayidx = getelementptr i32, ptr %p, i32 %i.0
store i32 %i.0, ptr %arrayidx, align 4
%inc = add i32 %i.0, 1
%cmp1 = icmp slt i32 %i.0, %add
br i1 %cmp1, label %do.body, label %do.end ; taken either 0 or 2 times
do.end:
ret void
}
define void @u32_max1(i32 %n, ptr %p) {
; CHECK-LABEL: 'u32_max1'
; CHECK-NEXT: Determining loop execution counts for: @u32_max1
; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((1 + %n) umax %n))
; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is 1, actual taken count either this or zero.
; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((1 + %n) umax %n)), actual taken count either this or zero.
; CHECK-NEXT: Loop %do.body: Predicated backedge-taken count is ((-1 * %n) + ((1 + %n) umax %n))
; CHECK-NEXT: Predicates:
; CHECK: Loop %do.body: Trip multiple is 1
;
entry:
%add = add i32 %n, 1
br label %do.body
do.body:
%i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
%arrayidx = getelementptr i32, ptr %p, i32 %i.0
store i32 %i.0, ptr %arrayidx, align 4
%inc = add i32 %i.0, 1
%cmp = icmp ult i32 %i.0, %add
br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 1 times
do.end:
ret void
}
define void @u32_max2(i32 %n, ptr %p) {
; CHECK-LABEL: 'u32_max2'
; CHECK-NEXT: Determining loop execution counts for: @u32_max2
; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((2 + %n) umax %n))
; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is 2, actual taken count either this or zero.
; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((2 + %n) umax %n)), actual taken count either this or zero.
; CHECK-NEXT: Loop %do.body: Predicated backedge-taken count is ((-1 * %n) + ((2 + %n) umax %n))
; CHECK-NEXT: Predicates:
; CHECK: Loop %do.body: Trip multiple is 1
;
entry:
%add = add i32 %n, 2
br label %do.body
do.body:
%i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
%arrayidx = getelementptr i32, ptr %p, i32 %i.0
store i32 %i.0, ptr %arrayidx, align 4
%inc = add i32 %i.0, 1
%cmp = icmp ult i32 %i.0, %add
br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 2 times
do.end:
ret void
}
define void @u32_maxx(i32 %n, i32 %x, ptr %p) {
; CHECK-LABEL: 'u32_maxx'
; CHECK-NEXT: Determining loop execution counts for: @u32_maxx
; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((%n + %x) umax %n))
; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is -1
; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((%n + %x) umax %n))
; CHECK-NEXT: Loop %do.body: Predicated backedge-taken count is ((-1 * %n) + ((%n + %x) umax %n))
; CHECK-NEXT: Predicates:
; CHECK: Loop %do.body: Trip multiple is 1
;
entry:
%add = add i32 %x, %n
br label %do.body
do.body:
%i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
%arrayidx = getelementptr i32, ptr %p, i32 %i.0
store i32 %i.0, ptr %arrayidx, align 4
%inc = add i32 %i.0, 1
%cmp = icmp ult i32 %i.0, %add
br i1 %cmp, label %do.body, label %do.end ; taken either 0 or x times
do.end:
ret void
}
define void @u32_max2_unpredictable_exit(i32 %n, i32 %x, ptr %p) {
; CHECK-LABEL: 'u32_max2_unpredictable_exit'
; CHECK-NEXT: Determining loop execution counts for: @u32_max2_unpredictable_exit
; CHECK-NEXT: Loop %do.body: <multiple exits> backedge-taken count is (((-1 * %n) + ((2 + %n) umax %n)) umin ((-1 * %n) + %x))
; CHECK-NEXT: exit count for do.body: ((-1 * %n) + %x)
; CHECK-NEXT: exit count for if.end: ((-1 * %n) + ((2 + %n) umax %n))
; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is 2
; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is (((-1 * %n) + ((2 + %n) umax %n)) umin ((-1 * %n) + %x))
; CHECK-NEXT: symbolic max exit count for do.body: ((-1 * %n) + %x)
; CHECK-NEXT: symbolic max exit count for if.end: ((-1 * %n) + ((2 + %n) umax %n))
; CHECK-NEXT: Loop %do.body: Predicated backedge-taken count is (((-1 * %n) + ((2 + %n) umax %n)) umin ((-1 * %n) + %x))
; CHECK-NEXT: Predicates:
; CHECK: Loop %do.body: Trip multiple is 1
;
entry:
%add = add i32 %n, 2
br label %do.body
do.body:
%i.0 = phi i32 [ %n, %entry ], [ %inc, %if.end ]
%cmp = icmp eq i32 %i.0, %x
br i1 %cmp, label %do.end, label %if.end ; unpredictable
if.end:
%arrayidx = getelementptr i32, ptr %p, i32 %i.0
store i32 %i.0, ptr %arrayidx, align 4
%inc = add i32 %i.0, 1
%cmp1 = icmp ult i32 %i.0, %add
br i1 %cmp1, label %do.body, label %do.end ; taken either 0 or 2 times
do.end:
ret void
}
|