this repo has no description
1// float rintf(float x)
2//
3// returns the argument rounded to an integral value using the prevailing
4// rounding mode. rintf is allowed to raise the "inexact" flag if the result
5// differs from the argument (C99 7.12.9.4).
6//
7// -- Stephen Canon, January 2010
8
9.text
10.align 4
11.globl _rintf
12_rintf:
13#if defined __i386__
14 movl 4(%esp), %ecx
15 movss 4(%esp), %xmm0
16#else
17 movd %xmm0, %ecx
18#endif
19 mov %ecx, %edx
20 and $0x7fffffff, %ecx // |x|
21 xor %ecx, %edx // signbit(x)
22 movd %edx, %xmm1
23 cmp $0x4b000000, %ecx // if |x| >= 2^23 or isnan(x)
24 jae L_xIsIntegral // then the result is just x
25
26 cvtps2dq %xmm0, %xmm0
27 cvtdq2ps %xmm0, %xmm0
28 orps %xmm1, %xmm0 // restore signbit
29
30#if defined __i386__
31 movss %xmm0, 4(%esp)
32L_xIsIntegral:
33 flds 4(%esp)
34 ret
35#else
36L_xIsIntegral:
37 ret
38#endif