1 ; ; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s 2 3 define void @infer.sext.0(i1* %c, i32 %start) { 4 ; CHECK-LABEL: Classifying expressions for: @infer.sext.0 5 entry: 6 br label %loop 7 8 loop: 9 %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ] 10 %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ] 11 %idx.inc = add nsw i32 %idx, 1 12 %idx.inc.sext = sext i32 %idx.inc to i64 13 ; CHECK: %idx.inc.sext = sext i32 %idx.inc to i64 14 ; CHECK-NEXT: --> {(1 + (sext i32 %start to i64)),+,1}<nsw><%loop> 15 %condition = icmp eq i32 %counter, 1 16 %counter.inc = add i32 %counter, 1 17 br i1 %condition, label %exit, label %loop 18 19 exit: 20 ret void 21 } 22 23 define void @infer.zext.0(i1* %c, i32 %start) { 24 ; CHECK-LABEL: Classifying expressions for: @infer.zext.0 25 entry: 26 br label %loop 27 28 loop: 29 %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ] 30 %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ] 31 %idx.inc = add nuw i32 %idx, 1 32 %idx.inc.sext = zext i32 %idx.inc to i64 33 ; CHECK: %idx.inc.sext = zext i32 %idx.inc to i64 34 ; CHECK-NEXT: --> {(1 + (zext i32 %start to i64)),+,1}<nuw><%loop> 35 %condition = icmp eq i32 %counter, 1 36 %counter.inc = add i32 %counter, 1 37 br i1 %condition, label %exit, label %loop 38 39 exit: 40 ret void 41 } 42 43 define void @infer.sext.1(i32 %start, i1* %c) { 44 ; CHECK-LABEL: Classifying expressions for: @infer.sext.1 45 entry: 46 %start.mul = mul i32 %start, 4 47 %start.real = add i32 %start.mul, 2 48 br label %loop 49 50 loop: 51 %idx = phi i32 [ %start.real, %entry ], [ %idx.inc, %loop ] 52 %idx.sext = sext i32 %idx to i64 53 ; CHECK: %idx.sext = sext i32 %idx to i64 54 ; CHECK-NEXT: --> {(2 + (sext i32 (4 * %start) to i64)),+,2}<nsw><%loop> 55 %idx.inc = add nsw i32 %idx, 2 56 %condition = load i1, i1* %c 57 br i1 %condition, label %exit, label %loop 58 59 exit: 60 ret void 61 } 62 63 define void @infer.sext.2(i1* %c, i8 %start) { 64 ; CHECK-LABEL: Classifying expressions for: @infer.sext.2 65 entry: 66 %start.inc = add i8 %start, 1 67 %entry.condition = icmp slt i8 %start, 127 68 br i1 %entry.condition, label %loop, label %exit 69 70 loop: 71 %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ] 72 %idx.sext = sext i8 %idx to i16 73 ; CHECK: %idx.sext = sext i8 %idx to i16 74 ; CHECK-NEXT: --> {(1 + (sext i8 %start to i16)),+,1}<nsw><%loop> 75 %idx.inc = add nsw i8 %idx, 1 76 %condition = load volatile i1, i1* %c 77 br i1 %condition, label %exit, label %loop 78 79 exit: 80 ret void 81 } 82 83 define void @infer.zext.1(i1* %c, i8 %start) { 84 ; CHECK-LABEL: Classifying expressions for: @infer.zext.1 85 entry: 86 %start.inc = add i8 %start, 1 87 %entry.condition = icmp ult i8 %start, 255 88 br i1 %entry.condition, label %loop, label %exit 89 90 loop: 91 %idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ] 92 %idx.zext = zext i8 %idx to i16 93 ; CHECK: %idx.zext = zext i8 %idx to i16 94 ; CHECK-NEXT: --> {(1 + (zext i8 %start to i16)),+,1}<nuw><%loop> 95 %idx.inc = add nuw i8 %idx, 1 96 %condition = load volatile i1, i1* %c 97 br i1 %condition, label %exit, label %loop 98 99 exit: 100 ret void 101 } 102