[PATCH 0/3] ARM with only 32-bit floats do not have fast 64-bit FMA

Keith Packard keithp@keithp.com
Mon Sep 7 17:16:24 GMT 2020


Eric Bresie via Newlib <newlib@sourceware.org> writes:

> Not directly related (and as I’m not really an expert on these things, nor able to change in any way) but was looking at the code mentioned and saw line like:
>
> if (x == 0.0 || y == 0.0)
>
> return (x * y + z);
>
> If either x or y is zero would it be better to just return z and avoid
> an extra multiplication operation here?

You want to compute the correct result and get the right exceptions in
all of the delightful IEEE754 corner cases (e.g. 0 × ∞). It's easier to
just execute the two operations than to try and synthesize the right
result (which is implementation-dependent in the case of 0 × ∞ +
qNaN). The key here is that if x or y is zero, then you won't lose any
intermediate precision by performing the operation this way.

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20200907/2bb48739/attachment.sig>


More information about the Newlib mailing list