diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-02 21:14:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-02 21:14:18 +0000 |
commit | 63f9c3c49ac7011e6366fbec42716f3f70f1beee (patch) | |
tree | cd087437583b8ca9934f3b236dd8fbbb60c7601c /test/Transforms/LoopIdiom | |
parent | 8e08e73f0e12c9e669f2d7d0a5c9213df3046c01 (diff) |
fix a miscompilation of tramp3d-v4: when forming a memcpy, we have to make
sure that the loop we're promoting into a memcpy doesn't mutate the input
of the memcpy. Before we were just checking that the dest of the memcpy
wasn't mod/ref'd by the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122712 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopIdiom')
-rw-r--r-- | test/Transforms/LoopIdiom/basic.ll | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/Transforms/LoopIdiom/basic.ll b/test/Transforms/LoopIdiom/basic.ll index e8e0f38004..f3b55d7d61 100644 --- a/test/Transforms/LoopIdiom/basic.ll +++ b/test/Transforms/LoopIdiom/basic.ll @@ -207,3 +207,36 @@ for.end: ; preds = %for.body, %entry ; CHECK: store i64 0, i64* %PI } +declare i8* @external(i8*) + +;; This cannot be transformed into a memcpy, because the read-from location is +;; mutated by the loop. +define void @test9(i64 %Size) nounwind ssp { +bb.nph: + %Base = alloca i8, i32 10000 + %Dest = alloca i8, i32 10000 + + %BaseAlias = call i8* @external(i8* %Base) + br label %for.body + +for.body: ; preds = %bb.nph, %for.body + %indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %for.body ] + %I.0.014 = getelementptr i8* %Base, i64 %indvar + %DestI = getelementptr i8* %Dest, i64 %indvar + %V = load i8* %I.0.014, align 1 + store i8 %V, i8* %DestI, align 1 + + ;; This store can clobber the input. + store i8 4, i8* %BaseAlias + + %indvar.next = add i64 %indvar, 1 + %exitcond = icmp eq i64 %indvar.next, %Size + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + ret void +; CHECK: @test9 +; CHECK-NOT: llvm.memcpy +; CHECK: ret void +} + |