summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-07-12 22:08:48 +0000
committerAndrew Trick <atrick@apple.com>2013-07-12 22:08:48 +0000
commit16404cc817e8b8d3fbfbc9051394eb59d7c5ffb4 (patch)
treec38db272b7095a3c70a84d9d8e5ca205b93c08e4 /test
parent807e6c71a8d13531ec359006e3b6526ae70064a8 (diff)
downloadllvm-16404cc817e8b8d3fbfbc9051394eb59d7c5ffb4.tar.gz
llvm-16404cc817e8b8d3fbfbc9051394eb59d7c5ffb4.tar.bz2
llvm-16404cc817e8b8d3fbfbc9051394eb59d7c5ffb4.tar.xz
LFTR improvement to avoid truncation.
This is a reimplemntation of the patch originally in r186107. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186215 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/IndVarSimplify/lftr-extend-const.ll44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/Transforms/IndVarSimplify/lftr-extend-const.ll b/test/Transforms/IndVarSimplify/lftr-extend-const.ll
new file mode 100644
index 0000000000..18e1507764
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/lftr-extend-const.ll
@@ -0,0 +1,44 @@
+;RUN: opt -S %s -indvars | FileCheck %s
+
+; CHECK-LABEL: @foo
+; CHECK-NOT: %lftr.wideiv = trunc i32 %indvars.iv.next to i16
+; CHECK: %exitcond = icmp ne i32 %indvars.iv.next, 512
+define void @foo() #0 {
+entry:
+ br label %for.body
+
+for.body: ; preds = %entry, %for.body
+ %i.01 = phi i16 [ 0, %entry ], [ %inc, %for.body ]
+ %conv2 = sext i16 %i.01 to i32
+ call void @bar(i32 %conv2) #1
+ %inc = add i16 %i.01, 1
+ %cmp = icmp slt i16 %inc, 512
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end: ; preds = %for.body
+ ret void
+}
+
+; Check that post-incrementing the backedge taken count does not overflow.
+; CHECK-LABEL: @postinc
+; CHECK: icmp eq i32 %indvars.iv.next, 256
+define i32 @postinc() #0 {
+entry:
+ br label %do.body
+
+do.body: ; preds = %do.body, %entry
+ %first.0 = phi i8 [ 0, %entry ], [ %inc, %do.body ]
+ %conv = zext i8 %first.0 to i32
+ call void @bar(i32 %conv) #1
+ %inc = add i8 %first.0, 1
+ %cmp = icmp eq i8 %first.0, -1
+ br i1 %cmp, label %do.end, label %do.body
+
+do.end: ; preds = %do.body
+ ret i32 0
+}
+
+declare void @bar(i32)
+
+attributes #0 = { nounwind uwtable }
+attributes #1 = { nounwind }