xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/arm64-rounding.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -O3 < %s -mtriple=arm64 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test1:
4*9880d681SAndroid Build Coastguard Worker; CHECK: frintm
5*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
6*9880d681SAndroid Build Coastguard Workerdefine float @test1(float %a) #0 {
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker  %call = tail call float @floorf(float %a) nounwind readnone
9*9880d681SAndroid Build Coastguard Worker  ret float %call
10*9880d681SAndroid Build Coastguard Worker}
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdeclare float @floorf(float) nounwind readnone
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test2:
15*9880d681SAndroid Build Coastguard Worker; CHECK: frintm
16*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
17*9880d681SAndroid Build Coastguard Workerdefine double @test2(double %a) #0 {
18*9880d681SAndroid Build Coastguard Workerentry:
19*9880d681SAndroid Build Coastguard Worker  %call = tail call double @floor(double %a) nounwind readnone
20*9880d681SAndroid Build Coastguard Worker  ret double %call
21*9880d681SAndroid Build Coastguard Worker}
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Workerdeclare double @floor(double) nounwind readnone
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test3:
26*9880d681SAndroid Build Coastguard Worker; CHECK: frinti
27*9880d681SAndroid Build Coastguard Workerdefine float @test3(float %a) #0 {
28*9880d681SAndroid Build Coastguard Workerentry:
29*9880d681SAndroid Build Coastguard Worker  %call = tail call float @nearbyintf(float %a) nounwind readnone
30*9880d681SAndroid Build Coastguard Worker  ret float %call
31*9880d681SAndroid Build Coastguard Worker}
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Workerdeclare float @nearbyintf(float) nounwind readnone
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test4:
36*9880d681SAndroid Build Coastguard Worker; CHECK: frinti
37*9880d681SAndroid Build Coastguard Workerdefine double @test4(double %a) #0 {
38*9880d681SAndroid Build Coastguard Workerentry:
39*9880d681SAndroid Build Coastguard Worker  %call = tail call double @nearbyint(double %a) nounwind readnone
40*9880d681SAndroid Build Coastguard Worker  ret double %call
41*9880d681SAndroid Build Coastguard Worker}
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Workerdeclare double @nearbyint(double) nounwind readnone
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test5:
46*9880d681SAndroid Build Coastguard Worker; CHECK: frintp
47*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
48*9880d681SAndroid Build Coastguard Workerdefine float @test5(float %a) #0 {
49*9880d681SAndroid Build Coastguard Workerentry:
50*9880d681SAndroid Build Coastguard Worker  %call = tail call float @ceilf(float %a) nounwind readnone
51*9880d681SAndroid Build Coastguard Worker  ret float %call
52*9880d681SAndroid Build Coastguard Worker}
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Workerdeclare float @ceilf(float) nounwind readnone
55*9880d681SAndroid Build Coastguard Worker
56*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test6:
57*9880d681SAndroid Build Coastguard Worker; CHECK: frintp
58*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
59*9880d681SAndroid Build Coastguard Workerdefine double @test6(double %a) #0 {
60*9880d681SAndroid Build Coastguard Workerentry:
61*9880d681SAndroid Build Coastguard Worker  %call = tail call double @ceil(double %a) nounwind readnone
62*9880d681SAndroid Build Coastguard Worker  ret double %call
63*9880d681SAndroid Build Coastguard Worker}
64*9880d681SAndroid Build Coastguard Worker
65*9880d681SAndroid Build Coastguard Workerdeclare double @ceil(double) nounwind readnone
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test7:
68*9880d681SAndroid Build Coastguard Worker; CHECK: frintx
69*9880d681SAndroid Build Coastguard Workerdefine float @test7(float %a) #0 {
70*9880d681SAndroid Build Coastguard Workerentry:
71*9880d681SAndroid Build Coastguard Worker  %call = tail call float @rintf(float %a) nounwind readnone
72*9880d681SAndroid Build Coastguard Worker  ret float %call
73*9880d681SAndroid Build Coastguard Worker}
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Workerdeclare float @rintf(float) nounwind readnone
76*9880d681SAndroid Build Coastguard Worker
77*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test8:
78*9880d681SAndroid Build Coastguard Worker; CHECK: frintx
79*9880d681SAndroid Build Coastguard Workerdefine double @test8(double %a) #0 {
80*9880d681SAndroid Build Coastguard Workerentry:
81*9880d681SAndroid Build Coastguard Worker  %call = tail call double @rint(double %a) nounwind readnone
82*9880d681SAndroid Build Coastguard Worker  ret double %call
83*9880d681SAndroid Build Coastguard Worker}
84*9880d681SAndroid Build Coastguard Worker
85*9880d681SAndroid Build Coastguard Workerdeclare double @rint(double) nounwind readnone
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test9:
88*9880d681SAndroid Build Coastguard Worker; CHECK: frintz
89*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
90*9880d681SAndroid Build Coastguard Workerdefine float @test9(float %a) #0 {
91*9880d681SAndroid Build Coastguard Workerentry:
92*9880d681SAndroid Build Coastguard Worker  %call = tail call float @truncf(float %a) nounwind readnone
93*9880d681SAndroid Build Coastguard Worker  ret float %call
94*9880d681SAndroid Build Coastguard Worker}
95*9880d681SAndroid Build Coastguard Worker
96*9880d681SAndroid Build Coastguard Workerdeclare float @truncf(float) nounwind readnone
97*9880d681SAndroid Build Coastguard Worker
98*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test10:
99*9880d681SAndroid Build Coastguard Worker; CHECK: frintz
100*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
101*9880d681SAndroid Build Coastguard Workerdefine double @test10(double %a) #0 {
102*9880d681SAndroid Build Coastguard Workerentry:
103*9880d681SAndroid Build Coastguard Worker  %call = tail call double @trunc(double %a) nounwind readnone
104*9880d681SAndroid Build Coastguard Worker  ret double %call
105*9880d681SAndroid Build Coastguard Worker}
106*9880d681SAndroid Build Coastguard Worker
107*9880d681SAndroid Build Coastguard Workerdeclare double @trunc(double) nounwind readnone
108*9880d681SAndroid Build Coastguard Worker
109*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test11:
110*9880d681SAndroid Build Coastguard Worker; CHECK: frinta
111*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
112*9880d681SAndroid Build Coastguard Workerdefine float @test11(float %a) #0 {
113*9880d681SAndroid Build Coastguard Workerentry:
114*9880d681SAndroid Build Coastguard Worker  %call = tail call float @roundf(float %a) nounwind readnone
115*9880d681SAndroid Build Coastguard Worker  ret float %call
116*9880d681SAndroid Build Coastguard Worker}
117*9880d681SAndroid Build Coastguard Worker
118*9880d681SAndroid Build Coastguard Workerdeclare float @roundf(float %a) nounwind readnone
119*9880d681SAndroid Build Coastguard Worker
120*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test12:
121*9880d681SAndroid Build Coastguard Worker; CHECK: frinta
122*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
123*9880d681SAndroid Build Coastguard Workerdefine double @test12(double %a) #0 {
124*9880d681SAndroid Build Coastguard Workerentry:
125*9880d681SAndroid Build Coastguard Worker  %call = tail call double @round(double %a) nounwind readnone
126*9880d681SAndroid Build Coastguard Worker  ret double %call
127*9880d681SAndroid Build Coastguard Worker}
128*9880d681SAndroid Build Coastguard Worker
129*9880d681SAndroid Build Coastguard Workerdeclare double @round(double %a) nounwind readnone
130*9880d681SAndroid Build Coastguard Worker
131*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test13:
132*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
133*9880d681SAndroid Build Coastguard Worker; CHECK: frintm
134*9880d681SAndroid Build Coastguard Workerdefine float @test13(float %a) #1 {
135*9880d681SAndroid Build Coastguard Workerentry:
136*9880d681SAndroid Build Coastguard Worker  %call = tail call float @floorf(float %a) nounwind readnone
137*9880d681SAndroid Build Coastguard Worker  ret float %call
138*9880d681SAndroid Build Coastguard Worker}
139*9880d681SAndroid Build Coastguard Worker
140*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test14:
141*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
142*9880d681SAndroid Build Coastguard Worker; CHECK: frintm
143*9880d681SAndroid Build Coastguard Workerdefine double @test14(double %a) #1 {
144*9880d681SAndroid Build Coastguard Workerentry:
145*9880d681SAndroid Build Coastguard Worker  %call = tail call double @floor(double %a) nounwind readnone
146*9880d681SAndroid Build Coastguard Worker  ret double %call
147*9880d681SAndroid Build Coastguard Worker}
148*9880d681SAndroid Build Coastguard Worker
149*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test15:
150*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
151*9880d681SAndroid Build Coastguard Worker; CHECK: frintp
152*9880d681SAndroid Build Coastguard Workerdefine float @test15(float %a) #1 {
153*9880d681SAndroid Build Coastguard Workerentry:
154*9880d681SAndroid Build Coastguard Worker  %call = tail call float @ceilf(float %a) nounwind readnone
155*9880d681SAndroid Build Coastguard Worker  ret float %call
156*9880d681SAndroid Build Coastguard Worker}
157*9880d681SAndroid Build Coastguard Worker
158*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test16:
159*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
160*9880d681SAndroid Build Coastguard Worker; CHECK: frintp
161*9880d681SAndroid Build Coastguard Workerdefine double @test16(double %a) #1 {
162*9880d681SAndroid Build Coastguard Workerentry:
163*9880d681SAndroid Build Coastguard Worker  %call = tail call double @ceil(double %a) nounwind readnone
164*9880d681SAndroid Build Coastguard Worker  ret double %call
165*9880d681SAndroid Build Coastguard Worker}
166*9880d681SAndroid Build Coastguard Worker
167*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test17:
168*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
169*9880d681SAndroid Build Coastguard Worker; CHECK: frintz
170*9880d681SAndroid Build Coastguard Workerdefine float @test17(float %a) #1 {
171*9880d681SAndroid Build Coastguard Workerentry:
172*9880d681SAndroid Build Coastguard Worker  %call = tail call float @truncf(float %a) nounwind readnone
173*9880d681SAndroid Build Coastguard Worker  ret float %call
174*9880d681SAndroid Build Coastguard Worker}
175*9880d681SAndroid Build Coastguard Worker
176*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test18:
177*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
178*9880d681SAndroid Build Coastguard Worker; CHECK: frintz
179*9880d681SAndroid Build Coastguard Workerdefine double @test18(double %a) #1 {
180*9880d681SAndroid Build Coastguard Workerentry:
181*9880d681SAndroid Build Coastguard Worker  %call = tail call double @trunc(double %a) nounwind readnone
182*9880d681SAndroid Build Coastguard Worker  ret double %call
183*9880d681SAndroid Build Coastguard Worker}
184*9880d681SAndroid Build Coastguard Worker
185*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test19:
186*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
187*9880d681SAndroid Build Coastguard Worker; CHECK: frinta
188*9880d681SAndroid Build Coastguard Workerdefine float @test19(float %a) #1 {
189*9880d681SAndroid Build Coastguard Workerentry:
190*9880d681SAndroid Build Coastguard Worker  %call = tail call float @roundf(float %a) nounwind readnone
191*9880d681SAndroid Build Coastguard Worker  ret float %call
192*9880d681SAndroid Build Coastguard Worker}
193*9880d681SAndroid Build Coastguard Worker
194*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test20:
195*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: frintx
196*9880d681SAndroid Build Coastguard Worker; CHECK: frinta
197*9880d681SAndroid Build Coastguard Workerdefine double @test20(double %a) #1 {
198*9880d681SAndroid Build Coastguard Workerentry:
199*9880d681SAndroid Build Coastguard Worker  %call = tail call double @round(double %a) nounwind readnone
200*9880d681SAndroid Build Coastguard Worker  ret double %call
201*9880d681SAndroid Build Coastguard Worker}
202*9880d681SAndroid Build Coastguard Worker
203*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind }
204*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind "unsafe-fp-math"="true" }
205