1; RUN: llc -march=hexagon -verify-machineinstrs < %s | FileCheck %s
2
3; Check that this testcase compiles successfully.
4; CHECK: dealloc_return
5
6target triple = "hexagon"
7
8%type.0 = type { %type.1, %type.3, i32, i32 }
9%type.1 = type { %type.2 }
10%type.2 = type { i8 }
11%type.3 = type { i8*, [12 x i8] }
12%type.4 = type { i8 }
13
14define weak_odr dereferenceable(28) %type.0* @fred(%type.0* %p0, i32 %p1, %type.0* dereferenceable(28) %p2, i32 %p3, i32 %p4) local_unnamed_addr align 2 {
15b0:
16  %t0 = getelementptr inbounds %type.0, %type.0* %p0, i32 0, i32 2
17  %t1 = load i32, i32* %t0, align 4
18  %t2 = icmp ult i32 %t1, %p1
19  %t3 = getelementptr inbounds %type.0, %type.0* %p2, i32 0, i32 2
20  br i1 %t2, label %b2, label %b1
21
22b1:
23  %t4 = load i32, i32* %t3, align 4
24  %t5 = icmp ult i32 %t4, %p3
25  br i1 %t5, label %b2, label %b3
26
27b2:
28  %t6 = bitcast %type.0* %p0 to %type.4*
29  tail call void @blah(%type.4* %t6)
30  %t7 = load i32, i32* %t3, align 4
31  %t8 = load i32, i32* %t0, align 4
32  br label %b3
33
34b3:
35  %t9 = phi i32 [ %t8, %b2 ], [ %t1, %b1 ]
36  %t10 = phi i32 [ %t7, %b2 ], [ %t4, %b1 ]
37  %t11 = sub i32 %t10, %p3
38  %t12 = icmp ult i32 %t11, %p4
39  %t13 = select i1 %t12, i32 %t11, i32 %p4
40  %t14 = xor i32 %t9, -1
41  %t15 = icmp ult i32 %t13, %t14
42  br i1 %t15, label %b5, label %b4
43
44b4:
45  %t16 = bitcast %type.0* %p0 to %type.4*
46  tail call void @danny(%type.4* %t16)
47  br label %b5
48
49b5:
50  %t17 = icmp eq i32 %t13, 0
51  br i1 %t17, label %b33, label %b6
52
53b6:
54  %t18 = load i32, i32* %t0, align 4
55  %t19 = add i32 %t18, %t13
56  %t20 = icmp eq i32 %t19, -1
57  br i1 %t20, label %b7, label %b8
58
59b7:
60  %t21 = bitcast %type.0* %p0 to %type.4*
61  tail call void @danny(%type.4* %t21)
62  br label %b8
63
64b8:
65  %t22 = getelementptr inbounds %type.0, %type.0* %p0, i32 0, i32 3
66  %t23 = load i32, i32* %t22, align 4
67  %t24 = icmp ult i32 %t23, %t19
68  br i1 %t24, label %b9, label %b10
69
70b9:
71  %t25 = load i32, i32* %t0, align 4
72  tail call void @sammy(%type.0* nonnull %p0, i32 %t19, i32 %t25)
73  %t26 = load i32, i32* %t22, align 4
74  br label %b15
75
76b10:
77  %t27 = icmp eq i32 %t19, 0
78  br i1 %t27, label %b11, label %b15
79
80b11:
81  %t28 = icmp ugt i32 %t23, 15
82  %t29 = getelementptr inbounds %type.0, %type.0* %p0, i32 0, i32 1
83  br i1 %t28, label %b12, label %b13
84
85b12:
86  %t30 = getelementptr inbounds %type.3, %type.3* %t29, i32 0, i32 0
87  %t31 = load i8*, i8** %t30, align 4
88  br label %b14
89
90b13:
91  %t32 = bitcast %type.3* %t29 to i8*
92  br label %b14
93
94b14:
95  %t33 = phi i8* [ %t31, %b12 ], [ %t32, %b13 ]
96  store i32 0, i32* %t0, align 4
97  br label %b31
98
99b15:
100  %t34 = phi i32 [ %t26, %b9 ], [ %t23, %b10 ]
101  %t35 = icmp ugt i32 %t34, 15
102  %t36 = getelementptr inbounds %type.0, %type.0* %p0, i32 0, i32 1
103  br i1 %t35, label %b16, label %b17
104
105b16:
106  %t37 = getelementptr inbounds %type.3, %type.3* %t36, i32 0, i32 0
107  %t38 = load i8*, i8** %t37, align 4
108  br label %b18
109
110b17:
111  %t39 = bitcast %type.3* %t36 to i8*
112  %t40 = bitcast %type.3* %t36 to i8*
113  br label %b18
114
115b18:
116  %t41 = phi i8* [ %t38, %b16 ], [ %t39, %b17 ]
117  %t42 = phi i8* [ %t38, %b16 ], [ %t40, %b17 ]
118  %t43 = getelementptr inbounds i8, i8* %t41, i32 %p1
119  %t44 = getelementptr inbounds i8, i8* %t43, i32 %t13
120  %t45 = getelementptr inbounds i8, i8* %t42, i32 %p1
121  %t46 = load i32, i32* %t0, align 4
122  %t47 = sub i32 %t46, %p1
123  tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %t44, i8* %t45, i32 %t47, i1 false) #1
124  %t48 = icmp eq %type.0* %p0, %p2
125  %t49 = load i32, i32* %t22, align 4
126  %t50 = icmp ugt i32 %t49, 15
127  br i1 %t50, label %b19, label %b20
128
129b19:
130  %t51 = getelementptr inbounds %type.3, %type.3* %t36, i32 0, i32 0
131  %t52 = load i8*, i8** %t51, align 4
132  br label %b21
133
134b20:
135  %t53 = bitcast %type.3* %t36 to i8*
136  br label %b21
137
138b21:
139  %t54 = phi i8* [ %t52, %b19 ], [ %t53, %b20 ]
140  %t55 = getelementptr inbounds i8, i8* %t54, i32 %p1
141  br i1 %t48, label %b22, label %b26
142
143b22:
144  br i1 %t50, label %b23, label %b24
145
146b23:
147  %t56 = getelementptr inbounds %type.3, %type.3* %t36, i32 0, i32 0
148  %t57 = load i8*, i8** %t56, align 4
149  br label %b25
150
151b24:
152  %t58 = bitcast %type.3* %t36 to i8*
153  br label %b25
154
155b25:
156  %t59 = phi i8* [ %t57, %b23 ], [ %t58, %b24 ]
157  %t60 = icmp ult i32 %p1, %p3
158  %t61 = select i1 %t60, i32 %t13, i32 0
159  %t62 = add i32 %t61, %p3
160  %t63 = getelementptr inbounds i8, i8* %t59, i32 %t62
161  tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %t55, i8* %t63, i32 %t13, i1 false) #1
162  br label %b27
163
164b26:
165  %t64 = getelementptr inbounds %type.0, %type.0* %p2, i32 0, i32 3
166  %t65 = load i32, i32* %t64, align 4
167  %t66 = icmp ugt i32 %t65, 15
168  %t67 = getelementptr inbounds %type.0, %type.0* %p2, i32 0, i32 1
169  %t68 = getelementptr inbounds %type.3, %type.3* %t67, i32 0, i32 0
170  %t69 = load i8*, i8** %t68, align 4
171  %t70 = bitcast %type.3* %t67 to i8*
172  %t71 = select i1 %t66, i8* %t69, i8* %t70
173  %t72 = getelementptr inbounds i8, i8* %t71, i32 %p3
174  tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %t55, i8* %t72, i32 %t13, i1 false) #1
175  br label %b27
176
177b27:
178  %t73 = load i32, i32* %t22, align 4
179  %t74 = icmp ugt i32 %t73, 15
180  br i1 %t74, label %b28, label %b29
181
182b28:
183  %t75 = getelementptr inbounds %type.3, %type.3* %t36, i32 0, i32 0
184  %t76 = load i8*, i8** %t75, align 4
185  br label %b30
186
187b29:
188  %t77 = bitcast %type.3* %t36 to i8*
189  br label %b30
190
191b30:
192  %t78 = phi i8* [ %t76, %b28 ], [ %t77, %b29 ]
193  store i32 %t19, i32* %t0, align 4
194  %t79 = getelementptr inbounds i8, i8* %t78, i32 %t19
195  br label %b31
196
197b31:
198  %t80 = phi i8* [ %t33, %b14 ], [ %t79, %b30 ]
199  store i8 0, i8* %t80, align 1
200  br label %b33
201
202b33:
203  ret %type.0* %p0
204}
205
206declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) #0
207declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i1) #0
208
209declare void @blah(%type.4*) local_unnamed_addr
210declare void @danny(%type.4*) local_unnamed_addr
211declare void @sammy(%type.0*, i32, i32) local_unnamed_addr align 2
212
213attributes #0 = { argmemonly nounwind }
214attributes #1 = { nounwind }
215