diff options
author | Jingyue Wu <jingyue@google.com> | 2014-06-06 21:52:55 +0000 |
---|---|---|
committer | Jingyue Wu <jingyue@google.com> | 2014-06-06 21:52:55 +0000 |
commit | 77145d9410d05049059d96762873483df571c304 (patch) | |
tree | b6237086b55edf2f54cf504469876d1977613240 /llvm/test/Transforms/InstCombine/getelementptr.ll | |
parent | e76013c2adcc094f7118ded8485db19fb2939efc (diff) | |
download | bcm5719-llvm-77145d9410d05049059d96762873483df571c304.tar.gz bcm5719-llvm-77145d9410d05049059d96762873483df571c304.zip |
InstCombine: Canonicalize addrspacecast between different element types
addrspacecast X addrspace(M)* to Y addrspace(N)*
-->
bitcast X addrspace(M)* to Y addrspace(M)*
addrspacecast Y addrspace(M)* to Y addrspace(N)*
Updat all affected tests and add several new tests in addrspacecast.ll.
This patch is based on http://reviews.llvm.org/D2186 (authored by Matt
Arsenault) with fixes and more tests.
llvm-svn: 210375
Diffstat (limited to 'llvm/test/Transforms/InstCombine/getelementptr.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/getelementptr.ll | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/test/Transforms/InstCombine/getelementptr.ll b/llvm/test/Transforms/InstCombine/getelementptr.ll index ef0cb29fd88..3240c6d2a4d 100644 --- a/llvm/test/Transforms/InstCombine/getelementptr.ll +++ b/llvm/test/Transforms/InstCombine/getelementptr.ll @@ -732,7 +732,8 @@ define i64 @test_gep_bitcast_array_same_size_element([100 x double]* %arr, i64 % define i64 @test_gep_bitcast_array_same_size_element_addrspacecast([100 x double]* %arr, i64 %N) { ; CHECK-LABEL: @test_gep_bitcast_array_same_size_element_addrspacecast( ; CHECK: getelementptr [100 x double]* %arr, i64 0, i64 %V -; CHECK-NEXT: %t = addrspacecast double* +; CHECK-NEXT: bitcast double* +; CHECK-NEXT: %t = addrspacecast i64* ; CHECK: load i64 addrspace(3)* %t %cast = addrspacecast [100 x double]* %arr to i64 addrspace(3)* %V = mul i64 %N, 8 @@ -802,10 +803,22 @@ define i16 @test41([3 x i32] addrspace(1)* %array) { ; CHECK-NEXT: ret i16 8 } -define i32 addrspace(1)* @ascast_0_gep([128 x i32]* %p) nounwind { +define i32 addrspace(1)* @ascast_0_gep(i32* %p) nounwind { ; CHECK-LABEL: @ascast_0_gep( ; CHECK-NOT: getelementptr ; CHECK: ret + %gep = getelementptr i32* %p, i32 0 + %x = addrspacecast i32* %gep to i32 addrspace(1)* + ret i32 addrspace(1)* %x +} + +; Do not merge the GEP and the addrspacecast, because it would undo the +; addrspacecast canonicalization. +define i32 addrspace(1)* @ascast_0_0_gep([128 x i32]* %p) nounwind { +; CHECK-LABEL: @ascast_0_0_gep( +; CHECK-NEXT: getelementptr [128 x i32] +; CHECK-NEXT: addrspacecast i32* +; CHECK-NEXT: ret i32 addrspace(1)* %gep = getelementptr [128 x i32]* %p, i32 0, i32 0 %x = addrspacecast i32* %gep to i32 addrspace(1)* ret i32 addrspace(1)* %x |