test_reduce_general_metadata.ll revision 9197d612935852c05a641bc3418f79edaf402932
1; Check that the #rs_export_reduce node is recognized.
2
3; RUN: llvm-rs-as %s -o %t
4; RUN: bcinfo %t | FileCheck %s
5
6; CHECK: exportReduceNewCount: 8
7; CHECK: exportReduceNewList[0]: addint - 0x00000001 - 1 - 4
8; CHECK:   accumulator(aiAccum)
9; CHECK: exportReduceNewList[1]: mpyint - 0x00000001 - 1 - 4
10; CHECK:   initializer(mpyInit)
11; CHECK:   accumulator(mpyAccum)
12; CHECK: exportReduceNewList[2]: dp - 0x00000001 - 2 - 4
13; CHECK:   accumulator(dpAccum)
14; CHECK:   combiner(dpSum)
15; CHECK: exportReduceNewList[3]: findMinAndMax - 0x00000009 - 1 - 16
16; CHECK:   initializer(fMMInit)
17; CHECK:   accumulator(fMMAccumulator)
18; CHECK:   combiner(fMMCombiner)
19; CHECK:   outconverter(fMMOutConverter)
20; CHECK: exportReduceNewList[4]: fz - 0x00000009 - 1 - 4
21; CHECK:   initializer(fzInit)
22; CHECK:   accumulator(fzAccum)
23; CHECK:   combiner(fzCombine)
24; CHECK:   halter(fzFound)
25; CHECK: exportReduceNewList[5]: fz2 - 0x00000019 - 1 - 8
26; CHECK:   initializer(fz2Init)
27; CHECK:   accumulator(fz2Accum)
28; CHECK:   combiner(fz2Combine)
29; CHECK:   halter(fz2Found)
30; CHECK: exportReduceNewList[6]: histogram - 0x00000001 - 1 - 1024
31; CHECK:   accumulator(hsgAccum)
32; CHECK:   combiner(hsgCombine)
33; CHECK: exportReduceNewList[7]: mode - 0x00000001 - 1 - 1024
34; CHECK:   accumulator(hsgAccum)
35; CHECK:   combiner(hsgCombine)
36; CHECK:   outconverter(modeOutConvert)
37
38; ModuleID = 'reduce_general_examples.bc'
39target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
40target triple = "aarch64-none-linux-gnueabi"
41
42%struct.MinAndMax.0 = type { %struct.IndexedVal.1, %struct.IndexedVal.1 }
43%struct.IndexedVal.1 = type { float, i32 }
44
45@fMMInit.r = internal unnamed_addr constant %struct.MinAndMax.0 { %struct.IndexedVal.1 { float 0.000000e+00, i32 -1 }, %struct.IndexedVal.1 { float -0.000000e+00, i32 -1 } }, align 4
46@llvm.used = appending global [20 x i8*] [i8* bitcast (void (<2 x i32>*)* @fz2Init to i8*), i8* bitcast (void ([256 x i32]*, [256 x i32]*)* @hsgCombine to i8*), i8* bitcast (i1 (<2 x i32>*)* @fz2Found to i8*), i8* bitcast (void (i32*, i32)* @mpyAccum to i8*), i8* bitcast (void (%struct.MinAndMax.0*)* @fMMInit to i8*), i8* bitcast (void (float*, float, float)* @dpAccum to i8*), i8* bitcast (void (<2 x i32>*, [256 x i32]*)* @modeOutConvert to i8*), i8* bitcast (void ([256 x i32]*, i8)* @hsgAccum to i8*), i8* bitcast (void (i32*)* @mpyInit to i8*), i8* bitcast (void (%struct.MinAndMax.0*, float, i32)* @fMMAccumulator to i8*), i8* bitcast (void (float*, float*)* @dpSum to i8*), i8* bitcast (void (%struct.MinAndMax.0*, %struct.MinAndMax.0*)* @fMMCombiner to i8*), i8* bitcast (void (i32*, i32*)* @fzCombine to i8*), i8* bitcast (void (i32*, i32)* @aiAccum to i8*), i8* bitcast (void (i32*)* @fzInit to i8*), i8* bitcast (void (i32*, i32, i32)* @fzAccum to i8*), i8* bitcast (i1 (i32*)* @fzFound to i8*), i8* bitcast (void (<2 x i32>*, i32, i32, i32)* @fz2Accum to i8*), i8* bitcast (void (<2 x i32>*, %struct.MinAndMax.0*)* @fMMOutConverter to i8*), i8* bitcast (void (<2 x i32>*, <2 x i32>*)* @fz2Combine to i8*)], section "llvm.metadata"
47
48; Function Attrs: nounwind
49define internal void @aiAccum(i32* nocapture %accum, i32 %val) #0 {
50  %1 = load i32, i32* %accum, align 4, !tbaa !18
51  %2 = add nsw i32 %1, %val
52  store i32 %2, i32* %accum, align 4, !tbaa !18
53  ret void
54}
55
56; Function Attrs: nounwind
57define internal void @mpyInit(i32* nocapture %accum) #0 {
58  store i32 1, i32* %accum, align 4, !tbaa !18
59  ret void
60}
61
62; Function Attrs: nounwind
63define internal void @mpyAccum(i32* nocapture %accum, i32 %val) #0 {
64  %1 = load i32, i32* %accum, align 4, !tbaa !18
65  %2 = mul nsw i32 %1, %val
66  store i32 %2, i32* %accum, align 4, !tbaa !18
67  ret void
68}
69
70; Function Attrs: nounwind
71define internal void @dpAccum(float* nocapture %accum, float %in1, float %in2) #0 {
72  %1 = fmul float %in1, %in2
73  %2 = load float, float* %accum, align 4, !tbaa !22
74  %3 = fadd float %1, %2
75  store float %3, float* %accum, align 4, !tbaa !22
76  ret void
77}
78
79; Function Attrs: nounwind
80define internal void @dpSum(float* nocapture %accum, float* nocapture %val) #0 {
81  %1 = load float, float* %val, align 4, !tbaa !22
82  %2 = load float, float* %accum, align 4, !tbaa !22
83  %3 = fadd float %1, %2
84  store float %3, float* %accum, align 4, !tbaa !22
85  ret void
86}
87
88; Function Attrs: nounwind
89define internal void @fMMInit(%struct.MinAndMax.0* nocapture %accum) #0 {
90  %1 = bitcast %struct.MinAndMax.0* %accum to i8*
91  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* bitcast (%struct.MinAndMax.0* @fMMInit.r to i8*), i64 16, i32 4, i1 false), !tbaa.struct !24
92  ret void
93}
94
95; Function Attrs: nounwind
96declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #0
97
98; Function Attrs: nounwind
99define internal void @fMMAccumulator(%struct.MinAndMax.0* nocapture %accum, float %in, i32 %x) #0 {
100  %1 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %accum, i64 0, i32 0, i32 0
101  %2 = load float, float* %1, align 4, !tbaa !22
102  %3 = fcmp ogt float %2, %in
103  br i1 %3, label %4, label %6
104
105; <label>:4                                       ; preds = %0
106  store float %in, float* %1, align 4
107  %5 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %accum, i64 0, i32 0, i32 1
108  store i32 %x, i32* %5, align 4
109  br label %6
110
111; <label>:6                                       ; preds = %4, %0
112  %7 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %accum, i64 0, i32 1, i32 0
113  %8 = load float, float* %7, align 4, !tbaa !22
114  %9 = fcmp olt float %8, %in
115  br i1 %9, label %10, label %12
116
117; <label>:10                                      ; preds = %6
118  store float %in, float* %7, align 4
119  %11 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %accum, i64 0, i32 1, i32 1
120  store i32 %x, i32* %11, align 4
121  br label %12
122
123; <label>:12                                      ; preds = %10, %6
124  ret void
125}
126
127; Function Attrs: nounwind
128define internal void @fMMCombiner(%struct.MinAndMax.0* nocapture %accum, %struct.MinAndMax.0* nocapture %val) #0 {
129  %1 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 0, i32 0
130  %2 = load float, float* %1, align 4, !tbaa !22
131  %3 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 0, i32 1
132  %4 = load i32, i32* %3, align 4, !tbaa !18
133  tail call void @fMMAccumulator(%struct.MinAndMax.0* %accum, float %2, i32 %4)
134  %5 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 1, i32 0
135  %6 = load float, float* %5, align 4, !tbaa !22
136  %7 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 1, i32 1
137  %8 = load i32, i32* %7, align 4, !tbaa !18
138  tail call void @fMMAccumulator(%struct.MinAndMax.0* %accum, float %6, i32 %8)
139  ret void
140}
141
142; Function Attrs: nounwind
143define internal void @fMMOutConverter(<2 x i32>* nocapture %result, %struct.MinAndMax.0* nocapture %val) #0 {
144  %1 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 0, i32 1
145  %2 = load i32, i32* %1, align 4, !tbaa !18
146  %3 = load <2 x i32>, <2 x i32>* %result, align 8
147  %4 = insertelement <2 x i32> %3, i32 %2, i64 0
148  store <2 x i32> %4, <2 x i32>* %result, align 8
149  %5 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 1, i32 1
150  %6 = load i32, i32* %5, align 4, !tbaa !18
151  %7 = insertelement <2 x i32> %4, i32 %6, i64 1
152  store <2 x i32> %7, <2 x i32>* %result, align 8
153  ret void
154}
155
156; Function Attrs: nounwind
157define internal void @fzInit(i32* nocapture %accumIdx) #0 {
158  store i32 -1, i32* %accumIdx, align 4, !tbaa !18
159  ret void
160}
161
162; Function Attrs: nounwind
163define internal void @fzAccum(i32* nocapture %accumIdx, i32 %inVal, i32 %x) #0 {
164  %1 = icmp eq i32 %inVal, 0
165  br i1 %1, label %2, label %3
166
167; <label>:2                                       ; preds = %0
168  store i32 %x, i32* %accumIdx, align 4, !tbaa !18
169  br label %3
170
171; <label>:3                                       ; preds = %2, %0
172  ret void
173}
174
175; Function Attrs: nounwind
176define internal void @fzCombine(i32* nocapture %accumIdx, i32* nocapture %accumIdx2) #0 {
177  %1 = load i32, i32* %accumIdx2, align 4, !tbaa !18
178  %2 = icmp sgt i32 %1, -1
179  br i1 %2, label %3, label %4
180
181; <label>:3                                       ; preds = %0
182  store i32 %1, i32* %accumIdx, align 4, !tbaa !18
183  br label %4
184
185; <label>:4                                       ; preds = %3, %0
186  ret void
187}
188
189; Function Attrs: nounwind readonly
190define internal i1 @fzFound(i32* nocapture %accumIdx) #1 {
191  %1 = load i32, i32* %accumIdx, align 4, !tbaa !18
192  %2 = icmp sgt i32 %1, -1
193  ret i1 %2
194}
195
196; Function Attrs: nounwind
197define internal void @fz2Init(<2 x i32>* nocapture %accum) #0 {
198  store <2 x i32> <i32 -1, i32 -1>, <2 x i32>* %accum, align 8
199  ret void
200}
201
202; Function Attrs: nounwind
203define internal void @fz2Accum(<2 x i32>* nocapture %accum, i32 %inVal, i32 %x, i32 %y) #0 {
204  %1 = icmp eq i32 %inVal, 0
205  br i1 %1, label %2, label %5
206
207; <label>:2                                       ; preds = %0
208  %3 = insertelement <2 x i32> undef, i32 %x, i64 0
209  %4 = insertelement <2 x i32> %3, i32 %y, i64 1
210  store <2 x i32> %4, <2 x i32>* %accum, align 8
211  br label %5
212
213; <label>:5                                       ; preds = %2, %0
214  ret void
215}
216
217; Function Attrs: nounwind
218define internal void @fz2Combine(<2 x i32>* nocapture %accum, <2 x i32>* nocapture %accum2) #0 {
219  %1 = load <2 x i32>, <2 x i32>* %accum2, align 8
220  %2 = extractelement <2 x i32> %1, i64 0
221  %3 = icmp sgt i32 %2, -1
222  br i1 %3, label %4, label %5
223
224; <label>:4                                       ; preds = %0
225  store <2 x i32> %1, <2 x i32>* %accum, align 8, !tbaa !25
226  br label %5
227
228; <label>:5                                       ; preds = %4, %0
229  ret void
230}
231
232; Function Attrs: nounwind readonly
233define internal i1 @fz2Found(<2 x i32>* nocapture %accum) #1 {
234  %1 = load <2 x i32>, <2 x i32>* %accum, align 8
235  %2 = extractelement <2 x i32> %1, i64 0
236  %3 = icmp sgt i32 %2, -1
237  ret i1 %3
238}
239
240; Function Attrs: nounwind
241define internal void @hsgAccum([256 x i32]* nocapture %h, i8 %in) #0 {
242  %1 = zext i8 %in to i64
243  %2 = getelementptr inbounds [256 x i32], [256 x i32]* %h, i64 0, i64 %1
244  %3 = load i32, i32* %2, align 4, !tbaa !18
245  %4 = add i32 %3, 1
246  store i32 %4, i32* %2, align 4, !tbaa !18
247  ret void
248}
249
250; Function Attrs: nounwind
251define internal void @hsgCombine([256 x i32]* nocapture %accum, [256 x i32]* nocapture %addend) #0 {
252  br label %2
253
254; <label>:1                                       ; preds = %2
255  ret void
256
257; <label>:2                                       ; preds = %2, %0
258  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %2 ]
259  %3 = getelementptr inbounds [256 x i32], [256 x i32]* %addend, i64 0, i64 %indvars.iv
260  %4 = load i32, i32* %3, align 4, !tbaa !18
261  %5 = getelementptr inbounds [256 x i32], [256 x i32]* %accum, i64 0, i64 %indvars.iv
262  %6 = load i32, i32* %5, align 4, !tbaa !18
263  %7 = add i32 %6, %4
264  store i32 %7, i32* %5, align 4, !tbaa !18
265  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
266  %exitcond = icmp eq i64 %indvars.iv.next, 256
267  br i1 %exitcond, label %1, label %2
268}
269
270; Function Attrs: nounwind
271define internal void @modeOutConvert(<2 x i32>* nocapture %result, [256 x i32]* nocapture %h) #0 {
272  br label %8
273
274; <label>:1                                       ; preds = %8
275  %2 = load <2 x i32>, <2 x i32>* %result, align 8
276  %3 = insertelement <2 x i32> %2, i32 %i.0.mode.0, i64 0
277  store <2 x i32> %3, <2 x i32>* %result, align 8
278  %4 = zext i32 %i.0.mode.0 to i64
279  %5 = getelementptr inbounds [256 x i32], [256 x i32]* %h, i64 0, i64 %4
280  %6 = load i32, i32* %5, align 4, !tbaa !18
281  %7 = insertelement <2 x i32> %3, i32 %6, i64 1
282  store <2 x i32> %7, <2 x i32>* %result, align 8
283  ret void
284
285; <label>:8                                       ; preds = %8, %0
286  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %8 ]
287  %mode.01 = phi i32 [ 0, %0 ], [ %i.0.mode.0, %8 ]
288  %9 = getelementptr inbounds [256 x i32], [256 x i32]* %h, i64 0, i64 %indvars.iv
289  %10 = load i32, i32* %9, align 4, !tbaa !18
290  %11 = zext i32 %mode.01 to i64
291  %12 = getelementptr inbounds [256 x i32], [256 x i32]* %h, i64 0, i64 %11
292  %13 = load i32, i32* %12, align 4, !tbaa !18
293  %14 = icmp ugt i32 %10, %13
294  %15 = trunc i64 %indvars.iv to i32
295  %i.0.mode.0 = select i1 %14, i32 %15, i32 %mode.01
296  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
297  %exitcond = icmp eq i64 %indvars.iv.next, 256
298  br i1 %exitcond, label %1, label %8
299}
300
301attributes #0 = { nounwind }
302attributes #1 = { nounwind readonly }
303
304!llvm.ident = !{!0}
305!\23pragma = !{!1, !2}
306!\23rs_export_reduce = !{!3, !5, !7, !9, !11, !13, !15, !17}
307
308!0 = !{!"clang version 3.6 "}
309!1 = !{!"version", !"1"}
310!2 = !{!"java_package_name", !"examples"}
311!3 = !{!"addint", !"4", !4}
312!4 = !{!"aiAccum", !"1"}
313!5 = !{!"mpyint", !"4", !6, !"mpyInit"}
314!6 = !{!"mpyAccum", !"1"}
315!7 = !{!"dp", !"4", !8, null, !"dpSum"}
316!8 = !{!"dpAccum", !"1"}
317!9 = !{!"findMinAndMax", !"16", !10, !"fMMInit", !"fMMCombiner", !"fMMOutConverter"}
318!10 = !{!"fMMAccumulator", !"9"}
319!11 = !{!"fz", !"4", !12, !"fzInit", !"fzCombine", null, !"fzFound"}
320!12 = !{!"fzAccum", !"9"}
321!13 = !{!"fz2", !"8", !14, !"fz2Init", !"fz2Combine", null, !"fz2Found"}
322!14 = !{!"fz2Accum", !"25"}
323!15 = !{!"histogram", !"1024", !16, null, !"hsgCombine"}
324!16 = !{!"hsgAccum", !"1"}
325!17 = !{!"mode", !"1024", !16, null, !"hsgCombine", !"modeOutConvert"}
326!18 = !{!19, !19, i64 0}
327!19 = !{!"int", !20, i64 0}
328!20 = !{!"omnipotent char", !21, i64 0}
329!21 = !{!"Simple C/C++ TBAA"}
330!22 = !{!23, !23, i64 0}
331!23 = !{!"float", !20, i64 0}
332!24 = !{i64 0, i64 4, !22, i64 4, i64 4, !18, i64 8, i64 4, !22, i64 12, i64 4, !18}
333!25 = !{!20, !20, i64 0}
334