• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -O0 -mcpu=ppc64 -mtriple=powerpc64-unknown-linux-gnu -fast-isel=false < %s | FileCheck %s
2; RUN: llc -O0 -mcpu=g4 -mtriple=powerpc-apple-darwin8 < %s | FileCheck -check-prefix=DARWIN32 %s
3; RUN: llc -O0 -mcpu=ppc970 -mtriple=powerpc64-apple-darwin8 < %s | FileCheck -check-prefix=DARWIN64 %s
4
5; Test case for PR 14779: anonymous aggregates are not handled correctly.
6; Darwin bug report PR 15821 is similar.
7; The bug is triggered by passing a byval structure after an anonymous
8; aggregate.
9
10%tarray = type { i64, i8* }
11
12define i8* @func1({ i64, i8* } %array, i8* %ptr) {
13entry:
14  %array_ptr = extractvalue {i64, i8* } %array, 1
15  %cond = icmp eq i8* %array_ptr, %ptr
16  br i1 %cond, label %equal, label %unequal
17equal:
18  ret i8* %array_ptr
19unequal:
20  ret i8* %ptr
21}
22
23; CHECK-LABEL: func1:
24; CHECK: cmpld {{([0-9]+,)?}}4, 5
25; CHECK-DAG: std 4, -[[OFFSET1:[0-9]+]]
26; CHECK-DAG: std 5, -[[OFFSET2:[0-9]+]]
27; CHECK: ld 3, -[[OFFSET1]](1)
28; CHECK: ld 3, -[[OFFSET2]](1)
29
30; DARWIN32: _func1:
31; DARWIN32: mr
32; DARWIN32: mr r[[REG1:[0-9]+]], r[[REGA:[0-9]+]]
33; DARWIN32: mr r[[REG2:[0-9]+]], r[[REGB:[0-9]+]]
34; DARWIN32: cmplw {{(cr[0-9]+,)?}}r[[REGA]], r[[REGB]]
35; DARWIN32: stw r[[REG1]], -[[OFFSET1:[0-9]+]]
36; DARWIN32: stw r[[REG2]], -[[OFFSET2:[0-9]+]]
37; DARWIN32: lwz r3, -[[OFFSET1]]
38; DARWIN32: lwz r3, -[[OFFSET2]]
39
40; DARWIN64: _func1:
41; DARWIN64: mr
42; DARWIN64: mr r[[REG1:[0-9]+]], r[[REGA:[0-9]+]]
43; DARWIN64: mr r[[REG2:[0-9]+]], r[[REGB:[0-9]+]]
44; DARWIN64: cmpld {{(cr[0-9]+,)?}}r[[REGA]], r[[REGB]]
45; DARWIN64: std r[[REG1]], -[[OFFSET1:[0-9]+]]
46; DARWIN64: std r[[REG2]], -[[OFFSET2:[0-9]+]]
47; DARWIN64: ld r3, -[[OFFSET1]]
48; DARWIN64: ld r3, -[[OFFSET2]]
49
50
51define i8* @func2({ i64, i8* } %array1, %tarray* byval %array2) {
52entry:
53  %array1_ptr = extractvalue {i64, i8* } %array1, 1
54  %tmp = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
55  %array2_ptr = load i8*, i8** %tmp
56  %cond = icmp eq i8* %array1_ptr, %array2_ptr
57  br i1 %cond, label %equal, label %unequal
58equal:
59  ret i8* %array1_ptr
60unequal:
61  ret i8* %array2_ptr
62}
63
64; CHECK-LABEL: func2:
65; CHECK: ld [[REG2:[0-9]+]], 72(1)
66; CHECK: cmpld {{([0-9]+,)?}}4, [[REG2]]
67; CHECK-DAG: std [[REG2]], -[[OFFSET1:[0-9]+]]
68; CHECK-DAG: std 4, -[[OFFSET2:[0-9]+]]
69; CHECK: ld 3, -[[OFFSET2]](1)
70; CHECK: ld 3, -[[OFFSET1]](1)
71
72; DARWIN32: _func2:
73; DARWIN32: addi r[[REG1:[0-9]+]], r[[REGSP:[0-9]+]], 36
74; DARWIN32: lwz r[[REG2:[0-9]+]], 44(r[[REGSP]])
75; DARWIN32: mr
76; DARWIN32: mr r[[REG3:[0-9]+]], r[[REGA:[0-9]+]]
77; DARWIN32: cmplw {{(cr[0-9]+,)?}}r[[REGA]], r[[REG2]]
78; DARWIN32: stw r[[REG3]], -[[OFFSET1:[0-9]+]]
79; DARWIN32: stw r[[REG2]], -[[OFFSET2:[0-9]+]]
80; DARWIN32: lwz r3, -[[OFFSET1]]
81; DARWIN32: lwz r3, -[[OFFSET2]]
82
83; DARWIN64: _func2:
84; DARWIN64: ld r[[REG2:[0-9]+]], 72(r1)
85; DARWIN64: mr
86; DARWIN64: mr r[[REG3:[0-9]+]], r[[REGA:[0-9]+]]
87; DARWIN64: cmpld {{(cr[0-9]+,)?}}r[[REGA]], r[[REG2]]
88; DARWIN64: std r[[REG3]], -[[OFFSET1:[0-9]+]]
89; DARWIN64: std r[[REG2]], -[[OFFSET2:[0-9]+]]
90; DARWIN64: ld r3, -[[OFFSET1]]
91; DARWIN64: ld r3, -[[OFFSET2]]
92
93
94define i8* @func3({ i64, i8* }* byval %array1, %tarray* byval %array2) {
95entry:
96  %tmp1 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %array1, i32 0, i32 1
97  %array1_ptr = load i8*, i8** %tmp1
98  %tmp2 = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
99  %array2_ptr = load i8*, i8** %tmp2
100  %cond = icmp eq i8* %array1_ptr, %array2_ptr
101  br i1 %cond, label %equal, label %unequal
102equal:
103  ret i8* %array1_ptr
104unequal:
105  ret i8* %array2_ptr
106}
107
108; CHECK-LABEL: func3:
109; CHECK: ld [[REG3:[0-9]+]], 72(1)
110; CHECK: ld [[REG4:[0-9]+]], 56(1)
111; CHECK: cmpld {{([0-9]+,)?}}[[REG4]], [[REG3]]
112; CHECK: std [[REG3]], -[[OFFSET1:[0-9]+]](1)
113; CHECK: std [[REG4]], -[[OFFSET2:[0-9]+]](1)
114; CHECK: ld 3, -[[OFFSET2]](1)
115; CHECK: ld 3, -[[OFFSET1]](1)
116
117; DARWIN32: _func3:
118; DARWIN32: addi r[[REG1:[0-9]+]], r[[REGSP:[0-9]+]], 36
119; DARWIN32: addi r[[REG2:[0-9]+]], r[[REGSP]], 24
120; DARWIN32: lwz r[[REG3:[0-9]+]], 44(r[[REGSP]])
121; DARWIN32: lwz r[[REG4:[0-9]+]], 32(r[[REGSP]])
122; DARWIN32: cmplw {{(cr[0-9]+,)?}}r[[REG4]], r[[REG3]]
123; DARWIN32: stw r[[REG3]], -[[OFFSET1:[0-9]+]]
124; DARWIN32: stw r[[REG4]], -[[OFFSET2:[0-9]+]]
125; DARWIN32: lwz r3, -[[OFFSET2]]
126; DARWIN32: lwz r3, -[[OFFSET1]]
127
128; DARWIN64: _func3:
129; DARWIN64: ld r[[REG3:[0-9]+]], 72(r1)
130; DARWIN64: ld r[[REG4:[0-9]+]], 56(r1)
131; DARWIN64: cmpld {{(cr[0-9]+,)?}}r[[REG4]], r[[REG3]]
132; DARWIN64: std r[[REG3]], -[[OFFSET1:[0-9]+]]
133; DARWIN64: std r[[REG4]], -[[OFFSET2:[0-9]+]]
134; DARWIN64: ld r3, -[[OFFSET2]]
135; DARWIN64: ld r3, -[[OFFSET1]]
136
137
138define i8* @func4(i64 %p1, i64 %p2, i64 %p3, i64 %p4,
139                  i64 %p5, i64 %p6, i64 %p7, i64 %p8,
140                  { i64, i8* } %array1, %tarray* byval %array2) {
141entry:
142  %array1_ptr = extractvalue {i64, i8* } %array1, 1
143  %tmp = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
144  %array2_ptr = load i8*, i8** %tmp
145  %cond = icmp eq i8* %array1_ptr, %array2_ptr
146  br i1 %cond, label %equal, label %unequal
147equal:
148  ret i8* %array1_ptr
149unequal:
150  ret i8* %array2_ptr
151}
152
153; CHECK-LABEL: func4:
154; CHECK: ld [[REG3:[0-9]+]], 136(1)
155; CHECK: ld [[REG2:[0-9]+]], 120(1)
156; CHECK: cmpld {{([0-9]+,)?}}[[REG2]], [[REG3]]
157; CHECK: std [[REG3]], -[[OFFSET2:[0-9]+]](1)
158; CHECK: std [[REG2]], -[[OFFSET1:[0-9]+]](1)
159; CHECK: ld 3, -[[OFFSET1]](1)
160; CHECK: ld 3, -[[OFFSET2]](1)
161
162; DARWIN32: _func4:
163; DARWIN32: lwz r[[REG4:[0-9]+]], 96(r1)
164; DARWIN32: addi r[[REG1:[0-9]+]], r1, 100
165; DARWIN32: lwz r[[REG3:[0-9]+]], 108(r1)
166; DARWIN32: mr r[[REG2:[0-9]+]], r[[REG4]]
167; DARWIN32: cmplw {{(cr[0-9]+,)?}}r[[REG4]], r[[REG3]]
168; DARWIN32: stw r[[REG2]], -[[OFFSET1:[0-9]+]]
169; DARWIN32: stw r[[REG3]], -[[OFFSET2:[0-9]+]]
170; DARWIN32: lwz r[[REG1]], -[[OFFSET1]]
171; DARWIN32: lwz r[[REG1]], -[[OFFSET2]]
172
173; DARWIN64: _func4:
174; DARWIN64: ld r[[REG2:[0-9]+]], 120(r1)
175; DARWIN64: ld r[[REG3:[0-9]+]], 136(r1)
176; DARWIN64: mr r[[REG4:[0-9]+]], r[[REG2]]
177; DARWIN64: cmpld {{(cr[0-9]+,)?}}r[[REG2]], r[[REG3]]
178; DARWIN64: std r[[REG4]], -[[OFFSET1:[0-9]+]]
179; DARWIN64: std r[[REG3]], -[[OFFSET2:[0-9]+]]
180; DARWIN64: ld r3, -[[OFFSET1]]
181; DARWIN64: ld r3, -[[OFFSET2]]
182