aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/IndVarSimplify/signed-trip-count.ll
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-02-18 17:22:41 +0000
committerDan Gohman <gohman@apple.com>2009-02-18 17:22:41 +0000
commitf5a309e989b8d2199cb542793e9edf48395d9fed (patch)
treec52543300d485f04baebd2bc1ee8f1fb7721a411 /test/Transforms/IndVarSimplify/signed-trip-count.ll
parentcad24c9abc834db5cf8f92019f99370507d8d07a (diff)
downloadexternal_llvm-f5a309e989b8d2199cb542793e9edf48395d9fed.zip
external_llvm-f5a309e989b8d2199cb542793e9edf48395d9fed.tar.gz
external_llvm-f5a309e989b8d2199cb542793e9edf48395d9fed.tar.bz2
Use a sign-extend instead of a zero-extend when promoting a
trip count value when the original loop iteration condition is signed and the canonical induction variable won't undergo signed overflow. This isn't required for correctness; it just preserves more information about original loop iteration values. Add a getTruncateOrSignExtend method to ScalarEvolution, following getTruncateOrZeroExtend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/IndVarSimplify/signed-trip-count.ll')
-rw-r--r--test/Transforms/IndVarSimplify/signed-trip-count.ll31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/Transforms/IndVarSimplify/signed-trip-count.ll b/test/Transforms/IndVarSimplify/signed-trip-count.ll
new file mode 100644
index 0000000..cea9f82
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/signed-trip-count.ll
@@ -0,0 +1,31 @@
+; RUN: llvm-as < %s | opt -indvars | llvm-dis > %t
+; RUN: grep { = sext i32 %n} %t
+; RUN: grep phi %t | count 1
+; RUN: not grep zext %t
+
+define void @foo(i64* nocapture %x, i32 %n) nounwind {
+entry:
+ %tmp102 = icmp sgt i32 %n, 0 ; <i1> [#uses=1]
+ br i1 %tmp102, label %bb.nph, label %return
+
+bb.nph: ; preds = %entry
+ br label %bb
+
+bb: ; preds = %bb7, %bb.nph
+ %i.01 = phi i32 [ %tmp6, %bb7 ], [ 0, %bb.nph ] ; <i32> [#uses=3]
+ %tmp1 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
+ %tmp4 = getelementptr i64* %x, i32 %i.01 ; <i64*> [#uses=1]
+ store i64 %tmp1, i64* %tmp4, align 8
+ %tmp6 = add i32 %i.01, 1 ; <i32> [#uses=2]
+ br label %bb7
+
+bb7: ; preds = %bb
+ %tmp10 = icmp slt i32 %tmp6, %n ; <i1> [#uses=1]
+ br i1 %tmp10, label %bb, label %bb7.return_crit_edge
+
+bb7.return_crit_edge: ; preds = %bb7
+ br label %return
+
+return: ; preds = %bb7.return_crit_edge, %entry
+ ret void
+}