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