[PATCH] Ensure calculations happen with desired rounding mode in y1lf128

Joseph Myers joseph@codesourcery.com
Mon Aug 15 20:59:53 GMT 2022


On Fri, 12 Aug 2022, Wilco Dijkstra via Libc-alpha wrote:

> All math functions using the SET_RESTORE_ROUND macros will need similar
> barriers. Note that it is feasible to remove these macros altogether and fix
> any issues (a slightly larger ULP is acceptable for non-nearest rounding).
> Given rounding mode changes are generally expensive, this also improves
> performance (though that may not be important for 128-bit floats).

This one is a case where SET_RESTORE_ROUND is used to reduce error 
accumulation to keep the errors within the bounds accepted by the 
testsuite (see bug 16824).  In such cases, it may indeed be possible to 
change the algorithm to one that has less total error accumulation 
possible in any rounding mode so the results are sufficiently accurate 
independent of rounding mode without needing SET_RESTORE_ROUND.

In other cases, the manipulation of the floating-point environment is 
needed for correctness, e.g. to avoid spurious exceptions or to implement 
round-to-odd for functions that must be correctly rounding, or it's 
because algorithms for higher internal precision are used (Dekker / Knuth) 
that are only correct in round-to-nearest most and much larger errors 
might occur if those are used in the wrong rounding mode.

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Libc-alpha mailing list