On Fri, 6 Nov 2015, Sujoy Saraswati wrote: > > Shouldn't real_convert do this rather than the caller needing to do it? > > Yes, it should be. I had started by doing this within real_convert but > then saw that there are quite a few callers where I should add the > check for flag_signaling_nans. This was making the patch bigger, so > instead decided to change the caller in this particular case. I will > try to make the change in real_convert now that we are planning to > break the patch.
I think the general principle is: * The caller decides whether folding is desirable (whether it would lose exceptions, for example). * The real.c code is called only when the caller has decided that folding is desirable, and should always produce the correct output (which for a conversion means producing a quiet NaN from a signaling NaN). So both places need changes, but real_convert is where the code that makes it a quiet NaN should go. Another place in the patch that looks incorrect: the changes to fold-const-call.c calling real_powi and checking if the result is a signaling NaN. The result of real_powi should never be a signaling NaN. Rather, real_powi should produce a quiet NaN if its input is a signaling NaN, and the callers should check if the argument is a signaling NaN when deciding whether to fold, not if the result is. -- Joseph S. Myers jos...@codesourcery.com