This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix 61441
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Sujoy Saraswati <ssaraswati at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 14 Sep 2015 20:37:52 +0000
- Subject: Re: Fix 61441
- Authentication-results: sourceware.org; auth=none
- References: <CA+ZXfhXZWO8eOCYGPv3nomrfK7zzWHkXSJE++jw0heHxbQoqaA at mail dot gmail dot com> <CAFiYyc0rwpQ_v1x4WzbrzaPfiFQetfq_hLur44otKwceqo6CDg at mail dot gmail dot com> <CA+ZXfhV3KKizefovNp+cu2G_yhL7nK7E41gocnRWaX67TuMq-w at mail dot gmail dot com> <CAFiYyc2N0PEiw12PoFkj-nq-WhG26Tezb40ZrBqtCr3Rwbk7Pw at mail dot gmail dot com> <CA+ZXfhVZx61N50nydQfDtMdD77329efLKpYmw+7g0rXvRHKvjQ at mail dot gmail dot com> <CAFiYyc0qur5=4TywfbgYGGHUpsvtV-f0-Dn+9VtrK0EYyjAnQg at mail dot gmail dot com>
On Mon, 14 Sep 2015, Richard Biener wrote:
> I'll leave the correctness part of the patch to Joseph who knows FP
> arithmetic better than me,
> implementation-wise this is ok if you fix the REAL_CST sharing issue.
Changing fold_abs_const is wrong - abs of sNaN is sNaN, no exceptions
raised. Changing real_arithmetic is wrong for the NEGATE_EXPR and
ABS_EXPR cases, both of which should just affect the sign bit without
quieting sNaNs.
All the comments in the patch should end with ". " (full stop, two
spaces).
If -fsignaling-nans, then folding of expressions involving sNaNs should be
disabled, outside of static initializers - such expressions should not get
folded to return an sNaN (it's incorrect to fold sNaN + 1 to sNaN, for
example). I think existing code may ensure that (the HONOR_SNANS check in
const_binop, for example).
Inside static initializers, expressions involving sNaNs still need to be
folded (so sNaN + 1 becomes qNaN inside such an initializer, for example,
with the translation-time exception being discarded). Again, existing
code should handle this: START_FOLD_INIT / END_FOLD_INIT already handle
clearing and restoring flag_signaling_nans.
My understanding of the design of the existing code is that real.c will do
the arithmetic regardless of whether it might raise an exception or have
rounding-mode-dependent results, with fold-const.c being responsible for
deciding whether the result can be used to fold the expression in
question. That is, you shouldn't need any flag_signaling_nans conditions
in real.c; rather, if IEEE semantics mean an sNaN is quieted, real.c
should do so unconditionally. It should be the callers in fold-const.c
that check HONOR_SNANS and disallow folding when it would lose exceptions.
--
Joseph S. Myers
joseph@codesourcery.com