aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis/ScalarEvolution/scev-prestart-nowrap.ll
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2015-03-23 12:10:34 -0700
committerStephen Hines <srhines@google.com>2015-03-23 12:10:34 -0700
commitebe69fe11e48d322045d5949c83283927a0d790b (patch)
treec92f1907a6b8006628a4b01615f38264d29834ea /test/Analysis/ScalarEvolution/scev-prestart-nowrap.ll
parentb7d2e72b02a4cb8034f32f8247a2558d2434e121 (diff)
downloadexternal_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.zip
external_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.tar.gz
external_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.tar.bz2
Update aosp/master LLVM for rebase to r230699.
Change-Id: I2b5be30509658cb8266be782de0ab24f9099f9b9
Diffstat (limited to 'test/Analysis/ScalarEvolution/scev-prestart-nowrap.ll')
-rw-r--r--test/Analysis/ScalarEvolution/scev-prestart-nowrap.ll82
1 files changed, 82 insertions, 0 deletions
diff --git a/test/Analysis/ScalarEvolution/scev-prestart-nowrap.ll b/test/Analysis/ScalarEvolution/scev-prestart-nowrap.ll
new file mode 100644
index 0000000..3ca32bd
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/scev-prestart-nowrap.ll
@@ -0,0 +1,82 @@
+; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
+
+; An example run where SCEV(%postinc)->getStart() may overflow:
+;
+; %start = INT_SMAX
+; %low.limit = INT_SMIN
+; %high.limit = < not used >
+;
+; >> entry:
+; %postinc.start = INT_SMIN
+;
+; >> loop:
+; %idx = %start
+; %postinc = INT_SMIN
+; %postinc.inc = INT_SMIN + 1
+; %postinc.sext = sext(INT_SMIN) = i64 INT32_SMIN
+; %break.early = INT_SMIN `slt` INT_SMIN = false
+; br i1 false, ___, %early.exit
+;
+; >> early.exit:
+; ret i64 INT32_SMIN
+
+
+define i64 @bad.0(i32 %start, i32 %low.limit, i32 %high.limit) {
+; CHECK-LABEL: Classifying expressions for: @bad.0
+ entry:
+ %postinc.start = add i32 %start, 1
+ br label %loop
+
+ loop:
+ %idx = phi i32 [ %start, %entry ], [ %idx.inc, %continue ]
+ %postinc = phi i32 [ %postinc.start, %entry ], [ %postinc.inc, %continue ]
+ %postinc.inc = add nsw i32 %postinc, 1
+ %postinc.sext = sext i32 %postinc to i64
+; CHECK: %postinc.sext = sext i32 %postinc to i64
+; CHECK-NEXT: --> {(sext i32 (1 + %start) to i64),+,1}<nsw><%loop>
+ %break.early = icmp slt i32 %postinc, %low.limit
+ br i1 %break.early, label %continue, label %early.exit
+
+ continue:
+ %idx.inc = add nsw i32 %idx, 1
+ %cmp = icmp slt i32 %idx.inc, %high.limit
+ br i1 %cmp, label %loop, label %exit
+
+ exit:
+ ret i64 0
+
+ early.exit:
+ ret i64 %postinc.sext
+}
+
+define i64 @bad.1(i32 %start, i32 %low.limit, i32 %high.limit, i1* %unknown) {
+; CHECK-LABEL: Classifying expressions for: @bad.1
+ entry:
+ %postinc.start = add i32 %start, 1
+ br label %loop
+
+ loop:
+ %idx = phi i32 [ %start, %entry ], [ %idx.inc, %continue ], [ %idx.inc, %continue.1 ]
+ %postinc = phi i32 [ %postinc.start, %entry ], [ %postinc.inc, %continue ], [ %postinc.inc, %continue.1 ]
+ %postinc.inc = add nsw i32 %postinc, 1
+ %postinc.sext = sext i32 %postinc to i64
+; CHECK: %postinc.sext = sext i32 %postinc to i64
+; CHECK-NEXT: --> {(sext i32 (1 + %start) to i64),+,1}<nsw><%loop>
+ %break.early = icmp slt i32 %postinc, %low.limit
+ br i1 %break.early, label %continue.1, label %early.exit
+
+ continue.1:
+ %cond = load volatile i1* %unknown
+ %idx.inc = add nsw i32 %idx, 1
+ br i1 %cond, label %loop, label %continue
+
+ continue:
+ %cmp = icmp slt i32 %idx.inc, %high.limit
+ br i1 %cmp, label %loop, label %exit
+
+ exit:
+ ret i64 0
+
+ early.exit:
+ ret i64 %postinc.sext
+}