137 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 52; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s3 4define dso_local void @simple(i32 noundef %n) local_unnamed_addr {5; CHECK-LABEL: 'simple'6; CHECK-NEXT: Classifying expressions for: @simple7; CHECK-NEXT: %right.06 = phi i32 [ %dec, %while.body ], [ %n, %entry ]8; CHECK-NEXT: --> {%n,+,-4}<nsw><%while.body> U: full-set S: full-set Exits: ((-4 * (((-4 + (-1 * (1 umin (-4 + (4 smax (-4 + %n)))<nsw>))<nuw><nsw> + (4 smax (-4 + %n))) /u 8) + (1 umin (-4 + (4 smax (-4 + %n)))<nsw>)))<nsw> + %n) LoopDispositions: { %while.body: Computable }9; CHECK-NEXT: %left.05 = phi i32 [ %inc, %while.body ], [ 0, %entry ]10; CHECK-NEXT: --> {0,+,4}<nuw><nsw><%while.body> U: [0,2147483641) S: [0,2147483641) Exits: (4 * (((-4 + (-1 * (1 umin (-4 + (4 smax (-4 + %n)))<nsw>))<nuw><nsw> + (4 smax (-4 + %n))) /u 8) + (1 umin (-4 + (4 smax (-4 + %n)))<nsw>)))<nuw> LoopDispositions: { %while.body: Computable }11; CHECK-NEXT: %inc = add nuw nsw i32 %left.05, 412; CHECK-NEXT: --> {4,+,4}<nuw><nsw><%while.body> U: [4,2147483645) S: [4,2147483645) Exits: (4 + (4 * (((-4 + (-1 * (1 umin (-4 + (4 smax (-4 + %n)))<nsw>))<nuw><nsw> + (4 smax (-4 + %n))) /u 8) + (1 umin (-4 + (4 smax (-4 + %n)))<nsw>)))<nuw>)<nuw> LoopDispositions: { %while.body: Computable }13; CHECK-NEXT: %dec = add nsw i32 %right.06, -414; CHECK-NEXT: --> {(-4 + %n),+,-4}<nsw><%while.body> U: full-set S: full-set Exits: (-4 + (-4 * (((-4 + (-1 * (1 umin (-4 + (4 smax (-4 + %n)))<nsw>))<nuw><nsw> + (4 smax (-4 + %n))) /u 8) + (1 umin (-4 + (4 smax (-4 + %n)))<nsw>)))<nsw> + %n) LoopDispositions: { %while.body: Computable }15; CHECK-NEXT: Determining loop execution counts for: @simple16; CHECK-NEXT: Loop %while.body: backedge-taken count is (((-4 + (-1 * (1 umin (-4 + (4 smax (-4 + %n)))<nsw>))<nuw><nsw> + (4 smax (-4 + %n))) /u 8) + (1 umin (-4 + (4 smax (-4 + %n)))<nsw>))17; CHECK-NEXT: Loop %while.body: constant max backedge-taken count is i32 53687091018; CHECK-NEXT: Loop %while.body: symbolic max backedge-taken count is (((-4 + (-1 * (1 umin (-4 + (4 smax (-4 + %n)))<nsw>))<nuw><nsw> + (4 smax (-4 + %n))) /u 8) + (1 umin (-4 + (4 smax (-4 + %n)))<nsw>))19; CHECK-NEXT: Loop %while.body: Trip multiple is 120;21entry:22 %cmp4 = icmp sgt i32 %n, 023 br i1 %cmp4, label %while.body, label %while.end24 25while.body:26 %right.06 = phi i32 [ %dec, %while.body ], [ %n, %entry ]27 %left.05 = phi i32 [ %inc, %while.body ], [ 0, %entry ]28 %inc = add nuw nsw i32 %left.05, 429 %dec = add nsw i32 %right.06, -430 %cmp = icmp slt i32 %inc, %dec31 br i1 %cmp, label %while.body, label %while.end32 33while.end:34 ret void35}36 37; Cannot find backedge-count because subtraction of strides is wrapping.38define dso_local void @stride_overflow(i32 noundef %n) local_unnamed_addr {39; CHECK-LABEL: 'stride_overflow'40; CHECK-NEXT: Classifying expressions for: @stride_overflow41; CHECK-NEXT: %right.06 = phi i32 [ %dec, %while.body ], [ %n, %entry ]42; CHECK-NEXT: --> {%n,+,-1}<nsw><%while.body> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %while.body: Computable }43; CHECK-NEXT: %left.05 = phi i32 [ %inc, %while.body ], [ 2147483647, %entry ]44; CHECK-NEXT: --> {2147483647,+,2147483647}<nuw><nsw><%while.body> U: [2147483647,-2147483648) S: [2147483647,-2147483648) Exits: <<Unknown>> LoopDispositions: { %while.body: Computable }45; CHECK-NEXT: %inc = add nuw nsw i32 %left.05, 214748364746; CHECK-NEXT: --> {-2,+,2147483647}<nuw><nsw><%while.body> U: [-2,-1) S: [-2,0) Exits: <<Unknown>> LoopDispositions: { %while.body: Computable }47; CHECK-NEXT: %dec = add nsw i32 %right.06, -148; CHECK-NEXT: --> {(-1 + %n),+,-1}<nsw><%while.body> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %while.body: Computable }49; CHECK-NEXT: Determining loop execution counts for: @stride_overflow50; CHECK-NEXT: Loop %while.body: Unpredictable backedge-taken count.51; CHECK-NEXT: Loop %while.body: constant max backedge-taken count is i32 152; CHECK-NEXT: Loop %while.body: symbolic max backedge-taken count is i32 153;54entry:55 %cmp4 = icmp sgt i32 %n, 056 br i1 %cmp4, label %while.body, label %while.end57 58while.body:59 %right.06 = phi i32 [ %dec, %while.body ], [ %n, %entry ]60 %left.05 = phi i32 [ %inc, %while.body ], [ 2147483647, %entry ]61 %inc = add nuw nsw i32 %left.05, 214748364762 %dec = add nsw i32 %right.06, -163 %cmp = icmp slt i32 %inc, %dec64 br i1 %cmp, label %while.body, label %while.end65 66while.end:67 ret void68}69 70; Cannot find backedge-count because %conv110 is wrapping71define dso_local void @rhs_wrapping() local_unnamed_addr {72; CHECK-LABEL: 'rhs_wrapping'73; CHECK-NEXT: Classifying expressions for: @rhs_wrapping74; CHECK-NEXT: %a = alloca i8, align 175; CHECK-NEXT: --> %a U: full-set S: full-set76; CHECK-NEXT: %conv110 = phi i32 [ 0, %entry ], [ %sext8, %while.body ]77; CHECK-NEXT: --> {0,+,-1090519040}<%while.body> U: [0,-16777215) S: [-2147483648,2130706433) Exits: <<Unknown>> LoopDispositions: { %while.body: Computable }78; CHECK-NEXT: %conv9 = phi i32 [ -2147483648, %entry ], [ %sext, %while.body ]79; CHECK-NEXT: --> {-2147483648,+,16777216}<nsw><%while.body> U: [0,-16777215) S: [-2147483648,2113929217) Exits: <<Unknown>> LoopDispositions: { %while.body: Computable }80; CHECK-NEXT: %sext = add nsw i32 %conv9, 1677721681; CHECK-NEXT: --> {-2130706432,+,16777216}<nsw><%while.body> U: [0,-16777215) S: [-2130706432,2130706433) Exits: <<Unknown>> LoopDispositions: { %while.body: Computable }82; CHECK-NEXT: %sext8 = add i32 %conv110, -109051904083; CHECK-NEXT: --> {-1090519040,+,-1090519040}<%while.body> U: [0,-16777215) S: [-2147483648,2130706433) Exits: <<Unknown>> LoopDispositions: { %while.body: Computable }84; CHECK-NEXT: Determining loop execution counts for: @rhs_wrapping85; CHECK-NEXT: Loop %while.body: Unpredictable backedge-taken count.86; CHECK-NEXT: Loop %while.body: constant max backedge-taken count is i32 25487; CHECK-NEXT: Loop %while.body: symbolic max backedge-taken count is i32 25488;89entry:90 %a = alloca i8, align 191 br label %while.body92 93while.body:94 %conv110 = phi i32 [ 0, %entry ], [ %sext8, %while.body ]95 %conv9 = phi i32 [ -2147483648, %entry ], [ %sext, %while.body ]96 %sext = add nsw i32 %conv9, 1677721697 %sext8 = add i32 %conv110, -109051904098 %cmp = icmp slt i32 %sext, %sext899 br i1 %cmp, label %while.body, label %while.end100 101while.end:102 ret void103}104 105; abs(left_stride) != abs(right_stride)106define dso_local void @simple2() local_unnamed_addr {107; CHECK-LABEL: 'simple2'108; CHECK-NEXT: Classifying expressions for: @simple2109; CHECK-NEXT: %right.08 = phi i32 [ 50, %entry ], [ %add2, %while.body ]110; CHECK-NEXT: --> {50,+,-5}<nsw><%while.body> U: [25,51) S: [25,51) Exits: 25 LoopDispositions: { %while.body: Computable }111; CHECK-NEXT: %left.07 = phi i32 [ 0, %entry ], [ %add, %while.body ]112; CHECK-NEXT: --> {0,+,4}<nuw><nsw><%while.body> U: [0,21) S: [0,21) Exits: 20 LoopDispositions: { %while.body: Computable }113; CHECK-NEXT: %add = add nuw nsw i32 %left.07, 4114; CHECK-NEXT: --> {4,+,4}<nuw><nsw><%while.body> U: [4,25) S: [4,25) Exits: 24 LoopDispositions: { %while.body: Computable }115; CHECK-NEXT: %add2 = add nsw i32 %right.08, -5116; CHECK-NEXT: --> {45,+,-5}<nsw><%while.body> U: [20,46) S: [20,46) Exits: 20 LoopDispositions: { %while.body: Computable }117; CHECK-NEXT: Determining loop execution counts for: @simple2118; CHECK-NEXT: Loop %while.body: backedge-taken count is i32 5119; CHECK-NEXT: Loop %while.body: constant max backedge-taken count is i32 5120; CHECK-NEXT: Loop %while.body: symbolic max backedge-taken count is i32 5121; CHECK-NEXT: Loop %while.body: Trip multiple is 6122;123entry:124 br label %while.body125 126while.body:127 %right.08 = phi i32 [ 50, %entry ], [ %add2, %while.body ]128 %left.07 = phi i32 [ 0, %entry ], [ %add, %while.body ]129 %add = add nuw nsw i32 %left.07, 4130 %add2 = add nsw i32 %right.08, -5131 %cmp = icmp slt i32 %add, %add2132 br i1 %cmp, label %while.body, label %while.end133 134while.end:135 ret void136}137