1 ; RUN: llc -verify-machineinstrs -O0 -mcpu=ppc64 -mtriple=powerpc64-unknown-linux-gnu -fast-isel=false < %s | FileCheck %s
3 ; Test case for PR 14779: anonymous aggregates are not handled correctly.
4 ; Darwin bug report PR 15821 is similar.
5 ; The bug is triggered by passing a byval structure after an anonymous
8 %tarray = type { i64, i8* }
10 define i8* @func1({ i64, i8* } %array, i8* %ptr) {
12 %array_ptr = extractvalue {i64, i8* } %array, 1
13 %cond = icmp eq i8* %array_ptr, %ptr
14 br i1 %cond, label %equal, label %unequal
22 ; CHECK: cmpld {{([0-9]+,)?}}4, 5
23 ; CHECK-DAG: std 3, -[[OFFSET1:[0-9]+]]
24 ; CHECK-DAG: std 5, -[[OFFSET2:[0-9]+]]
25 ; CHECK: ld 3, -[[OFFSET1]](1)
26 ; CHECK: ld 3, -[[OFFSET2]](1)
28 define i8* @func2({ i64, i8* } %array1, %tarray* byval %array2) {
30 %array1_ptr = extractvalue {i64, i8* } %array1, 1
31 %tmp = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
32 %array2_ptr = load i8*, i8** %tmp
33 %cond = icmp eq i8* %array1_ptr, %array2_ptr
34 br i1 %cond, label %equal, label %unequal
41 ; CHECK-DAG: cmpld {{([0-9]+,)?}}4, 5
42 ; CHECK-DAG: std 6, 72(1)
43 ; CHECK-DAG: std 5, 64(1)
44 ; CHECK-DAG: std 5, -[[OFFSET1:[0-9]+]]
45 ; CHECK-DAG: std 3, -[[OFFSET2:[0-9]+]]
46 ; CHECK: ld 3, -[[OFFSET2]](1)
47 ; CHECK: ld 3, -[[OFFSET1]](1)
49 define i8* @func3({ i64, i8* }* byval %array1, %tarray* byval %array2) {
51 %tmp1 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %array1, i32 0, i32 1
52 %array1_ptr = load i8*, i8** %tmp1
53 %tmp2 = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
54 %array2_ptr = load i8*, i8** %tmp2
55 %cond = icmp eq i8* %array1_ptr, %array2_ptr
56 br i1 %cond, label %equal, label %unequal
64 ; CHECK-DAG: cmpld {{([0-9]+,)?}}3, 4
65 ; CHECK-DAG: std 3, -[[OFFSET2:[0-9]+]](1)
66 ; CHECK-DAG: std 4, -[[OFFSET1:[0-9]+]](1)
67 ; CHECK: ld 3, -[[OFFSET2]](1)
68 ; CHECK: ld 3, -[[OFFSET1]](1)
70 define i8* @func4(i64 %p1, i64 %p2, i64 %p3, i64 %p4,
71 i64 %p5, i64 %p6, i64 %p7, i64 %p8,
72 { i64, i8* } %array1, %tarray* byval %array2) {
74 %array1_ptr = extractvalue {i64, i8* } %array1, 1
75 %tmp = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1
76 %array2_ptr = load i8*, i8** %tmp
77 %cond = icmp eq i8* %array1_ptr, %array2_ptr
78 br i1 %cond, label %equal, label %unequal
86 ; CHECK-DAG: ld [[REG2:[0-9]+]], 120(1)
87 ; CHECK-DAG: ld [[REG3:[0-9]+]], 136(1)
88 ; CHECK-DAG: cmpld {{([0-9]+,)?}}[[REG2]], [[REG3]]
89 ; CHECK: std [[REG2]], -[[OFFSET1:[0-9]+]](1)
90 ; CHECK: std [[REG3]], -[[OFFSET2:[0-9]+]](1)
91 ; CHECK: ld 3, -[[OFFSET1]](1)
92 ; CHECK: ld 3, -[[OFFSET2]](1)