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