1 ; ; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
3 define void @infer.sext.0(i1* %c, i32 %start, i32* %buf) {
4 ; CHECK-LABEL: Classifying expressions for: @infer.sext.0
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>
16 %buf.gep = getelementptr inbounds i32, i32* %buf, i32 %idx.inc
17 %val = load i32, i32* %buf.gep
19 %condition = icmp eq i32 %counter, 1
20 %counter.inc = add i32 %counter, 1
21 br i1 %condition, label %exit, label %loop
27 define void @infer.zext.0(i1* %c, i32 %start, i32* %buf) {
28 ; CHECK-LABEL: Classifying expressions for: @infer.zext.0
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>
40 %buf.gep = getelementptr inbounds i32, i32* %buf, i32 %idx.inc
41 %val = load i32, i32* %buf.gep
43 %condition = icmp eq i32 %counter, 1
44 %counter.inc = add i32 %counter, 1
45 br i1 %condition, label %exit, label %loop
51 define void @infer.sext.1(i32 %start, i1* %c) {
52 ; CHECK-LABEL: Classifying expressions for: @infer.sext.1
54 %start.mul = mul i32 %start, 4
55 %start.real = add i32 %start.mul, 2
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))<nuw><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
71 define void @infer.sext.2(i1* %c, i8 %start) {
72 ; CHECK-LABEL: Classifying expressions for: @infer.sext.2
74 %start.inc = add i8 %start, 1
75 %entry.condition = icmp slt i8 %start, 127
76 br i1 %entry.condition, label %loop, label %exit
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
91 define void @infer.zext.1(i1* %c, i8 %start) {
92 ; CHECK-LABEL: Classifying expressions for: @infer.zext.1
94 %start.inc = add i8 %start, 1
95 %entry.condition = icmp ult i8 %start, 255
96 br i1 %entry.condition, label %loop, label %exit
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