1 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
3 ; An example run where SCEV(%postinc)->getStart() may overflow:
6 ; %low.limit = INT_SMIN
7 ; %high.limit = < not used >
10 ; %postinc.start = INT_SMIN
15 ; %postinc.inc = INT_SMIN + 1
16 ; %postinc.sext = sext(INT_SMIN) = i64 INT32_SMIN
17 ; %break.early = INT_SMIN `slt` INT_SMIN = false
18 ; br i1 false, ___, %early.exit
24 define i64 @bad.0(i32 %start, i32 %low.limit, i32 %high.limit) {
25 ; CHECK-LABEL: Classifying expressions for: @bad.0
27 %postinc.start = add i32 %start, 1
31 %idx = phi i32 [ %start, %entry ], [ %idx.inc, %continue ]
32 %postinc = phi i32 [ %postinc.start, %entry ], [ %postinc.inc, %continue ]
33 %postinc.inc = add nsw i32 %postinc, 1
34 %postinc.sext = sext i32 %postinc to i64
35 ; CHECK: %postinc.sext = sext i32 %postinc to i64
36 ; CHECK-NEXT: --> {(sext i32 (1 + %start) to i64),+,1}<nsw><%loop>
37 %break.early = icmp slt i32 %postinc, %low.limit
38 br i1 %break.early, label %continue, label %early.exit
41 %idx.inc = add nsw i32 %idx, 1
42 %cmp = icmp slt i32 %idx.inc, %high.limit
43 br i1 %cmp, label %loop, label %exit
52 define i64 @bad.1(i32 %start, i32 %low.limit, i32 %high.limit, ptr %unknown) {
53 ; CHECK-LABEL: Classifying expressions for: @bad.1
55 %postinc.start = add i32 %start, 1
59 %idx = phi i32 [ %start, %entry ], [ %idx.inc, %continue ], [ %idx.inc, %continue.1 ]
60 %postinc = phi i32 [ %postinc.start, %entry ], [ %postinc.inc, %continue ], [ %postinc.inc, %continue.1 ]
61 %postinc.inc = add nsw i32 %postinc, 1
62 %postinc.sext = sext i32 %postinc to i64
63 ; CHECK: %postinc.sext = sext i32 %postinc to i64
64 ; CHECK-NEXT: --> {(sext i32 (1 + %start) to i64),+,1}<nsw><%loop>
65 %break.early = icmp slt i32 %postinc, %low.limit
66 br i1 %break.early, label %continue.1, label %early.exit
69 %cond = load volatile i1, ptr %unknown
70 %idx.inc = add nsw i32 %idx, 1
71 br i1 %cond, label %loop, label %continue
74 %cmp = icmp slt i32 %idx.inc, %high.limit
75 br i1 %cmp, label %loop, label %exit