Update InstCombine to transform aggregate loads into scalar loads.
[oota-llvm.git] / test / Transforms / InstCombine / unpack-fca.ll
1 ; RUN: opt -instcombine -S < %s | FileCheck %s
2
3 target datalayout = "e-i64:64-f80:128-n8:16:32:64"
4 target triple = "x86_64-unknown-linux-gnu"
5
6 %A__vtbl = type { i8*, i32 (%A*)* }
7 %A = type { %A__vtbl* }
8
9 @A__vtblZ = constant %A__vtbl { i8* null, i32 (%A*)* @A.foo }
10
11 declare i32 @A.foo(%A* nocapture %this)
12
13 declare i8* @allocmemory(i64)
14
15 define void @storeA() {
16 body:
17   %0 = tail call i8* @allocmemory(i64 32)
18   %1 = bitcast i8* %0 to %A*
19 ; CHECK-LABEL: storeA
20 ; CHECK: store %A__vtbl* @A__vtblZ
21   store %A { %A__vtbl* @A__vtblZ }, %A* %1, align 8
22   ret void
23 }
24
25 define void @storeStructOfA() {
26 body:
27   %0 = tail call i8* @allocmemory(i64 32)
28   %1 = bitcast i8* %0 to { %A }*
29 ; CHECK-LABEL: storeStructOfA
30 ; CHECK: store %A__vtbl* @A__vtblZ
31   store { %A } { %A { %A__vtbl* @A__vtblZ } }, { %A }* %1, align 8
32   ret void
33 }
34
35 define %A @loadA() {
36 body:
37   %0 = tail call i8* @allocmemory(i64 32)
38   %1 = bitcast i8* %0 to %A*
39 ; CHECK-LABEL: loadA
40 ; CHECK: load %A__vtbl*,
41 ; CHECK: insertvalue %A undef, %A__vtbl* {{.*}}, 0
42   %2 = load %A, %A* %1, align 8
43   ret %A %2
44 }
45
46 define { %A } @loadStructOfA() {
47 body:
48   %0 = tail call i8* @allocmemory(i64 32)
49   %1 = bitcast i8* %0 to { %A }*
50 ; CHECK-LABEL: loadStructOfA
51 ; CHECK: load %A__vtbl*,
52 ; CHECK: insertvalue %A undef, %A__vtbl* {{.*}}, 0
53 ; CHECK: insertvalue { %A } undef, %A {{.*}}, 0
54   %2 = load { %A }, { %A }* %1, align 8
55   ret { %A } %2
56 }
57
58 define { %A } @structOfA() {
59 body:
60   %0 = tail call i8* @allocmemory(i64 32)
61   %1 = bitcast i8* %0 to { %A }*
62 ; CHECK-LABEL: structOfA
63 ; CHECK: store %A__vtbl* @A__vtblZ
64   store { %A } { %A { %A__vtbl* @A__vtblZ } }, { %A }* %1, align 8
65   %2 = load { %A }, { %A }* %1, align 8
66 ; CHECK-NOT: load
67 ; CHECK: ret { %A } { %A { %A__vtbl* @A__vtblZ } }
68   ret { %A } %2
69 }