From: Matt Arsenault Date: Fri, 16 Aug 2013 02:59:17 +0000 (+0000) Subject: Add missing test for GEP + bitcast transformation X-Git-Tag: llvmorg-3.4.0-rc1~6296 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b06951bc19c54ed75ebf9d2eceb00ac56ea1beee;p=platform%2Fupstream%2Fllvm.git Add missing test for GEP + bitcast transformation llvm-svn: 188529 --- diff --git a/llvm/test/Transforms/InstCombine/getelementptr.ll b/llvm/test/Transforms/InstCombine/getelementptr.ll index 3033bf1a7b66..a0e3375cf8a6 100644 --- a/llvm/test/Transforms/InstCombine/getelementptr.ll +++ b/llvm/test/Transforms/InstCombine/getelementptr.ll @@ -573,4 +573,28 @@ define i1 @pr16483([1 x i8]* %a, [1 x i8]* %b) { ; CHECK-NEXT: icmp ult [1 x i8]* %a, %b } +; The element size of the array matches the element size of the pointer +define i64 @test_gep_bitcast_array_same_size_element([100 x double]* %arr, i64 %N) { +; CHECK-LABEL: @test_gep_bitcast_array_same_size_element( +; CHECK: getelementptr [100 x double]* %arr, i64 0, i64 %V +; CHECK: bitcast + %cast = bitcast [100 x double]* %arr to i64* + %V = mul i64 %N, 8 + %t = getelementptr i64* %cast, i64 %V + %x = load i64* %t + ret i64 %x +} + +; The element size of the array is different the element size of the pointer +define i8 @test_gep_bitcast_array_different_size_element([100 x double]* %arr, i64 %N) { +; CHECK-LABEL: @test_gep_bitcast_array_different_size_element( +; CHECK: getelementptr [100 x double]* %arr, i64 0, i64 %N +; CHECK: bitcast + %cast = bitcast [100 x double]* %arr to i8* + %V = mul i64 %N, 8 + %t = getelementptr i8* %cast, i64 %V + %x = load i8* %t + ret i8 %x +} + ; CHECK: attributes [[NUW]] = { nounwind }