This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Don't fold nextafter/nexttoward if -ftrapping-math or -fmath-errno if they produce denormal results (PR c/86420)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Richard Biener <rguenther at suse dot de>
- Date: Sat, 7 Jul 2018 12:12:58 +0200
- Subject: Re: [PATCH] Don't fold nextafter/nexttoward if -ftrapping-math or -fmath-errno if they produce denormal results (PR c/86420)
- References: <20180707080605.GP7166@tucnak> <alpine.DEB.email@example.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sat, Jul 07, 2018 at 11:55:17AM +0200, Marc Glisse wrote:
> On Sat, 7 Jul 2018, Jakub Jelinek wrote:
> > 2018-07-07 Jakub Jelinek <firstname.lastname@example.org>
> > PR c/86420
> > * real.c (real_nextafter): Return true if result is denormal.
> I have a question on the side: would it be hard / useful, in cases where
> nextafter may set errno or some exception flag, to fold the result to a
> constant while keeping the function call (ignoring the value it returns)? To
> clarify, I mean replace
> _2 = nextafter(DBL_DENORM_MIN, 0);
> nextafter(DBL_DENORM_MIN, 0);
> _2 = 0;
> I think we already do that for some other calls, although I can't remember
> where. The point would be that we have the value of _2 and can keep folding
> its uses.
For errno purposes alone that would be possible, but the function is marked
#define ATTR_MATHFN_ERRNO (flag_errno_math ? \
ATTR_NOTHROW_LEAF_LIST : ATTR_CONST_NOTHROW_LEAF_LIST)
and thus with -ftrapping-math -fno-math-errno I'm afraid we'd immediately
DCE the call in the second form (without lhs).