Skip to content

Commit a8376bb

Browse files
committed
AMDGPU: Add baseline tests for libcall to intrinsic handling
Test all the different itanium mangled opencl functions that are interesting to replace with raw intrinsic calls. https://reviews.llvm.org/D157873
1 parent cf2cf19 commit a8376bb

18 files changed

+6823
-0
lines changed
Lines changed: 327 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,327 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2+
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-simplifylib %s | FileCheck %s
3+
4+
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8"
5+
6+
declare float @_Z4ceilf(float)
7+
declare <2 x float> @_Z4ceilDv2_f(<2 x float>)
8+
declare <3 x float> @_Z4ceilDv3_f(<3 x float>)
9+
declare <4 x float> @_Z4ceilDv4_f(<4 x float>)
10+
declare <8 x float> @_Z4ceilDv8_f(<8 x float>)
11+
declare <16 x float> @_Z4ceilDv16_f(<16 x float>)
12+
13+
declare double @_Z4ceild(double)
14+
declare <2 x double> @_Z4ceilDv2_d(<2 x double>)
15+
declare <3 x double> @_Z4ceilDv3_d(<3 x double>)
16+
declare <4 x double> @_Z4ceilDv4_d(<4 x double>)
17+
declare <8 x double> @_Z4ceilDv8_d(<8 x double>)
18+
declare <16 x double> @_Z4ceilDv16_d(<16 x double>)
19+
20+
declare half @_Z4ceilDh(half)
21+
declare <2 x half> @_Z4ceilDv2_Dh(<2 x half>)
22+
declare <3 x half> @_Z4ceilDv3_Dh(<3 x half>)
23+
declare <4 x half> @_Z4ceilDv4_Dh(<4 x half>)
24+
declare <8 x half> @_Z4ceilDv8_Dh(<8 x half>)
25+
declare <16 x half> @_Z4ceilDv16_Dh(<16 x half>)
26+
27+
define float @test_ceil_f32(float %arg) {
28+
; CHECK-LABEL: define float @test_ceil_f32
29+
; CHECK-SAME: (float [[ARG:%.*]]) {
30+
; CHECK-NEXT: [[CEIL:%.*]] = tail call float @_Z4ceilf(float [[ARG]])
31+
; CHECK-NEXT: ret float [[CEIL]]
32+
;
33+
%ceil = tail call float @_Z4ceilf(float %arg)
34+
ret float %ceil
35+
}
36+
37+
define <2 x float> @test_ceil_v2f32(<2 x float> %arg) {
38+
; CHECK-LABEL: define <2 x float> @test_ceil_v2f32
39+
; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {
40+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <2 x float> @_Z4ceilDv2_f(<2 x float> [[ARG]])
41+
; CHECK-NEXT: ret <2 x float> [[CEIL]]
42+
;
43+
%ceil = tail call <2 x float> @_Z4ceilDv2_f(<2 x float> %arg)
44+
ret <2 x float> %ceil
45+
}
46+
47+
define <3 x float> @test_ceil_v3f32(<3 x float> %arg) {
48+
; CHECK-LABEL: define <3 x float> @test_ceil_v3f32
49+
; CHECK-SAME: (<3 x float> [[ARG:%.*]]) {
50+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <3 x float> @_Z4ceilDv3_f(<3 x float> [[ARG]])
51+
; CHECK-NEXT: ret <3 x float> [[CEIL]]
52+
;
53+
%ceil = tail call <3 x float> @_Z4ceilDv3_f(<3 x float> %arg)
54+
ret <3 x float> %ceil
55+
}
56+
57+
define <4 x float> @test_ceil_v4f32(<4 x float> %arg) {
58+
; CHECK-LABEL: define <4 x float> @test_ceil_v4f32
59+
; CHECK-SAME: (<4 x float> [[ARG:%.*]]) {
60+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <4 x float> @_Z4ceilDv4_f(<4 x float> [[ARG]])
61+
; CHECK-NEXT: ret <4 x float> [[CEIL]]
62+
;
63+
%ceil = tail call <4 x float> @_Z4ceilDv4_f(<4 x float> %arg)
64+
ret <4 x float> %ceil
65+
}
66+
67+
define <8 x float> @test_ceil_v8f32(<8 x float> %arg) {
68+
; CHECK-LABEL: define <8 x float> @test_ceil_v8f32
69+
; CHECK-SAME: (<8 x float> [[ARG:%.*]]) {
70+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <8 x float> @_Z4ceilDv8_f(<8 x float> [[ARG]])
71+
; CHECK-NEXT: ret <8 x float> [[CEIL]]
72+
;
73+
%ceil = tail call <8 x float> @_Z4ceilDv8_f(<8 x float> %arg)
74+
ret <8 x float> %ceil
75+
}
76+
77+
define <16 x float> @test_ceil_v16f32(<16 x float> %arg) {
78+
; CHECK-LABEL: define <16 x float> @test_ceil_v16f32
79+
; CHECK-SAME: (<16 x float> [[ARG:%.*]]) {
80+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <16 x float> @_Z4ceilDv16_f(<16 x float> [[ARG]])
81+
; CHECK-NEXT: ret <16 x float> [[CEIL]]
82+
;
83+
%ceil = tail call <16 x float> @_Z4ceilDv16_f(<16 x float> %arg)
84+
ret <16 x float> %ceil
85+
}
86+
87+
define double @test_ceil_f64(double %arg) {
88+
; CHECK-LABEL: define double @test_ceil_f64
89+
; CHECK-SAME: (double [[ARG:%.*]]) {
90+
; CHECK-NEXT: [[CEIL:%.*]] = tail call double @_Z4ceild(double [[ARG]])
91+
; CHECK-NEXT: ret double [[CEIL]]
92+
;
93+
%ceil = tail call double @_Z4ceild(double %arg)
94+
ret double %ceil
95+
}
96+
97+
define <2 x double> @test_ceil_v2f64(<2 x double> %arg) {
98+
; CHECK-LABEL: define <2 x double> @test_ceil_v2f64
99+
; CHECK-SAME: (<2 x double> [[ARG:%.*]]) {
100+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <2 x double> @_Z4ceilDv2_d(<2 x double> [[ARG]])
101+
; CHECK-NEXT: ret <2 x double> [[CEIL]]
102+
;
103+
%ceil = tail call <2 x double> @_Z4ceilDv2_d(<2 x double> %arg)
104+
ret <2 x double> %ceil
105+
}
106+
107+
define <3 x double> @test_ceil_v3f64(<3 x double> %arg) {
108+
; CHECK-LABEL: define <3 x double> @test_ceil_v3f64
109+
; CHECK-SAME: (<3 x double> [[ARG:%.*]]) {
110+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <3 x double> @_Z4ceilDv3_d(<3 x double> [[ARG]])
111+
; CHECK-NEXT: ret <3 x double> [[CEIL]]
112+
;
113+
%ceil = tail call <3 x double> @_Z4ceilDv3_d(<3 x double> %arg)
114+
ret <3 x double> %ceil
115+
}
116+
117+
define <4 x double> @test_ceil_v4f64(<4 x double> %arg) {
118+
; CHECK-LABEL: define <4 x double> @test_ceil_v4f64
119+
; CHECK-SAME: (<4 x double> [[ARG:%.*]]) {
120+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <4 x double> @_Z4ceilDv4_d(<4 x double> [[ARG]])
121+
; CHECK-NEXT: ret <4 x double> [[CEIL]]
122+
;
123+
%ceil = tail call <4 x double> @_Z4ceilDv4_d(<4 x double> %arg)
124+
ret <4 x double> %ceil
125+
}
126+
127+
define <8 x double> @test_ceil_v8f64(<8 x double> %arg) {
128+
; CHECK-LABEL: define <8 x double> @test_ceil_v8f64
129+
; CHECK-SAME: (<8 x double> [[ARG:%.*]]) {
130+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <8 x double> @_Z4ceilDv8_d(<8 x double> [[ARG]])
131+
; CHECK-NEXT: ret <8 x double> [[CEIL]]
132+
;
133+
%ceil = tail call <8 x double> @_Z4ceilDv8_d(<8 x double> %arg)
134+
ret <8 x double> %ceil
135+
}
136+
137+
define <16 x double> @test_ceil_v16f64(<16 x double> %arg) {
138+
; CHECK-LABEL: define <16 x double> @test_ceil_v16f64
139+
; CHECK-SAME: (<16 x double> [[ARG:%.*]]) {
140+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <16 x double> @_Z4ceilDv16_d(<16 x double> [[ARG]])
141+
; CHECK-NEXT: ret <16 x double> [[CEIL]]
142+
;
143+
%ceil = tail call <16 x double> @_Z4ceilDv16_d(<16 x double> %arg)
144+
ret <16 x double> %ceil
145+
}
146+
147+
define half @test_ceil_f16(half %arg) {
148+
; CHECK-LABEL: define half @test_ceil_f16
149+
; CHECK-SAME: (half [[ARG:%.*]]) {
150+
; CHECK-NEXT: [[CEIL:%.*]] = tail call half @_Z4ceilDh(half [[ARG]])
151+
; CHECK-NEXT: ret half [[CEIL]]
152+
;
153+
%ceil = tail call half @_Z4ceilDh(half %arg)
154+
ret half %ceil
155+
}
156+
157+
define <2 x half> @test_ceil_v2f16(<2 x half> %arg) {
158+
; CHECK-LABEL: define <2 x half> @test_ceil_v2f16
159+
; CHECK-SAME: (<2 x half> [[ARG:%.*]]) {
160+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <2 x half> @_Z4ceilDv2_Dh(<2 x half> [[ARG]])
161+
; CHECK-NEXT: ret <2 x half> [[CEIL]]
162+
;
163+
%ceil = tail call <2 x half> @_Z4ceilDv2_Dh(<2 x half> %arg)
164+
ret <2 x half> %ceil
165+
}
166+
167+
define <3 x half> @test_ceil_v3f16(<3 x half> %arg) {
168+
; CHECK-LABEL: define <3 x half> @test_ceil_v3f16
169+
; CHECK-SAME: (<3 x half> [[ARG:%.*]]) {
170+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <3 x half> @_Z4ceilDv3_Dh(<3 x half> [[ARG]])
171+
; CHECK-NEXT: ret <3 x half> [[CEIL]]
172+
;
173+
%ceil = tail call <3 x half> @_Z4ceilDv3_Dh(<3 x half> %arg)
174+
ret <3 x half> %ceil
175+
}
176+
177+
define <4 x half> @test_ceil_v4f16(<4 x half> %arg) {
178+
; CHECK-LABEL: define <4 x half> @test_ceil_v4f16
179+
; CHECK-SAME: (<4 x half> [[ARG:%.*]]) {
180+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <4 x half> @_Z4ceilDv4_Dh(<4 x half> [[ARG]])
181+
; CHECK-NEXT: ret <4 x half> [[CEIL]]
182+
;
183+
%ceil = tail call <4 x half> @_Z4ceilDv4_Dh(<4 x half> %arg)
184+
ret <4 x half> %ceil
185+
}
186+
187+
define <8 x half> @test_ceil_v8f16(<8 x half> %arg) {
188+
; CHECK-LABEL: define <8 x half> @test_ceil_v8f16
189+
; CHECK-SAME: (<8 x half> [[ARG:%.*]]) {
190+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <8 x half> @_Z4ceilDv8_Dh(<8 x half> [[ARG]])
191+
; CHECK-NEXT: ret <8 x half> [[CEIL]]
192+
;
193+
%ceil = tail call <8 x half> @_Z4ceilDv8_Dh(<8 x half> %arg)
194+
ret <8 x half> %ceil
195+
}
196+
197+
define <16 x half> @test_ceil_v16f16(<16 x half> %arg) {
198+
; CHECK-LABEL: define <16 x half> @test_ceil_v16f16
199+
; CHECK-SAME: (<16 x half> [[ARG:%.*]]) {
200+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <16 x half> @_Z4ceilDv16_Dh(<16 x half> [[ARG]])
201+
; CHECK-NEXT: ret <16 x half> [[CEIL]]
202+
;
203+
%ceil = tail call <16 x half> @_Z4ceilDv16_Dh(<16 x half> %arg)
204+
ret <16 x half> %ceil
205+
}
206+
207+
define float @test_ceil_f32_nobuiltin_callsite(float %arg) {
208+
; CHECK-LABEL: define float @test_ceil_f32_nobuiltin_callsite
209+
; CHECK-SAME: (float [[ARG:%.*]]) {
210+
; CHECK-NEXT: [[CEIL:%.*]] = tail call float @_Z4ceilf(float [[ARG]]) #[[ATTR3:[0-9]+]]
211+
; CHECK-NEXT: ret float [[CEIL]]
212+
;
213+
%ceil = tail call float @_Z4ceilf(float %arg) #0
214+
ret float %ceil
215+
}
216+
217+
define <2 x float> @test_ceil_v2f32_nobuiltin_callsite(<2 x float> %arg) {
218+
; CHECK-LABEL: define <2 x float> @test_ceil_v2f32_nobuiltin_callsite
219+
; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {
220+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <2 x float> @_Z4ceilDv2_f(<2 x float> [[ARG]]) #[[ATTR3]]
221+
; CHECK-NEXT: ret <2 x float> [[CEIL]]
222+
;
223+
%ceil = tail call <2 x float> @_Z4ceilDv2_f(<2 x float> %arg) #0
224+
ret <2 x float> %ceil
225+
}
226+
227+
; "no-builtins" should be ignored
228+
define float @test_ceil_f32_nobuiltins(float %arg) #1 {
229+
; CHECK-LABEL: define float @test_ceil_f32_nobuiltins
230+
; CHECK-SAME: (float [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
231+
; CHECK-NEXT: [[CEIL:%.*]] = tail call float @_Z4ceilf(float [[ARG]]) #[[ATTR3]]
232+
; CHECK-NEXT: ret float [[CEIL]]
233+
;
234+
%ceil = tail call float @_Z4ceilf(float %arg) #0
235+
ret float %ceil
236+
}
237+
238+
define <2 x float> @test_ceil_v2f32_nobuiltins(<2 x float> %arg) #1 {
239+
; CHECK-LABEL: define <2 x float> @test_ceil_v2f32_nobuiltins
240+
; CHECK-SAME: (<2 x float> [[ARG:%.*]]) #[[ATTR0]] {
241+
; CHECK-NEXT: [[CEIL:%.*]] = tail call <2 x float> @_Z4ceilDv2_f(<2 x float> [[ARG]]) #[[ATTR3]]
242+
; CHECK-NEXT: ret <2 x float> [[CEIL]]
243+
;
244+
%ceil = tail call <2 x float> @_Z4ceilDv2_f(<2 x float> %arg) #0
245+
ret <2 x float> %ceil
246+
}
247+
248+
define float @test_ceil_f32_preserve_flags(float %arg) {
249+
; CHECK-LABEL: define float @test_ceil_f32_preserve_flags
250+
; CHECK-SAME: (float [[ARG:%.*]]) {
251+
; CHECK-NEXT: [[CEIL:%.*]] = tail call nnan ninf float @_Z4ceilf(float [[ARG]])
252+
; CHECK-NEXT: ret float [[CEIL]]
253+
;
254+
%ceil = tail call nnan ninf float @_Z4ceilf(float %arg)
255+
ret float %ceil
256+
}
257+
258+
define <2 x float> @test_ceil_v2f32_preserve_flags(<2 x float> %arg) {
259+
; CHECK-LABEL: define <2 x float> @test_ceil_v2f32_preserve_flags
260+
; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {
261+
; CHECK-NEXT: [[CEIL:%.*]] = tail call nnan nsz contract <2 x float> @_Z4ceilDv2_f(<2 x float> [[ARG]])
262+
; CHECK-NEXT: ret <2 x float> [[CEIL]]
263+
;
264+
%ceil = tail call contract nsz nnan <2 x float> @_Z4ceilDv2_f(<2 x float> %arg)
265+
ret <2 x float> %ceil
266+
}
267+
268+
define float @test_ceil_f32_preserve_flags_md(float %arg) {
269+
; CHECK-LABEL: define float @test_ceil_f32_preserve_flags_md
270+
; CHECK-SAME: (float [[ARG:%.*]]) {
271+
; CHECK-NEXT: [[CEIL:%.*]] = tail call nnan ninf float @_Z4ceilf(float [[ARG]]), !foo !0
272+
; CHECK-NEXT: ret float [[CEIL]]
273+
;
274+
%ceil = tail call nnan ninf float @_Z4ceilf(float %arg), !foo !0
275+
ret float %ceil
276+
}
277+
278+
define <2 x float> @test_ceil_v2f32_preserve_flags_md(<2 x float> %arg) {
279+
; CHECK-LABEL: define <2 x float> @test_ceil_v2f32_preserve_flags_md
280+
; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {
281+
; CHECK-NEXT: [[CEIL:%.*]] = tail call nnan nsz contract <2 x float> @_Z4ceilDv2_f(<2 x float> [[ARG]]), !foo !0
282+
; CHECK-NEXT: ret <2 x float> [[CEIL]]
283+
;
284+
%ceil = tail call contract nsz nnan <2 x float> @_Z4ceilDv2_f(<2 x float> %arg), !foo !0
285+
ret <2 x float> %ceil
286+
}
287+
288+
; Test the libm name, not a recognized opencl builtin.
289+
declare float @ceilf(float) #2
290+
declare double @ceil(double) #2
291+
292+
define float @test_libm_ceil_f32(float %arg) {
293+
; CHECK-LABEL: define float @test_libm_ceil_f32
294+
; CHECK-SAME: (float [[ARG:%.*]]) {
295+
; CHECK-NEXT: [[CEIL:%.*]] = tail call float @ceilf(float [[ARG]])
296+
; CHECK-NEXT: ret float [[CEIL]]
297+
;
298+
%ceil = tail call float @ceilf(float %arg)
299+
ret float %ceil
300+
}
301+
302+
define double @test_libm_ceil_f64(double %arg) {
303+
; CHECK-LABEL: define double @test_libm_ceil_f64
304+
; CHECK-SAME: (double [[ARG:%.*]]) {
305+
; CHECK-NEXT: [[CEIL:%.*]] = tail call double @ceil(double [[ARG]])
306+
; CHECK-NEXT: ret double [[CEIL]]
307+
;
308+
%ceil = tail call double @ceil(double %arg)
309+
ret double %ceil
310+
}
311+
312+
define float @test_ceil_f32_strictfp(float %arg) #3 {
313+
; CHECK-LABEL: define float @test_ceil_f32_strictfp
314+
; CHECK-SAME: (float [[ARG:%.*]]) #[[ATTR2:[0-9]+]] {
315+
; CHECK-NEXT: [[CEIL:%.*]] = tail call nnan float @_Z4ceilf(float [[ARG]]) #[[ATTR2]]
316+
; CHECK-NEXT: ret float [[CEIL]]
317+
;
318+
%ceil = tail call nnan float @_Z4ceilf(float %arg) #3
319+
ret float %ceil
320+
}
321+
322+
attributes #0 = { nobuiltin }
323+
attributes #1 = { "no-builtins" }
324+
attributes #2 = { nounwind memory(none) }
325+
attributes #3 = { strictfp }
326+
327+
!0 = !{i32 1234}

0 commit comments

Comments
 (0)