Re: Re: [PATCH 0/3] ARM with only 32-bit floats do not have fast 64-bit FMA
Keith Packard via Newlib <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Eric Bresie via Newlib <[email protected]> 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
signature.asc
(application/pgp-signature, 832 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAl9WaugACgkQ2yIaaQAA ABF+0A/8DtvyoGyCu/6iUaGUd5AuWF4qr62Fh9/s9LXacLuHaH2M2oK8UGNJNNYs 0j83/jTUkio8JdMjhtmU28jNwaY+/yo/M38it6LK9jQ6KyEy/t5hkUBs8Ty4o1Ln hL0/Oq7M4VI37w5gaIzU9jirzEv0AQwOChfOCvNWfrugXEPWP3URI5niwKXis8nI Vs/bovhx1gxAKo2DfPQ05+GJ7mMuuUaU/NnrSZj2M+OmeOyGgWGFkWjeRWOQciim 6NGIsY+CBdq/0jGiXidKZxgbXz8DswINTAcsCKzZSaHoBRl9ok1a9HNGgPmbnV13 XpqCb5ImHN7mKeVJl6wMGt6GMHd1cVmGQAEnpaNKo60mSdHdyQZky8sGjPBaz2k7 maQ56ONVF/1yiZZQa2JGTbvHcPiLiVW7tmp0pQT9pqVbI9Y7sI9GnevPoUkQxSgq JmcJLUHloirstYSBj5tnre+63WI9c9cv8wohBXf0Vemf+7DKYxl5pA2KEf0h48PI hVz4evz7ZztCXcKFZflDQ1AFT+MTvzCcRdLpNQ7HCwG2kWcbzCjGKK9Z/D7UoxhD WLJx9E7HGLMzoz09B4zcIpr/ajFPEmaZ8zGTeohVACx/RG3OWFctxSIzAxx3FCwT djT8+94ik70h/9z09SUReW1mjowh2lWQbMqlmSVdGlBUIEe+TkY= =w10w -----END PGP SIGNATURE-----