aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-07-11 17:08:59 +0000
committerAndrew Trick <atrick@apple.com>2013-07-11 17:08:59 +0000
commit53b28f86236fc548143656929f39f38d9dc83e06 (patch)
treed7317e129df2e3231363fdc512ddb8fe5cb691ed /test
parent53c86db25b5b4e163c68dc91c8ce1bc8180e6ff3 (diff)
downloadexternal_llvm-53b28f86236fc548143656929f39f38d9dc83e06.zip
external_llvm-53b28f86236fc548143656929f39f38d9dc83e06.tar.gz
external_llvm-53b28f86236fc548143656929f39f38d9dc83e06.tar.bz2
indvars: Improve LFTR by eliminating truncation when comparing against a constant.
Patch by Michele Scandale! Adds a special handling of the case where, during the loop exit condition rewriting, the exit value is a constant of bitwidth lower than the type of the induction variable: instead of introducing a trunc operation in order to match correctly the operand types, it allows to convert the constant value to an equivalent constant, depending on the initial value of the induction variable and the trip count, in order have an equivalent comparison between the induction variable and the new constant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/IndVarSimplify/exitcnt-const-arstart-const-opt.ll25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Transforms/IndVarSimplify/exitcnt-const-arstart-const-opt.ll b/test/Transforms/IndVarSimplify/exitcnt-const-arstart-const-opt.ll
new file mode 100644
index 0000000..185a67f
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/exitcnt-const-arstart-const-opt.ll
@@ -0,0 +1,25 @@
+;RUN: opt -S %s -indvars | FileCheck %s
+
+; Function Attrs: nounwind uwtable
+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
+;CHECK-NOT: %lftr.wideiv = trunc i32 %indvars.iv.next to i16
+;CHECK: %exitcond = icmp ne i32 %indvars.iv.next, 512
+ %cmp = icmp slt i16 %inc, 512
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end: ; preds = %for.body
+ ret void
+}
+
+declare void @bar(i32)
+
+attributes #0 = { nounwind uwtable }
+attributes #1 = { nounwind }