211 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py2; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s3 4define void @s32_max1(i32 %n, ptr %p) {5; CHECK-LABEL: 's32_max1'6; CHECK-NEXT: Determining loop execution counts for: @s32_max17; 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 111;12entry:13 %add = add i32 %n, 114 br label %do.body15 16do.body:17 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]18 %arrayidx = getelementptr i32, ptr %p, i32 %i.019 store i32 %i.0, ptr %arrayidx, align 420 %inc = add i32 %i.0, 121 %cmp = icmp slt i32 %i.0, %add22 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 1 times23 24do.end:25 ret void26}27 28define void @s32_max2(i32 %n, ptr %p) {29; CHECK-LABEL: 's32_max2'30; CHECK-NEXT: Determining loop execution counts for: @s32_max231; 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 135;36entry:37 %add = add i32 %n, 238 br label %do.body39 40do.body:41 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]42 %arrayidx = getelementptr i32, ptr %p, i32 %i.043 store i32 %i.0, ptr %arrayidx, align 444 %inc = add i32 %i.0, 145 %cmp = icmp slt i32 %i.0, %add46 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 2 times47 48do.end:49 ret void50}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_maxx55; 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 -157; 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 159;60entry:61 %add = add i32 %x, %n62 br label %do.body63 64do.body:65 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]66 %arrayidx = getelementptr i32, ptr %p, i32 %i.067 store i32 %i.0, ptr %arrayidx, align 468 %inc = add i32 %i.0, 169 %cmp = icmp slt i32 %i.0, %add70 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or x times71 72do.end:73 ret void74}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_exit79; 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 283; 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 187;88entry:89 %add = add i32 %n, 290 br label %do.body91 92do.body:93 %i.0 = phi i32 [ %n, %entry ], [ %inc, %if.end ]94 %cmp = icmp eq i32 %i.0, %x95 br i1 %cmp, label %do.end, label %if.end ; unpredictable96 97if.end:98 %arrayidx = getelementptr i32, ptr %p, i32 %i.099 store i32 %i.0, ptr %arrayidx, align 4100 %inc = add i32 %i.0, 1101 %cmp1 = icmp slt i32 %i.0, %add102 br i1 %cmp1, label %do.body, label %do.end ; taken either 0 or 2 times103 104do.end:105 ret void106}107 108define void @u32_max1(i32 %n, ptr %p) {109; CHECK-LABEL: 'u32_max1'110; CHECK-NEXT: Determining loop execution counts for: @u32_max1111; 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 1115;116entry:117 %add = add i32 %n, 1118 br label %do.body119 120do.body:121 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]122 %arrayidx = getelementptr i32, ptr %p, i32 %i.0123 store i32 %i.0, ptr %arrayidx, align 4124 %inc = add i32 %i.0, 1125 %cmp = icmp ult i32 %i.0, %add126 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 1 times127 128do.end:129 ret void130}131 132define void @u32_max2(i32 %n, ptr %p) {133; CHECK-LABEL: 'u32_max2'134; CHECK-NEXT: Determining loop execution counts for: @u32_max2135; 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 1139;140entry:141 %add = add i32 %n, 2142 br label %do.body143 144do.body:145 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]146 %arrayidx = getelementptr i32, ptr %p, i32 %i.0147 store i32 %i.0, ptr %arrayidx, align 4148 %inc = add i32 %i.0, 1149 %cmp = icmp ult i32 %i.0, %add150 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 2 times151 152do.end:153 ret void154}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_maxx159; 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 -1161; 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 1163;164entry:165 %add = add i32 %x, %n166 br label %do.body167 168do.body:169 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]170 %arrayidx = getelementptr i32, ptr %p, i32 %i.0171 store i32 %i.0, ptr %arrayidx, align 4172 %inc = add i32 %i.0, 1173 %cmp = icmp ult i32 %i.0, %add174 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or x times175 176do.end:177 ret void178}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_exit183; 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 2187; 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 1191;192entry:193 %add = add i32 %n, 2194 br label %do.body195 196do.body:197 %i.0 = phi i32 [ %n, %entry ], [ %inc, %if.end ]198 %cmp = icmp eq i32 %i.0, %x199 br i1 %cmp, label %do.end, label %if.end ; unpredictable200 201if.end:202 %arrayidx = getelementptr i32, ptr %p, i32 %i.0203 store i32 %i.0, ptr %arrayidx, align 4204 %inc = add i32 %i.0, 1205 %cmp1 = icmp ult i32 %i.0, %add206 br i1 %cmp1, label %do.body, label %do.end ; taken either 0 or 2 times207 208do.end:209 ret void210}211