Skip to content

Commit 8054680

Browse files
committed
[IR] Add a test for f128 libcall lowering (NFC)
`f128` intrinsic functions sometimes lower to `long double` library calls when they instead need to be `f128` versions. Add a test demonstrating current behavior.
1 parent af223bc commit 8054680

File tree

1 file changed

+328
-0
lines changed

1 file changed

+328
-0
lines changed
Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
;
2+
; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-none -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-USELD %}
3+
; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-linux-gnu -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-USELD %}
4+
; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-linux-musl -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-USELD %}
5+
; RUN: %if arm-registered-target %{ llc < %s -mtriple=arm-none-eabi -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-USELD %}
6+
; RUN: %if xfail-powerpc-registered-target %{ llc < %s -mtriple=powerpc-unknown -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-F128 %}
7+
; RUN: %if xfail-powerpc-registered-target %{ llc < %s -mtriple=powerpc64-unknown -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-F128 %}
8+
; RUN: %if riscv-registered-target %{ llc < %s -mtriple=riscv32-unknown -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-USELD %}
9+
; RUN: %if systemz-registered-target %{ llc < %s -mtriple=s390x-unknown -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-S390X %}
10+
; RUN: %if x86-registered-target %{ llc < %s -mtriple=i686-unknown -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-USELD %}
11+
; RUN: %if x86-registered-target %{ llc < %s -mtriple=x86_64-unknown -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,CHECK-USELD %}
12+
;
13+
; Verify that fp128 intrinsics only lower to `long double` calls (e.g. sinl) on
14+
; platforms where 128 and `long double` have the same layout, and where the
15+
; `*f128` versions are known to not exist. Otherwise, lower to f128 versions
16+
; (e.g. sinf128).
17+
;
18+
; Targets include:
19+
; * aarch64 (long double == f128, should use ld syms)
20+
; * arm (long double == f64, should use f128 syms)
21+
; * s390x (long double == f128, should use ld syms, some hardware support)
22+
; * x86, x64 (80-bit long double, should use ld syms)
23+
; * gnu (has f128 symbols on all platforms so we can use those)
24+
; * musl (no f128 symbols available)
25+
26+
; FIXME: targets are configured so these tests pass, but the output has not
27+
; yet been corrected.
28+
29+
define fp128 @test_acos(fp128 %a) {
30+
; CHECK-LABEL: test_acos:
31+
; CHECK-F128: acosf128
32+
; CHECK-USELD: acosl
33+
; CHECK-S390X: acosl
34+
start:
35+
%0 = tail call fp128 @llvm.acos.f128(fp128 %a)
36+
ret fp128 %0
37+
}
38+
39+
define fp128 @test_asin(fp128 %a) {
40+
; CHECK-LABEL: test_asin:
41+
; CHECK-F128: asinf128
42+
; CHECK-USELD: asinl
43+
; CHECK-S390X: asinl
44+
start:
45+
%0 = tail call fp128 @llvm.asin.f128(fp128 %a)
46+
ret fp128 %0
47+
}
48+
49+
define fp128 @test_atan(fp128 %a) {
50+
; CHECK-LABEL: test_atan:
51+
; CHECK-F128: atanf128
52+
; CHECK-USELD: atanl
53+
; CHECK-S390X: atanl
54+
start:
55+
%0 = tail call fp128 @llvm.atan.f128(fp128 %a)
56+
ret fp128 %0
57+
}
58+
59+
define fp128 @test_ceil(fp128 %a) {
60+
; CHECK-LABEL: test_ceil:
61+
; CHECK-F128: ceilf128
62+
; CHECK-USELD: ceill
63+
; CHECK-S390X: ceill
64+
start:
65+
%0 = tail call fp128 @llvm.ceil.f128(fp128 %a)
66+
ret fp128 %0
67+
}
68+
69+
define fp128 @test_copysign(fp128 %a, fp128 %b) {
70+
; copysign should always get lowered to assembly.
71+
; CHECK-LABEL: test_copysign:
72+
; CHECK-NOT: copysignf128
73+
; CHECK-NOT: copysignl
74+
start:
75+
%0 = tail call fp128 @llvm.copysign.f128(fp128 %a, fp128 %b)
76+
ret fp128 %0
77+
}
78+
79+
define fp128 @test_cos(fp128 %a) {
80+
; CHECK-LABEL: test_cos:
81+
; CHECK-F128: cosf128
82+
; CHECK-USELD: cosl
83+
; CHECK-S390X: cosl
84+
start:
85+
%0 = tail call fp128 @llvm.cos.f128(fp128 %a)
86+
ret fp128 %0
87+
}
88+
89+
define fp128 @test_exp10(fp128 %a) {
90+
; CHECK-LABEL: test_exp10:
91+
; CHECK-F128: exp10f128
92+
; CHECK-USELD: exp10l
93+
; CHECK-S390X: exp10l
94+
start:
95+
%0 = tail call fp128 @llvm.exp10.f128(fp128 %a)
96+
ret fp128 %0
97+
}
98+
99+
define fp128 @test_exp2(fp128 %a) {
100+
; CHECK-LABEL: test_exp2:
101+
; CHECK-F128: exp2f128
102+
; CHECK-USELD: exp2l
103+
; CHECK-S390X: exp2l
104+
start:
105+
%0 = tail call fp128 @llvm.exp2.f128(fp128 %a)
106+
ret fp128 %0
107+
}
108+
109+
110+
define fp128 @test_exp(fp128 %a) {
111+
; CHECK-LABEL: test_exp:
112+
; CHECK-F128: expf128
113+
; CHECK-USELD: expl
114+
; CHECK-S390X: expl
115+
start:
116+
%0 = tail call fp128 @llvm.exp.f128(fp128 %a)
117+
ret fp128 %0
118+
}
119+
120+
define fp128 @test_fabs(fp128 %a) {
121+
; fabs should always get lowered to assembly.
122+
; CHECK-LABEL: test_fabs:
123+
; CHECK-NOT: fabsf128
124+
; CHECK-NOT: fabsl
125+
start:
126+
%0 = tail call fp128 @llvm.fabs.f128(fp128 %a)
127+
ret fp128 %0
128+
}
129+
130+
define fp128 @test_floor(fp128 %a) {
131+
; CHECK-LABEL: test_floor:
132+
; CHECK-F128: floorf128
133+
; CHECK-USELD: floorl
134+
; CHECK-S390X: floorl
135+
start:
136+
%0 = tail call fp128 @llvm.floor.f128(fp128 %a)
137+
ret fp128 %0
138+
}
139+
140+
define fp128 @test_fma(fp128 %a, fp128 %b, fp128 %c) {
141+
; CHECK-LABEL: test_fma:
142+
; CHECK-F128: fmaf128
143+
; CHECK-USELD: fmal
144+
; CHECK-S390X: fmal
145+
start:
146+
%0 = tail call fp128 @llvm.fma.f128(fp128 %a, fp128 %b, fp128 %c)
147+
ret fp128 %0
148+
}
149+
150+
define { fp128, i32 } @test_frexp(fp128 %a) {
151+
; CHECK-LABEL: test_frexp:
152+
; CHECK-F128: frexpf128
153+
; CHECK-USELD: frexpl
154+
; CHECK-S390X: frexpl
155+
start:
156+
%0 = tail call { fp128, i32 } @llvm.frexp.f128(fp128 %a)
157+
ret { fp128, i32 } %0
158+
}
159+
160+
define fp128 @test_ldexp(fp128 %a, i32 %b) {
161+
; CHECK-LABEL: test_ldexp:
162+
; CHECK-F128: ldexpf128
163+
; CHECK-USELD: ldexpl
164+
; CHECK-S390X: ldexpl
165+
start:
166+
%0 = tail call fp128 @llvm.ldexp.f128(fp128 %a, i32 %b)
167+
ret fp128 %0
168+
}
169+
170+
define i64 @test_llrint(fp128 %a) {
171+
; CHECK-LABEL: test_llrint:
172+
; CHECK-F128: llrintf128
173+
; CHECK-USELD: llrintl
174+
; CHECK-S390X: llrintl
175+
start:
176+
%0 = tail call i64 @llvm.llrint.f128(fp128 %a)
177+
ret i64 %0
178+
}
179+
180+
define i64 @test_llround(fp128 %a) {
181+
; CHECK-LABEL: test_llround:
182+
; CHECK-F128: llroundf128
183+
; CHECK-USELD: llroundl
184+
; CHECK-S390X: llroundl
185+
start:
186+
%0 = tail call i64 @llvm.llround.i64.f128(fp128 %a)
187+
ret i64 %0
188+
}
189+
190+
define fp128 @test_log10(fp128 %a) {
191+
; CHECK-LABEL: test_log10:
192+
; CHECK-F128: log10f128
193+
; CHECK-USELD: log10l
194+
; CHECK-S390X: log10l
195+
start:
196+
%0 = tail call fp128 @llvm.log10.f128(fp128 %a)
197+
ret fp128 %0
198+
}
199+
200+
define fp128 @test_log2(fp128 %a) {
201+
; CHECK-LABEL: test_log2:
202+
; CHECK-F128: log2f128
203+
; CHECK-USELD: log2l
204+
; CHECK-S390X: log2l
205+
start:
206+
%0 = tail call fp128 @llvm.log2.f128(fp128 %a)
207+
ret fp128 %0
208+
}
209+
210+
define fp128 @test_log(fp128 %a) {
211+
; CHECK-LABEL: test_log:
212+
; CHECK-F128: logf128
213+
; CHECK-USELD: logl
214+
; CHECK-S390X: logl
215+
start:
216+
%0 = tail call fp128 @llvm.log.f128(fp128 %a)
217+
ret fp128 %0
218+
}
219+
220+
define i64 @test_lrint(fp128 %a) {
221+
; CHECK-LABEL: test_lrint:
222+
; CHECK-F128: lrintf128
223+
; CHECK-USELD: lrintl
224+
; CHECK-S390X: lrintl
225+
start:
226+
%0 = tail call i64 @llvm.lrint.f128(fp128 %a)
227+
ret i64 %0
228+
}
229+
230+
define i64 @test_lround(fp128 %a) {
231+
; CHECK-LABEL: test_lround:
232+
; CHECK-F128: lroundf128
233+
; CHECK-USELD: lroundl
234+
; CHECK-S390X: lroundl
235+
start:
236+
%0 = tail call i64 @llvm.lround.i64.f128(fp128 %a)
237+
ret i64 %0
238+
}
239+
240+
define fp128 @test_nearbyint(fp128 %a) {
241+
; CHECK-LABEL: test_nearbyint:
242+
; CHECK-F128: nearbyintf128
243+
; CHECK-USELD: nearbyintl
244+
; CHECK-S390X: nearbyintl
245+
start:
246+
%0 = tail call fp128 @llvm.nearbyint.f128(fp128 %a)
247+
ret fp128 %0
248+
}
249+
250+
define fp128 @test_pow(fp128 %a, fp128 %b) {
251+
; CHECK-LABEL: test_pow:
252+
; CHECK-F128: powf128
253+
; CHECK-USELD: powl
254+
; CHECK-S390X: powl
255+
start:
256+
%0 = tail call fp128 @llvm.pow.f128(fp128 %a, fp128 %b)
257+
ret fp128 %0
258+
}
259+
260+
define fp128 @test_rint(fp128 %a) {
261+
; CHECK-LABEL: test_rint:
262+
; CHECK-F128: rintf128
263+
; CHECK-USELD: rintl
264+
; CHECK-S390X: fixbr {{%.*}}, 0, {{%.*}}
265+
start:
266+
%0 = tail call fp128 @llvm.rint.f128(fp128 %a)
267+
ret fp128 %0
268+
}
269+
270+
define fp128 @test_roundeven(fp128 %a) {
271+
; CHECK-LABEL: test_roundeven:
272+
; CHECK-F128: roundevenf128
273+
; CHECK-USELD: roundevenl
274+
; CHECK-S390X: roundevenl
275+
start:
276+
%0 = tail call fp128 @llvm.roundeven.f128(fp128 %a)
277+
ret fp128 %0
278+
}
279+
280+
define fp128 @test_round(fp128 %a) {
281+
; CHECK-LABEL: test_round:
282+
; CHECK-F128: roundf128
283+
; CHECK-USELD: roundl
284+
; CHECK-S390X: roundl
285+
start:
286+
%0 = tail call fp128 @llvm.round.f128(fp128 %a)
287+
ret fp128 %0
288+
}
289+
290+
define fp128 @test_sin(fp128 %a) {
291+
; CHECK-LABEL: test_sin:
292+
; CHECK-F128: sinf128
293+
; CHECK-USELD: sinl
294+
; CHECK-S390X: sinl
295+
start:
296+
%0 = tail call fp128 @llvm.sin.f128(fp128 %a)
297+
ret fp128 %0
298+
}
299+
300+
define fp128 @test_sqrt(fp128 %a) {
301+
; CHECK-LABEL: test_sqrt:
302+
; CHECK-F128: sqrtf128
303+
; CHECK-USELD: sqrtl
304+
; CHECK-S390X: sqxbr {{%.*}}, {{%.*}}
305+
start:
306+
%0 = tail call fp128 @llvm.sqrt.f128(fp128 %a)
307+
ret fp128 %0
308+
}
309+
310+
define fp128 @test_tan(fp128 %a) {
311+
; CHECK-LABEL: test_tan:
312+
; CHECK-F128: tanf128
313+
; CHECK-USELD: tanl
314+
; CHECK-S390X: tanl
315+
start:
316+
%0 = tail call fp128 @llvm.tan.f128(fp128 %a)
317+
ret fp128 %0
318+
}
319+
320+
define fp128 @test_trunc(fp128 %a) {
321+
; CHECK-LABEL: test_trunc:
322+
; CHECK-F128: truncf128
323+
; CHECK-USELD: truncl
324+
; CHECK-S390X: truncl
325+
start:
326+
%0 = tail call fp128 @llvm.trunc.f128(fp128 %a)
327+
ret fp128 %0
328+
}

0 commit comments

Comments
 (0)