Skip to content

Commit 4ff6205

Browse files
authored
[LoongArch] Add test for scalar FP rounding (#114968)
1 parent 9a1a8f3 commit 4ff6205

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc --mtriple=loongarch64 --mattr=-lsx < %s | FileCheck %s --check-prefix=NOLSX
3+
; RUN: llc --mtriple=loongarch64 --mattr=+lsx < %s | FileCheck %s --check-prefix=LSX
4+
5+
;; ceilf
6+
define float @ceil_f32(float %i) nounwind {
7+
; NOLSX-LABEL: ceil_f32:
8+
; NOLSX: # %bb.0: # %entry
9+
; NOLSX-NEXT: b %plt(ceilf)
10+
;
11+
; LSX-LABEL: ceil_f32:
12+
; LSX: # %bb.0: # %entry
13+
; LSX-NEXT: b %plt(ceilf)
14+
entry:
15+
%0 = call float @llvm.ceil.f32(float %i)
16+
ret float %0
17+
}
18+
19+
;; ceil
20+
define double @ceil_f64(double %i) nounwind {
21+
; NOLSX-LABEL: ceil_f64:
22+
; NOLSX: # %bb.0: # %entry
23+
; NOLSX-NEXT: b %plt(ceil)
24+
;
25+
; LSX-LABEL: ceil_f64:
26+
; LSX: # %bb.0: # %entry
27+
; LSX-NEXT: b %plt(ceil)
28+
entry:
29+
%0 = call double @llvm.ceil.f64(double %i)
30+
ret double %0
31+
}
32+
33+
;; floorf
34+
define float @floor_f32(float %i) nounwind {
35+
; NOLSX-LABEL: floor_f32:
36+
; NOLSX: # %bb.0: # %entry
37+
; NOLSX-NEXT: b %plt(floorf)
38+
;
39+
; LSX-LABEL: floor_f32:
40+
; LSX: # %bb.0: # %entry
41+
; LSX-NEXT: b %plt(floorf)
42+
entry:
43+
%0 = call float @llvm.floor.f32(float %i)
44+
ret float %0
45+
}
46+
47+
;; floor
48+
define double @floor_f64(double %i) nounwind {
49+
; NOLSX-LABEL: floor_f64:
50+
; NOLSX: # %bb.0: # %entry
51+
; NOLSX-NEXT: b %plt(floor)
52+
;
53+
; LSX-LABEL: floor_f64:
54+
; LSX: # %bb.0: # %entry
55+
; LSX-NEXT: b %plt(floor)
56+
entry:
57+
%0 = call double @llvm.floor.f64(double %i)
58+
ret double %0
59+
}
60+
61+
;; truncf
62+
define float @trunc_f32(float %i) nounwind {
63+
; NOLSX-LABEL: trunc_f32:
64+
; NOLSX: # %bb.0: # %entry
65+
; NOLSX-NEXT: b %plt(truncf)
66+
;
67+
; LSX-LABEL: trunc_f32:
68+
; LSX: # %bb.0: # %entry
69+
; LSX-NEXT: b %plt(truncf)
70+
entry:
71+
%0 = call float @llvm.trunc.f32(float %i)
72+
ret float %0
73+
}
74+
75+
;; trunc
76+
define double @trunc_f64(double %i) nounwind {
77+
; NOLSX-LABEL: trunc_f64:
78+
; NOLSX: # %bb.0: # %entry
79+
; NOLSX-NEXT: b %plt(trunc)
80+
;
81+
; LSX-LABEL: trunc_f64:
82+
; LSX: # %bb.0: # %entry
83+
; LSX-NEXT: b %plt(trunc)
84+
entry:
85+
%0 = call double @llvm.trunc.f64(double %i)
86+
ret double %0
87+
}
88+
89+
;; roundevenf
90+
define float @roundeven_f32(float %i) nounwind {
91+
; NOLSX-LABEL: roundeven_f32:
92+
; NOLSX: # %bb.0: # %entry
93+
; NOLSX-NEXT: b %plt(roundevenf)
94+
;
95+
; LSX-LABEL: roundeven_f32:
96+
; LSX: # %bb.0: # %entry
97+
; LSX-NEXT: b %plt(roundevenf)
98+
entry:
99+
%0 = call float @llvm.roundeven.f32(float %i)
100+
ret float %0
101+
}
102+
103+
;; roundeven
104+
define double @roundeven_f64(double %i) nounwind {
105+
; NOLSX-LABEL: roundeven_f64:
106+
; NOLSX: # %bb.0: # %entry
107+
; NOLSX-NEXT: b %plt(roundeven)
108+
;
109+
; LSX-LABEL: roundeven_f64:
110+
; LSX: # %bb.0: # %entry
111+
; LSX-NEXT: b %plt(roundeven)
112+
entry:
113+
%0 = call double @llvm.roundeven.f64(double %i)
114+
ret double %0
115+
}
116+
117+
declare float @llvm.ceil.f32(float)
118+
declare double @llvm.ceil.f64(double)
119+
declare float @llvm.floor.f32(float)
120+
declare double @llvm.floor.f64(double)
121+
declare float @llvm.trunc.f32(float)
122+
declare double @llvm.trunc.f64(double)
123+
declare float @llvm.roundeven.f32(float)
124+
declare double @llvm.roundeven.f64(double)

0 commit comments

Comments
 (0)