summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/IndVarSimplify/pointer.ll
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-14 22:58:51 +0000
committerDan Gohman <gohman@apple.com>2009-06-14 22:58:51 +0000
commit038d02e74e0dcf33b0ce866c71b0d886e9577777 (patch)
tree08dea987025324b7f00a269e5921481bb1b744ff /llvm/test/Transforms/IndVarSimplify/pointer.ll
parent8448acc8ba94bb2260523ab38633721a0ed8af34 (diff)
downloadbcm5719-llvm-038d02e74e0dcf33b0ce866c71b0d886e9577777.tar.gz
bcm5719-llvm-038d02e74e0dcf33b0ce866c71b0d886e9577777.zip
Implement more aggressive folding of add operand lists when
they contain multiplications of constants with add operations. This helps simplify several kinds of things; in particular it helps simplify expressions like ((-1 * (%a + %b)) + %a) to %b, as expressions like this often come up in loop trip count computations. llvm-svn: 73361
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify/pointer.ll')
-rw-r--r--llvm/test/Transforms/IndVarSimplify/pointer.ll38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/pointer.ll b/llvm/test/Transforms/IndVarSimplify/pointer.ll
new file mode 100644
index 00000000000..7ad11619192
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/pointer.ll
@@ -0,0 +1,38 @@
+; RUN: llvm-as < %s | opt -indvars | llvm-dis > %t
+; RUN: grep {%exitcond = icmp eq i64 %indvar.next, %n} %t
+; RUN: grep {getelementptr i8\\* %A, i64 %indvar} %t
+; RUN: grep getelementptr %t | count 1
+; RUN: grep add %t | count 1
+; RUN: not grep scevgep %t
+; RUN: not grep ptrtoint %t
+
+; Indvars should be able to expand the pointer-arithmetic
+; IV into an integer IV indexing into a simple getelementptr.
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
+
+define void @foo(i8* %A, i64 %n) nounwind {
+entry:
+ %0 = icmp eq i64 %n, 0 ; <i1> [#uses=1]
+ br i1 %0, label %return, label %bb.nph
+
+bb.nph: ; preds = %entry
+ %1 = getelementptr i8* %A, i64 %n ; <i8*> [#uses=1]
+ br label %bb
+
+bb: ; preds = %bb1, %bb.nph
+ %q.01 = phi i8* [ %2, %bb1 ], [ %A, %bb.nph ] ; <i8*> [#uses=2]
+ store i8 0, i8* %q.01, align 1
+ %2 = getelementptr i8* %q.01, i64 1 ; <i8*> [#uses=2]
+ br label %bb1
+
+bb1: ; preds = %bb
+ %3 = icmp eq i8* %1, %2 ; <i1> [#uses=1]
+ br i1 %3, label %bb1.return_crit_edge, label %bb
+
+bb1.return_crit_edge: ; preds = %bb1
+ br label %return
+
+return: ; preds = %bb1.return_crit_edge, %entry
+ ret void
+}
OpenPOWER on IntegriCloud