[PATCH]: Fix PR middle-end/30789, complex math folding via MPC
Joseph S. Myers
joseph@codesourcery.com
Fri Aug 14 17:13:00 GMT 2009
On Fri, 14 Aug 2009, Kaveh R. Ghazi wrote:
> How is folding handled for floating point exceptions and signaling NaNs? Do
> we just fold and ignore these side-effects?
>
> The folding code for REAL_CST in const_binop() doesn't fold if it may
> encounter these, or e.g. divide-by-zero, overflow, or just if the result is
> inexact when the rounding mode has changed. The REAL_CST code is used by the
> COMPLEX_CST code for the underlying math (before the introduction MPC). So how
> and where does the static initializer folding occur currently when these
> conditions happen?
START_FOLD_INIT and END_FOLD_INIT adjust the relevant flags
(flag_signaling_nans, flag_trapping_math, flag_rounding_math etc.) so that
the folding happens even though it wouldn't outside a static initializer.
This is in accordance with C99 Annex F: the translation-time environment
is described in F.7.2 and F.7.5 says initialization of static storage
duration objects is done at translation time. When the flags are in the
state they are for static initializer folding, you can do folding that
discards exceptions and rounding mode issues - and need to do so in the
case of a static initializer.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Gcc-patches
mailing list