Update InstCombine to transform aggregate loads into scalar loads.
[oota-llvm.git] / test / Transforms / InstCombine / unpack-fca.ll
index 5f63330b9316fff9939b6b9b1f3a81c101b9dc0a..58dfbe55162fad4f17d727ff72cb881ad93534f7 100644 (file)
@@ -12,20 +12,58 @@ declare i32 @A.foo(%A* nocapture %this)
 
 declare i8* @allocmemory(i64)
 
-define void @structA() {
+define void @storeA() {
 body:
   %0 = tail call i8* @allocmemory(i64 32)
   %1 = bitcast i8* %0 to %A*
+; CHECK-LABEL: storeA
 ; CHECK: store %A__vtbl* @A__vtblZ
   store %A { %A__vtbl* @A__vtblZ }, %A* %1, align 8
   ret void
 }
 
-define void @structOfA() {
+define void @storeStructOfA() {
 body:
   %0 = tail call i8* @allocmemory(i64 32)
   %1 = bitcast i8* %0 to { %A }*
+; CHECK-LABEL: storeStructOfA
 ; CHECK: store %A__vtbl* @A__vtblZ
   store { %A } { %A { %A__vtbl* @A__vtblZ } }, { %A }* %1, align 8
   ret void
 }
+
+define %A @loadA() {
+body:
+  %0 = tail call i8* @allocmemory(i64 32)
+  %1 = bitcast i8* %0 to %A*
+; CHECK-LABEL: loadA
+; CHECK: load %A__vtbl*,
+; CHECK: insertvalue %A undef, %A__vtbl* {{.*}}, 0
+  %2 = load %A, %A* %1, align 8
+  ret %A %2
+}
+
+define { %A } @loadStructOfA() {
+body:
+  %0 = tail call i8* @allocmemory(i64 32)
+  %1 = bitcast i8* %0 to { %A }*
+; CHECK-LABEL: loadStructOfA
+; CHECK: load %A__vtbl*,
+; CHECK: insertvalue %A undef, %A__vtbl* {{.*}}, 0
+; CHECK: insertvalue { %A } undef, %A {{.*}}, 0
+  %2 = load { %A }, { %A }* %1, align 8
+  ret { %A } %2
+}
+
+define { %A } @structOfA() {
+body:
+  %0 = tail call i8* @allocmemory(i64 32)
+  %1 = bitcast i8* %0 to { %A }*
+; CHECK-LABEL: structOfA
+; CHECK: store %A__vtbl* @A__vtblZ
+  store { %A } { %A { %A__vtbl* @A__vtblZ } }, { %A }* %1, align 8
+  %2 = load { %A }, { %A }* %1, align 8
+; CHECK-NOT: load
+; CHECK: ret { %A } { %A { %A__vtbl* @A__vtblZ } }
+  ret { %A } %2
+}