Hi.
We have Newlib ported to our architecture. One of configurations that we support
is hardware single precision and soft-float double precision.
I have noticed unexpected double precision soft-float function calls in simple
code like x = sinf(y), where both x and y are single precision.
I have noticed that Newlib sinef function (libm/mathfp/sf_sine.c) contains lines
like:
/* Calculate the exponent. */
if (y < 0.0)
N = (int) (y * ONE_OVER_PI - 0.5);
else
N = (int) (y * ONE_OVER_PI + 0.5);
While y * ONE_OVER_PI gets calculated in single precision, that +- 0.5 causes
the result of multiplication being converted to double and then addition is done
in double using soft-float. For our case this has big performance penalty and
also requires double soft-float functions to be linked in, causing binary to grow.
Is 0.5 (instead of 0.5f) used by purpose or is that just wrong (and needs
fixing)? Where did those math. functions originate from?
Best regards,
Branko Drevensek