summaryrefslogtreecommitdiffstats
path: root/tests/libbcc/test_reduce_general_metadata.ll
blob: b41234a7910690c292c0e85026b383111c215963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
; Check that the #rs_export_reduce node is recognized.

; RUN: llvm-rs-as %s -o %t
; RUN: bcinfo %t | FileCheck %s

; CHECK: exportReduceNewCount: 8
; CHECK: exportReduceNewList[0]: addint - 0x00000001 - 1 - 4
; CHECK:   accumulator(aiAccum)
; CHECK: exportReduceNewList[1]: mpyint - 0x00000001 - 1 - 4
; CHECK:   initializer(mpyInit)
; CHECK:   accumulator(mpyAccum)
; CHECK: exportReduceNewList[2]: dp - 0x00000001 - 2 - 4
; CHECK:   accumulator(dpAccum)
; CHECK:   combiner(dpSum)
; CHECK: exportReduceNewList[3]: findMinAndMax - 0x00000009 - 1 - 16
; CHECK:   initializer(fMMInit)
; CHECK:   accumulator(fMMAccumulator)
; CHECK:   combiner(fMMCombiner)
; CHECK:   outconverter(fMMOutConverter)
; CHECK: exportReduceNewList[4]: fz - 0x00000009 - 1 - 4
; CHECK:   initializer(fzInit)
; CHECK:   accumulator(fzAccum)
; CHECK:   combiner(fzCombine)
; CHECK:   halter(fzFound)
; CHECK: exportReduceNewList[5]: fz2 - 0x00000019 - 1 - 8
; CHECK:   initializer(fz2Init)
; CHECK:   accumulator(fz2Accum)
; CHECK:   combiner(fz2Combine)
; CHECK:   halter(fz2Found)
; CHECK: exportReduceNewList[6]: histogram - 0x00000001 - 1 - 1024
; CHECK:   accumulator(hsgAccum)
; CHECK:   combiner(hsgCombine)
; CHECK: exportReduceNewList[7]: mode - 0x00000001 - 1 - 1024
; CHECK:   accumulator(hsgAccum)
; CHECK:   combiner(hsgCombine)
; CHECK:   outconverter(modeOutConvert)

; ModuleID = 'reduce_general_examples.bc'
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-none-linux-gnueabi"

%struct.MinAndMax.0 = type { %struct.IndexedVal.1, %struct.IndexedVal.1 }
%struct.IndexedVal.1 = type { float, i32 }

@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
@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"

; Function Attrs: nounwind
define internal void @aiAccum(i32* nocapture %accum, i32 %val) #0 {
  %1 = load i32, i32* %accum, align 4, !tbaa !18
  %2 = add nsw i32 %1, %val
  store i32 %2, i32* %accum, align 4, !tbaa !18
  ret void
}

; Function Attrs: nounwind
define internal void @mpyInit(i32* nocapture %accum) #0 {
  store i32 1, i32* %accum, align 4, !tbaa !18
  ret void
}

; Function Attrs: nounwind
define internal void @mpyAccum(i32* nocapture %accum, i32 %val) #0 {
  %1 = load i32, i32* %accum, align 4, !tbaa !18
  %2 = mul nsw i32 %1, %val
  store i32 %2, i32* %accum, align 4, !tbaa !18
  ret void
}

; Function Attrs: nounwind
define internal void @dpAccum(float* nocapture %accum, float %in1, float %in2) #0 {
  %1 = fmul float %in1, %in2
  %2 = load float, float* %accum, align 4, !tbaa !22
  %3 = fadd float %1, %2
  store float %3, float* %accum, align 4, !tbaa !22
  ret void
}

; Function Attrs: nounwind
define internal void @dpSum(float* nocapture %accum, float* nocapture %val) #0 {
  %1 = load float, float* %val, align 4, !tbaa !22
  %2 = load float, float* %accum, align 4, !tbaa !22
  %3 = fadd float %1, %2
  store float %3, float* %accum, align 4, !tbaa !22
  ret void
}

; Function Attrs: nounwind
define internal void @fMMInit(%struct.MinAndMax.0* nocapture %accum) #0 {
  %1 = bitcast %struct.MinAndMax.0* %accum to i8*
  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
  ret void
}

; Function Attrs: nounwind
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #0

; Function Attrs: nounwind
define internal void @fMMAccumulator(%struct.MinAndMax.0* nocapture %accum, float %in, i32 %x) #0 {
  %1 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %accum, i64 0, i32 0, i32 0
  %2 = load float, float* %1, align 4, !tbaa !22
  %3 = fcmp ogt float %2, %in
  br i1 %3, label %4, label %6

; <label>:4                                       ; preds = %0
  store float %in, float* %1, align 4
  %5 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %accum, i64 0, i32 0, i32 1
  store i32 %x, i32* %5, align 4
  br label %6

; <label>:6                                       ; preds = %4, %0
  %7 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %accum, i64 0, i32 1, i32 0
  %8 = load float, float* %7, align 4, !tbaa !22
  %9 = fcmp olt float %8, %in
  br i1 %9, label %10, label %12

; <label>:10                                      ; preds = %6
  store float %in, float* %7, align 4
  %11 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %accum, i64 0, i32 1, i32 1
  store i32 %x, i32* %11, align 4
  br label %12

; <label>:12                                      ; preds = %10, %6
  ret void
}

; Function Attrs: nounwind
define internal void @fMMCombiner(%struct.MinAndMax.0* nocapture %accum, %struct.MinAndMax.0* nocapture %val) #0 {
  %1 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 0, i32 0
  %2 = load float, float* %1, align 4, !tbaa !22
  %3 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 0, i32 1
  %4 = load i32, i32* %3, align 4, !tbaa !18
  tail call void @fMMAccumulator(%struct.MinAndMax.0* %accum, float %2, i32 %4)
  %5 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 1, i32 0
  %6 = load float, float* %5, align 4, !tbaa !22
  %7 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 1, i32 1
  %8 = load i32, i32* %7, align 4, !tbaa !18
  tail call void @fMMAccumulator(%struct.MinAndMax.0* %accum, float %6, i32 %8)
  ret void
}

; Function Attrs: nounwind
define internal void @fMMOutConverter(<2 x i32>* nocapture %result, %struct.MinAndMax.0* nocapture %val) #0 {
  %1 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 0, i32 1
  %2 = load i32, i32* %1, align 4, !tbaa !18
  %3 = load <2 x i32>, <2 x i32>* %result, align 8
  %4 = insertelement <2 x i32> %3, i32 %2, i64 0
  store <2 x i32> %4, <2 x i32>* %result, align 8
  %5 = getelementptr inbounds %struct.MinAndMax.0, %struct.MinAndMax.0* %val, i64 0, i32 1, i32 1
  %6 = load i32, i32* %5, align 4, !tbaa !18
  %7 = insertelement <2 x i32> %4, i32 %6, i64 1
  store <2 x i32> %7, <2 x i32>* %result, align 8
  ret void
}

; Function Attrs: nounwind
define internal void @fzInit(i32* nocapture %accumIdx) #0 {
  store i32 -1, i32* %accumIdx, align 4, !tbaa !18
  ret void
}

; Function Attrs: nounwind
define internal void @fzAccum(i32* nocapture %accumIdx, i32 %inVal, i32 %x) #0 {
  %1 = icmp eq i32 %inVal, 0
  br i1 %1, label %2, label %3

; <label>:2                                       ; preds = %0
  store i32 %x, i32* %accumIdx, align 4, !tbaa !18
  br label %3

; <label>:3                                       ; preds = %2, %0
  ret void
}

; Function Attrs: nounwind
define internal void @fzCombine(i32* nocapture %accumIdx, i32* nocapture %accumIdx2) #0 {
  %1 = load i32, i32* %accumIdx2, align 4, !tbaa !18
  %2 = icmp sgt i32 %1, -1
  br i1 %2, label %3, label %4

; <label>:3                                       ; preds = %0
  store i32 %1, i32* %accumIdx, align 4, !tbaa !18
  br label %4

; <label>:4                                       ; preds = %3, %0
  ret void
}

; Function Attrs: nounwind readonly
define internal i1 @fzFound(i32* nocapture %accumIdx) #1 {
  %1 = load i32, i32* %accumIdx, align 4, !tbaa !18
  %2 = icmp sgt i32 %1, -1
  ret i1 %2
}

; Function Attrs: nounwind
define internal void @fz2Init(<2 x i32>* nocapture %accum) #0 {
  store <2 x i32> <i32 -1, i32 -1>, <2 x i32>* %accum, align 8
  ret void
}

; Function Attrs: nounwind
define internal void @fz2Accum(<2 x i32>* nocapture %accum, i32 %inVal, i32 %x, i32 %y) #0 {
  %1 = icmp eq i32 %inVal, 0
  br i1 %1, label %2, label %5

; <label>:2                                       ; preds = %0
  %3 = insertelement <2 x i32> undef, i32 %x, i64 0
  %4 = insertelement <2 x i32> %3, i32 %y, i64 1
  store <2 x i32> %4, <2 x i32>* %accum, align 8
  br label %5

; <label>:5                                       ; preds = %2, %0
  ret void
}

; Function Attrs: nounwind
define internal void @fz2Combine(<2 x i32>* nocapture %accum, <2 x i32>* nocapture %accum2) #0 {
  %1 = load <2 x i32>, <2 x i32>* %accum2, align 8
  %2 = extractelement <2 x i32> %1, i64 0
  %3 = icmp sgt i32 %2, -1
  br i1 %3, label %4, label %5

; <label>:4                                       ; preds = %0
  store <2 x i32> %1, <2 x i32>* %accum, align 8, !tbaa !25
  br label %5

; <label>:5                                       ; preds = %4, %0
  ret void
}

; Function Attrs: nounwind readonly
define internal i1 @fz2Found(<2 x i32>* nocapture %accum) #1 {
  %1 = load <2 x i32>, <2 x i32>* %accum, align 8
  %2 = extractelement <2 x i32> %1, i64 0
  %3 = icmp sgt i32 %2, -1
  ret i1 %3
}

; Function Attrs: nounwind
define internal void @hsgAccum([256 x i32]* nocapture %h, i8 %in) #0 {
  %1 = zext i8 %in to i64
  %2 = getelementptr inbounds [256 x i32], [256 x i32]* %h, i64 0, i64 %1
  %3 = load i32, i32* %2, align 4, !tbaa !18
  %4 = add i32 %3, 1
  store i32 %4, i32* %2, align 4, !tbaa !18
  ret void
}

; Function Attrs: nounwind
define internal void @hsgCombine([256 x i32]* nocapture %accum, [256 x i32]* nocapture %addend) #0 {
  br label %2

; <label>:1                                       ; preds = %2
  ret void

; <label>:2                                       ; preds = %2, %0
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %2 ]
  %3 = getelementptr inbounds [256 x i32], [256 x i32]* %addend, i64 0, i64 %indvars.iv
  %4 = load i32, i32* %3, align 4, !tbaa !18
  %5 = getelementptr inbounds [256 x i32], [256 x i32]* %accum, i64 0, i64 %indvars.iv
  %6 = load i32, i32* %5, align 4, !tbaa !18
  %7 = add i32 %6, %4
  store i32 %7, i32* %5, align 4, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, 256
  br i1 %exitcond, label %1, label %2
}

; Function Attrs: nounwind
define internal void @modeOutConvert(<2 x i32>* nocapture %result, [256 x i32]* nocapture %h) #0 {
  br label %8

; <label>:1                                       ; preds = %8
  %2 = load <2 x i32>, <2 x i32>* %result, align 8
  %3 = insertelement <2 x i32> %2, i32 %i.0.mode.0, i64 0
  store <2 x i32> %3, <2 x i32>* %result, align 8
  %4 = zext i32 %i.0.mode.0 to i64
  %5 = getelementptr inbounds [256 x i32], [256 x i32]* %h, i64 0, i64 %4
  %6 = load i32, i32* %5, align 4, !tbaa !18
  %7 = insertelement <2 x i32> %3, i32 %6, i64 1
  store <2 x i32> %7, <2 x i32>* %result, align 8
  ret void

; <label>:8                                       ; preds = %8, %0
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %8 ]
  %mode.01 = phi i32 [ 0, %0 ], [ %i.0.mode.0, %8 ]
  %9 = getelementptr inbounds [256 x i32], [256 x i32]* %h, i64 0, i64 %indvars.iv
  %10 = load i32, i32* %9, align 4, !tbaa !18
  %11 = zext i32 %mode.01 to i64
  %12 = getelementptr inbounds [256 x i32], [256 x i32]* %h, i64 0, i64 %11
  %13 = load i32, i32* %12, align 4, !tbaa !18
  %14 = icmp ugt i32 %10, %13
  %15 = trunc i64 %indvars.iv to i32
  %i.0.mode.0 = select i1 %14, i32 %15, i32 %mode.01
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, 256
  br i1 %exitcond, label %1, label %8
}

attributes #0 = { nounwind }
attributes #1 = { nounwind readonly }

!llvm.ident = !{!0}
!\23pragma = !{!1, !2}
!\23rs_export_reduce = !{!3, !5, !7, !9, !11, !13, !15, !17}

!0 = !{!"clang version 3.6 "}
!1 = !{!"version", !"1"}
!2 = !{!"java_package_name", !"examples"}
!3 = !{!"addint", !"4", !4}
!4 = !{!"aiAccum", !"1"}
!5 = !{!"mpyint", !"4", !6, !"mpyInit"}
!6 = !{!"mpyAccum", !"1"}
!7 = !{!"dp", !"4", !8, null, !"dpSum"}
!8 = !{!"dpAccum", !"1"}
!9 = !{!"findMinAndMax", !"16", !10, !"fMMInit", !"fMMCombiner", !"fMMOutConverter"}
!10 = !{!"fMMAccumulator", !"9"}
!11 = !{!"fz", !"4", !12, !"fzInit", !"fzCombine", null, !"fzFound"}
!12 = !{!"fzAccum", !"9"}
!13 = !{!"fz2", !"8", !14, !"fz2Init", !"fz2Combine", null, !"fz2Found"}
!14 = !{!"fz2Accum", !"25"}
!15 = !{!"histogram", !"1024", !16, null, !"hsgCombine"}
!16 = !{!"hsgAccum", !"1"}
!17 = !{!"mode", !"1024", !16, null, !"hsgCombine", !"modeOutConvert"}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !20, i64 0}
!20 = !{!"omnipotent char", !21, i64 0}
!21 = !{!"Simple C/C++ TBAA"}
!22 = !{!23, !23, i64 0}
!23 = !{!"float", !20, i64 0}
!24 = !{i64 0, i64 4, !22, i64 4, i64 4, !18, i64 8, i64 4, !22, i64 12, i64 4, !18}
!25 = !{!20, !20, i64 0}