Add missing test for GEP + bitcast transformation
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 16 Aug 2013 02:59:17 +0000 (02:59 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 16 Aug 2013 02:59:17 +0000 (02:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188529 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/getelementptr.ll

index 3033bf1a7b666cc197082c623795fc46b1981ec4..a0e3375cf8a6992a02adcb0a781598c00e639b93 100644 (file)
@@ -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 }