1 ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck %s
2 ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -disable-fp-elim < %s | FileCheck -check-prefix=CHECK-FP %s
3 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-f128:128:128-v128:128:128-n32:64"
4 target triple = "powerpc64-unknown-linux-gnu"
6 %struct.s = type { i32, i32 }
8 declare void @bar(i32*)
10 define void @goo(%struct.s* byval nocapture readonly %a) {
12 %x = alloca [2 x i32], align 32
13 %a1 = getelementptr inbounds %struct.s* %a, i64 0, i32 0
14 %0 = load i32* %a1, align 4
15 %arrayidx = getelementptr inbounds [2 x i32]* %x, i64 0, i64 0
16 store i32 %0, i32* %arrayidx, align 32
17 %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1
18 %1 = load i32* %b, align 4
19 %arrayidx2 = getelementptr inbounds [2 x i32]* %x, i64 0, i64 1
20 store i32 %1, i32* %arrayidx2, align 4
21 call void @bar(i32* %arrayidx)
28 ; CHECK-DAG: rldicl [[REG:[0-9]+]], 1, 0, 59
29 ; CHECK-DAG: std 30, -16(1)
31 ; CHECK-DAG: std 0, 16(1)
32 ; CHECK-DAG: subfic 0, [[REG]], -160
33 ; CHECK: stdux 1, 1, 0
35 ; CHECK: .cfi_offset r30, -16
36 ; CHECK: .cfi_offset lr, 16
38 ; CHECK: std 3, 48(30)
41 ; CHECK-DAG: ld 0, 16(1)
42 ; CHECK-DAG: ld 30, -16(1)
46 ; CHECK-FP-LABEL: @goo
48 ; CHECK-FP-DAG: mflr 0
49 ; CHECK-FP-DAG: rldicl [[REG:[0-9]+]], 1, 0, 59
50 ; CHECK-FP-DAG: std 31, -8(1)
51 ; CHECK-FP-DAG: std 30, -16(1)
52 ; CHECK-FP-DAG: mr 30, 1
53 ; CHECK-FP-DAG: std 0, 16(1)
54 ; CHECK-FP-DAG: subfic 0, [[REG]], -160
55 ; CHECK-FP: stdux 1, 1, 0
57 ; CHECK-FP: .cfi_offset r31, -8
58 ; CHECK-FP: .cfi_offset r30, -16
59 ; CHECK-FP: .cfi_offset lr, 16
63 ; CHECK-FP: std 3, 48(30)
65 ; CHECK-FP: ld 1, 0(1)
66 ; CHECK-FP-DAG: ld 0, 16(1)
67 ; CHECK-FP-DAG: ld 31, -8(1)
68 ; CHECK-FP-DAG: ld 30, -16(1)
69 ; CHECK-FP-DAG: mtlr 0
72 ; The large-frame-size case.
73 define void @hoo(%struct.s* byval nocapture readonly %a) {
75 %x = alloca [200000 x i32], align 32
76 %a1 = getelementptr inbounds %struct.s* %a, i64 0, i32 0
77 %0 = load i32* %a1, align 4
78 %arrayidx = getelementptr inbounds [200000 x i32]* %x, i64 0, i64 0
79 store i32 %0, i32* %arrayidx, align 32
80 %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1
81 %1 = load i32* %b, align 4
82 %arrayidx2 = getelementptr inbounds [200000 x i32]* %x, i64 0, i64 1
83 store i32 %1, i32* %arrayidx2, align 4
84 call void @bar(i32* %arrayidx)
90 ; CHECK-DAG: lis [[REG1:[0-9]+]], -13
91 ; CHECK-DAG: rldicl [[REG3:[0-9]+]], 1, 0, 59
93 ; CHECK-DAG: ori [[REG2:[0-9]+]], [[REG1]], 51808
94 ; CHECK-DAG: std 30, -16(1)
96 ; CHECK-DAG: std 0, 16(1)
97 ; CHECK-DAG: subfc 0, [[REG3]], [[REG2]]
98 ; CHECK: stdux 1, 1, 0
102 ; Make sure that the FP save area is still allocated correctly relative to
103 ; where r30 is saved.
104 define void @loo(%struct.s* byval nocapture readonly %a) {
106 %x = alloca [2 x i32], align 32
107 %a1 = getelementptr inbounds %struct.s* %a, i64 0, i32 0
108 %0 = load i32* %a1, align 4
109 %arrayidx = getelementptr inbounds [2 x i32]* %x, i64 0, i64 0
110 store i32 %0, i32* %arrayidx, align 32
111 %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1
112 %1 = load i32* %b, align 4
113 %arrayidx2 = getelementptr inbounds [2 x i32]* %x, i64 0, i64 1
114 store i32 %1, i32* %arrayidx2, align 4
115 call void @bar(i32* %arrayidx)
116 call void asm sideeffect "", "~{f30}"() nounwind
123 ; CHECK-DAG: rldicl [[REG:[0-9]+]], 1, 0, 59
124 ; CHECK-DAG: std 30, -32(1)
125 ; CHECK-DAG: mr 30, 1
126 ; CHECK-DAG: std 0, 16(1)
127 ; CHECK-DAG: subfic 0, [[REG]], -192
128 ; CHECK: stdux 1, 1, 0
130 ; CHECK: stfd 30, -16(30)
134 ; CHECK-FP-LABEL: @loo
136 ; CHECK-FP-DAG: mflr 0
137 ; CHECK-FP-DAG: rldicl [[REG:[0-9]+]], 1, 0, 59
138 ; CHECK-FP-DAG: std 31, -24(1)
139 ; CHECK-FP-DAG: std 30, -32(1)
140 ; CHECK-FP-DAG: mr 30, 1
141 ; CHECK-FP-DAG: std 0, 16(1)
142 ; CHECK-FP-DAG: subfic 0, [[REG]], -192
143 ; CHECK-FP: stdux 1, 1, 0
145 ; CHECK-FP: stfd 30, -16(30)