summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorYaxun Liu <Yaxun.Liu@amd.com>2017-02-24 20:27:25 +0000
committerYaxun Liu <Yaxun.Liu@amd.com>2017-02-24 20:27:25 +0000
commite6d1ce59c0d320e02fe50ddb85e37c82f0a453cf (patch)
treeb55d0c21ab522c07f19526520842f6f5cc3a62dd /llvm/test
parent9cc84384addbec14650adf532fb0b47de57a53d7 (diff)
downloadbcm5719-llvm-e6d1ce59c0d320e02fe50ddb85e37c82f0a453cf.tar.gz
bcm5719-llvm-e6d1ce59c0d320e02fe50ddb85e37c82f0a453cf.zip
[InstCombine] Fix bug in pointer replacement
This optimisation was crashing when there was a chain of more than one bitcast instruction to replace, as a result of the changes in D27283. Patch by James Price. Differential Revision: https://reviews.llvm.org/D30347 llvm-svn: 296163
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/memcpy-addrspace.ll20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/memcpy-addrspace.ll b/llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
index 2b80f2f51e5..17bc1d08f98 100644
--- a/llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
+++ b/llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
@@ -21,6 +21,26 @@ entry:
ret void
}
+; CHECK-LABEL: test_load_bitcast_chain
+; CHECK: %[[GEP:.*]] = getelementptr [8 x i32], [8 x i32] addrspace(2)* @test.data, i64 0, i64 %x
+; CHECK: %{{.*}} = load i32, i32 addrspace(2)* %[[GEP]]
+; CHECK-NOT: alloca
+; CHECK-NOT: call void @llvm.memcpy.p0i8.p2i8.i64
+; CHECK-NOT: addrspacecast
+; CHECK-NOT: load i32, i32*
+define void @test_load_bitcast_chain(i32 addrspace(1)* %out, i64 %x) {
+entry:
+ %data = alloca [8 x i32], align 4
+ %0 = bitcast [8 x i32]* %data to i8*
+ call void @llvm.memcpy.p0i8.p2i8.i64(i8* %0, i8 addrspace(2)* bitcast ([8 x i32] addrspace(2)* @test.data to i8 addrspace(2)*), i64 32, i32 4, i1 false)
+ %1 = bitcast i8* %0 to i32*
+ %arrayidx = getelementptr inbounds i32, i32* %1, i64 %x
+ %2 = load i32, i32* %arrayidx, align 4
+ %arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %out, i64 %x
+ store i32 %2, i32 addrspace(1)* %arrayidx1, align 4
+ ret void
+}
+
; CHECK-LABEL: test_call
; CHECK: alloca
; CHECK: call void @llvm.memcpy.p0i8.p2i8.i64
OpenPOWER on IntegriCloud