ARM64: initial backend import
[oota-llvm.git] / test / Transforms / GlobalMerge / ARM64 / arm64.ll
1 ; RUN: llc %s -O0 -o - | FileCheck -check-prefix=NO-MERGE %s
2 ; RUN: llc %s -O0 -o - -global-merge=false | FileCheck -check-prefix=NO-MERGE %s
3 ; RUN: llc %s -O0 -o - -global-merge=true | FileCheck -check-prefix=NO-MERGE %s
4 ; RUN: llc %s -O1 -o - | FileCheck -check-prefix=MERGE %s
5 ; RUN: llc %s -O1 -o - -global-merge=false | FileCheck -check-prefix=NO-MERGE %s
6 ; RUN: llc %s -O1 -o - -global-merge=true | FileCheck -check-prefix=MERGE %s
7
8 ; MERGE-NOT: .zerofill __DATA,__bss,_bar,20,2
9 ; MERGE-NOT: .zerofill __DATA,__bss,_baz,20,2
10 ; MERGE-NOT: .zerofill __DATA,__bss,_foo,20,2
11 ; MERGE: .zerofill __DATA,__bss,__MergedGlobals,60,4
12 ; MERGE-NOT: .zerofill __DATA,__bss,_bar,20,2
13 ; MERGE-NOT: .zerofill __DATA,__bss,_baz,20,2
14 ; MERGE-NOT: .zerofill __DATA,__bss,_foo,20,2
15
16 ; NO-MERGE-NOT: .zerofill __DATA,__bss,__MergedGlobals,60,4
17 ; NO-MERGE: .zerofill __DATA,__bss,_bar,20,2
18 ; NO-MERGE: .zerofill __DATA,__bss,_baz,20,2
19 ; NO-MERGE: .zerofill __DATA,__bss,_foo,20,2
20 ; NO-MERGE-NOT: .zerofill __DATA,__bss,__MergedGlobals,60,4
21
22 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32:64-S128"
23 target triple = "arm64-apple-ios7.0.0"
24
25 @bar = internal global [5 x i32] zeroinitializer, align 4
26 @baz = internal global [5 x i32] zeroinitializer, align 4
27 @foo = internal global [5 x i32] zeroinitializer, align 4
28
29 ; Function Attrs: nounwind ssp
30 define internal void @initialize() #0 {
31   %1 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
32   store i32 %1, i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 0), align 4
33   %2 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
34   store i32 %2, i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 0), align 4
35   %3 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
36   store i32 %3, i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 1), align 4
37   %4 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
38   store i32 %4, i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 1), align 4
39   %5 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
40   store i32 %5, i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 2), align 4
41   %6 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
42   store i32 %6, i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 2), align 4
43   %7 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
44   store i32 %7, i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 3), align 4
45   %8 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
46   store i32 %8, i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 3), align 4
47   %9 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
48   store i32 %9, i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 4), align 4
49   %10 = tail call i32 bitcast (i32 (...)* @calc to i32 ()*)() #2
50   store i32 %10, i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 4), align 4
51   ret void
52 }
53
54 declare i32 @calc(...)
55
56 ; Function Attrs: nounwind ssp
57 define internal void @calculate() #0 {
58   %1 = load i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 0), align 4
59   %2 = load i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 0), align 4
60   %3 = mul nsw i32 %2, %1
61   store i32 %3, i32* getelementptr inbounds ([5 x i32]* @foo, i64 0, i64 0), align 4
62   %4 = load i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 1), align 4
63   %5 = load i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 1), align 4
64   %6 = mul nsw i32 %5, %4
65   store i32 %6, i32* getelementptr inbounds ([5 x i32]* @foo, i64 0, i64 1), align 4
66   %7 = load i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 2), align 4
67   %8 = load i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 2), align 4
68   %9 = mul nsw i32 %8, %7
69   store i32 %9, i32* getelementptr inbounds ([5 x i32]* @foo, i64 0, i64 2), align 4
70   %10 = load i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 3), align 4
71   %11 = load i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 3), align 4
72   %12 = mul nsw i32 %11, %10
73   store i32 %12, i32* getelementptr inbounds ([5 x i32]* @foo, i64 0, i64 3), align 4
74   %13 = load i32* getelementptr inbounds ([5 x i32]* @bar, i64 0, i64 4), align 4
75   %14 = load i32* getelementptr inbounds ([5 x i32]* @baz, i64 0, i64 4), align 4
76   %15 = mul nsw i32 %14, %13
77   store i32 %15, i32* getelementptr inbounds ([5 x i32]* @foo, i64 0, i64 4), align 4
78   ret void
79 }
80
81 ; Function Attrs: nounwind readnone ssp
82 define internal i32* @returnFoo() #1 {
83   ret i32* getelementptr inbounds ([5 x i32]* @foo, i64 0, i64 0)
84 }
85
86 attributes #0 = { nounwind ssp }
87 attributes #1 = { nounwind readnone ssp }
88 attributes #2 = { nounwind }