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, ptr }
10 define ptr @func1({ i64, ptr } %array, ptr %ptr) {
12 %array_ptr = extractvalue {i64, ptr } %array, 1
13 %cond = icmp eq ptr %array_ptr, %ptr
14 br i1 %cond, label %equal, label %unequal
22 ; CHECK-DAG: std 3, -[[OFFSET1:[0-9]+]]
23 ; CHECK-DAG: std 5, -[[OFFSET2:[0-9]+]]
24 ; CHECK: cmpld {{([0-9]+,)?}}4, 5
25 ; CHECK: ld 3, -[[OFFSET1]](1)
26 ; CHECK: ld 3, -[[OFFSET2]](1)
28 define ptr @func2({ i64, ptr } %array1, ptr byval(%tarray) %array2) {
30 %array1_ptr = extractvalue {i64, ptr } %array1, 1
31 %tmp = getelementptr inbounds %tarray, ptr %array2, i32 0, i32 1
32 %array2_ptr = load ptr, ptr %tmp
33 %cond = icmp eq ptr %array1_ptr, %array2_ptr
34 br i1 %cond, label %equal, label %unequal
41 ; CHECK-DAG: cmpld {{([0-9]+,)?}}4, 3
42 ; CHECK-DAG: std 6, 72(1)
43 ; CHECK-DAG: std 5, 64(1)
44 ; CHECK-DAG: std 3, -[[OFFSET1:[0-9]+]]
45 ; CHECK-DAG: std 3, -[[OFFSET2:[0-9]+]]
46 ; CHECK: ld 3, -[[OFFSET1]](1)
47 ; CHECK: ld 3, -[[OFFSET2]](1)
49 define ptr @func3(ptr byval({ i64, ptr }) %array1, ptr byval(%tarray) %array2) {
51 %tmp1 = getelementptr inbounds { i64, ptr }, ptr %array1, i32 0, i32 1
52 %array1_ptr = load ptr, ptr %tmp1
53 %tmp2 = getelementptr inbounds %tarray, ptr %array2, i32 0, i32 1
54 %array2_ptr = load ptr, ptr %tmp2
55 %cond = icmp eq ptr %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 ptr @func4(i64 %p1, i64 %p2, i64 %p3, i64 %p4,
71 i64 %p5, i64 %p6, i64 %p7, i64 %p8,
72 { i64, ptr } %array1, ptr byval(%tarray) %array2) {
74 %array1_ptr = extractvalue {i64, ptr } %array1, 1
75 %tmp = getelementptr inbounds %tarray, ptr %array2, i32 0, i32 1
76 %array2_ptr = load ptr, ptr %tmp
77 %cond = icmp eq ptr %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: std [[REG2]], -[[OFFSET1:[0-9]+]](1)
89 ; CHECK: std [[REG3]], -[[OFFSET2:[0-9]+]](1)
90 ; CHECK: cmpld {{([0-9]+,)?}}[[REG2]], [[REG3]]
91 ; CHECK: ld 3, -[[OFFSET1]](1)
92 ; CHECK: ld 3, -[[OFFSET2]](1)