1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5 2; RUN: opt -disable-output -passes="print<scalar-evolution>" < %s 2>&1 | FileCheck %s 3 4define void @infer.sext.0(ptr %c, i32 %start, ptr %buf) { 5; CHECK-LABEL: 'infer.sext.0' 6; CHECK-NEXT: Classifying expressions for: @infer.sext.0 7; CHECK-NEXT: %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ] 8; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,2) S: [0,2) Exits: 1 LoopDispositions: { %loop: Computable } 9; CHECK-NEXT: %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ] 10; CHECK-NEXT: --> {%start,+,1}<nsw><%loop> U: full-set S: full-set Exits: (1 + %start) LoopDispositions: { %loop: Computable } 11; CHECK-NEXT: %idx.inc = add nsw i32 %idx, 1 12; CHECK-NEXT: --> {(1 + %start)<nsw>,+,1}<nsw><%loop> U: full-set S: full-set Exits: (2 + %start) LoopDispositions: { %loop: Computable } 13; CHECK-NEXT: %idx.inc.sext = sext i32 %idx.inc to i64 14; CHECK-NEXT: --> {(1 + (sext i32 %start to i64))<nsw>,+,1}<nsw><%loop> U: [-2147483647,2147483650) S: [-2147483647,2147483650) Exits: (2 + (sext i32 %start to i64))<nsw> LoopDispositions: { %loop: Computable } 15; CHECK-NEXT: %buf.gep = getelementptr inbounds i32, ptr %buf, i32 %idx.inc 16; CHECK-NEXT: --> {(4 + (4 * (sext i32 %start to i64))<nsw> + %buf),+,4}<nw><%loop> U: full-set S: full-set Exits: (8 + (4 * (sext i32 %start to i64))<nsw> + %buf) LoopDispositions: { %loop: Computable } 17; CHECK-NEXT: %val = load i32, ptr %buf.gep, align 4 18; CHECK-NEXT: --> %val U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant } 19; CHECK-NEXT: %counter.inc = add i32 %counter, 1 20; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,3) S: [1,3) Exits: 2 LoopDispositions: { %loop: Computable } 21; CHECK-NEXT: Determining loop execution counts for: @infer.sext.0 22; CHECK-NEXT: Loop %loop: backedge-taken count is i32 1 23; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 1 24; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is i32 1 25; CHECK-NEXT: Loop %loop: Trip multiple is 2 26; 27 entry: 28 br label %loop 29 30 loop: 31 %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ] 32 %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ] 33 %idx.inc = add nsw i32 %idx, 1 34 %idx.inc.sext = sext i32 %idx.inc to i64 35 36 %buf.gep = getelementptr inbounds i32, ptr %buf, i32 %idx.inc 37 %val = load i32, ptr %buf.gep 38 39 %condition = icmp eq i32 %counter, 1 40 %counter.inc = add i32 %counter, 1 41 br i1 %condition, label %exit, label %loop 42 43 exit: 44 ret void 45} 46 47define void @infer.zext.0(ptr %c, i32 %start, ptr %buf) { 48; CHECK-LABEL: 'infer.zext.0' 49; CHECK-NEXT: Classifying expressions for: @infer.zext.0 50; CHECK-NEXT: %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ] 51; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,2) S: [0,2) Exits: 1 LoopDispositions: { %loop: Computable } 52; CHECK-NEXT: %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ] 53; CHECK-NEXT: --> {%start,+,1}<nuw><%loop> U: full-set S: full-set Exits: (1 + %start) LoopDispositions: { %loop: Computable } 54; CHECK-NEXT: %idx.inc = add nuw i32 %idx, 1 55; CHECK-NEXT: --> {(1 + %start)<nuw>,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: (2 + %start) LoopDispositions: { %loop: Computable } 56; CHECK-NEXT: %idx.inc.sext = zext i32 %idx.inc to i64 57; CHECK-NEXT: --> {(1 + (zext i32 %start to i64))<nuw><nsw>,+,1}<nuw><%loop> U: [1,4294967298) S: [1,4294967298) Exits: (2 + (zext i32 %start to i64))<nuw><nsw> LoopDispositions: { %loop: Computable } 58; CHECK-NEXT: %buf.gep = getelementptr inbounds i32, ptr %buf, i32 %idx.inc 59; CHECK-NEXT: --> ((4 * (sext i32 {(1 + %start)<nuw>,+,1}<nuw><%loop> to i64))<nsw> + %buf) U: full-set S: full-set Exits: ((4 * (sext i32 (2 + %start) to i64))<nsw> + %buf) LoopDispositions: { %loop: Computable } 60; CHECK-NEXT: %val = load i32, ptr %buf.gep, align 4 61; CHECK-NEXT: --> %val U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant } 62; CHECK-NEXT: %counter.inc = add i32 %counter, 1 63; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,3) S: [1,3) Exits: 2 LoopDispositions: { %loop: Computable } 64; CHECK-NEXT: Determining loop execution counts for: @infer.zext.0 65; CHECK-NEXT: Loop %loop: backedge-taken count is i32 1 66; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 1 67; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is i32 1 68; CHECK-NEXT: Loop %loop: Trip multiple is 2 69; 70 entry: 71 br label %loop 72 73 loop: 74 %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ] 75 %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ] 76 %idx.inc = add nuw i32 %idx, 1 77 %idx.inc.sext = zext i32 %idx.inc to i64 78 79 %buf.gep = getelementptr inbounds i32, ptr %buf, i32 %idx.inc 80 %val = load i32, ptr %buf.gep 81 82 %condition = icmp eq i32 %counter, 1 83 %counter.inc = add i32 %counter, 1 84 br i1 %condition, label %exit, label %loop 85 86 exit: 87 ret void 88} 89 90define void @infer.sext.1(i32 %start, ptr %c) { 91; CHECK-LABEL: 'infer.sext.1' 92; CHECK-NEXT: Classifying expressions for: @infer.sext.1 93; CHECK-NEXT: %start.mul = mul i32 %start, 4 94; CHECK-NEXT: --> (4 * %start) U: [0,-3) S: [-2147483648,2147483645) 95; CHECK-NEXT: %start.real = add i32 %start.mul, 2 96; CHECK-NEXT: --> (2 + (4 * %start))<nuw><nsw> U: [2,-1) S: [-2147483646,2147483647) 97; CHECK-NEXT: %idx = phi i32 [ %start.real, %entry ], [ %idx.inc, %loop ] 98; CHECK-NEXT: --> {(2 + (4 * %start))<nuw><nsw>,+,2}<nsw><%loop> U: [0,-1) S: [-2147483646,2147483647) Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 99; CHECK-NEXT: %idx.sext = sext i32 %idx to i64 100; CHECK-NEXT: --> {(2 + (sext i32 (4 * %start) to i64))<nuw><nsw>,+,2}<nsw><%loop> U: [0,-1) S: [-2147483646,9223372036854775807) Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 101; CHECK-NEXT: %idx.inc = add nsw i32 %idx, 2 102; CHECK-NEXT: --> {(4 + (4 * %start)),+,2}<nw><%loop> U: [0,-1) S: [-2147483648,2147483647) Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 103; CHECK-NEXT: %condition = load i1, ptr %c, align 1 104; CHECK-NEXT: --> %condition U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant } 105; CHECK-NEXT: Determining loop execution counts for: @infer.sext.1 106; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. 107; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count. 108; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count. 109; 110 entry: 111 %start.mul = mul i32 %start, 4 112 %start.real = add i32 %start.mul, 2 113 br label %loop 114 115 loop: 116 %idx = phi i32 [ %start.real, %entry ], [ %idx.inc, %loop ] 117 %idx.sext = sext i32 %idx to i64 118 %idx.inc = add nsw i32 %idx, 2 119 %condition = load i1, ptr %c 120 br i1 %condition, label %exit, label %loop 121 122 exit: 123 ret void 124} 125 126define void @infer.sext.2(ptr %c, i8 %start) { 127; CHECK-LABEL: 'infer.sext.2' 128; CHECK-NEXT: Classifying expressions for: @infer.sext.2 129; CHECK-NEXT: %start.inc = add i8 %start, 1 130; CHECK-NEXT: --> (1 + %start) U: full-set S: full-set 131; CHECK-NEXT: %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ] 132; CHECK-NEXT: --> {(1 + %start),+,1}<nsw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 133; CHECK-NEXT: %idx.sext = sext i8 %idx to i16 134; CHECK-NEXT: --> {(1 + (sext i8 %start to i16))<nsw>,+,1}<nsw><%loop> U: [-127,-32768) S: [-127,-32768) Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 135; CHECK-NEXT: %idx.inc = add nsw i8 %idx, 1 136; CHECK-NEXT: --> {(2 + %start),+,1}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 137; CHECK-NEXT: %condition = load volatile i1, ptr %c, align 1 138; CHECK-NEXT: --> %condition U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant } 139; CHECK-NEXT: Determining loop execution counts for: @infer.sext.2 140; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. 141; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count. 142; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count. 143; 144 entry: 145 %start.inc = add i8 %start, 1 146 %entry.condition = icmp slt i8 %start, 127 147 br i1 %entry.condition, label %loop, label %exit 148 149 loop: 150 %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ] 151 %idx.sext = sext i8 %idx to i16 152 %idx.inc = add nsw i8 %idx, 1 153 %condition = load volatile i1, ptr %c 154 br i1 %condition, label %exit, label %loop 155 156 exit: 157 ret void 158} 159 160define void @infer.zext.1(ptr %c, i8 %start) { 161; CHECK-LABEL: 'infer.zext.1' 162; CHECK-NEXT: Classifying expressions for: @infer.zext.1 163; CHECK-NEXT: %start.inc = add i8 %start, 1 164; CHECK-NEXT: --> (1 + %start) U: full-set S: full-set 165; CHECK-NEXT: %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ] 166; CHECK-NEXT: --> {(1 + %start),+,1}<nuw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 167; CHECK-NEXT: %idx.zext = zext i8 %idx to i16 168; CHECK-NEXT: --> {(1 + (zext i8 %start to i16))<nuw><nsw>,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 169; CHECK-NEXT: %idx.inc = add nuw i8 %idx, 1 170; CHECK-NEXT: --> {(2 + %start),+,1}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable } 171; CHECK-NEXT: %condition = load volatile i1, ptr %c, align 1 172; CHECK-NEXT: --> %condition U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant } 173; CHECK-NEXT: Determining loop execution counts for: @infer.zext.1 174; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count. 175; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count. 176; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count. 177; 178 entry: 179 %start.inc = add i8 %start, 1 180 %entry.condition = icmp ult i8 %start, 255 181 br i1 %entry.condition, label %loop, label %exit 182 183 loop: 184 %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ] 185 %idx.zext = zext i8 %idx to i16 186 %idx.inc = add nuw i8 %idx, 1 187 %condition = load volatile i1, ptr %c 188 br i1 %condition, label %exit, label %loop 189 190 exit: 191 ret void 192} 193