summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-10-27 14:25:51 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-10-27 14:25:51 +0000
commitd11c5d08a5f4f030d6e357378d0d46d93efd9a59 (patch)
tree95e77226ccabfa2fd6c5b171c64f038ccdef512d /test
parent96c8735e28f2f89be37cdd907f680c6c1bf16052 (diff)
downloadllvm-d11c5d08a5f4f030d6e357378d0d46d93efd9a59.tar.gz
llvm-d11c5d08a5f4f030d6e357378d0d46d93efd9a59.tar.bz2
llvm-d11c5d08a5f4f030d6e357378d0d46d93efd9a59.tar.xz
LoopIdiom: Recognize memmove loops.
This turns loops like for (unsigned i = 0; i != n; ++i) p[i] = p[i+1]; into memmove, which has a highly optimized implementation in most libcs. This was really easy with the new DependenceAnalysis :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/LoopIdiom/basic.ll22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Transforms/LoopIdiom/basic.ll b/test/Transforms/LoopIdiom/basic.ll
index 46ab7e5542..5afc405fa6 100644
--- a/test/Transforms/LoopIdiom/basic.ll
+++ b/test/Transforms/LoopIdiom/basic.ll
@@ -383,4 +383,26 @@ for.end: ; preds = %for.inc
}
+@p = common global [1024 x i8] zeroinitializer, align 16
+define void @test15(i32 %n) nounwind {
+entry:
+ %cmp6 = icmp eq i32 %n, 0
+ br i1 %cmp6, label %for.end, label %for.body
+
+for.body: ; preds = %entry, %for.body
+ %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
+ %indvars.iv.next = add i64 %indvars.iv, 1
+ %arrayidx = getelementptr inbounds [1024 x i8]* @p, i64 0, i64 %indvars.iv.next
+ %0 = load i8* %arrayidx, align 1
+ %arrayidx2 = getelementptr inbounds [1024 x i8]* @p, i64 0, i64 %indvars.iv
+ store i8 %0, i8* %arrayidx2, align 1
+ %lftr.wideiv = trunc i64 %indvars.iv.next to i32
+ %exitcond = icmp eq i32 %lftr.wideiv, %n
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body, %entry
+ ret void
+; CHECK: @test15
+; CHECK: call void @llvm.memmove.p0i8.p0i8.i64(i8* getelementptr inbounds ([1024 x i8]* @p, i32 0, i32 0), i8* getelementptr inbounds ([1024 x i8]* @p, i64 0, i64 1),
+}