RE: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-27 Thread Joseph Myers
On Thu, 26 Nov 2020, Roger Sayle wrote: > NaNs have a sign-bit, so copyexpr (and negate and ABS_EXPR) are > well-defined, and it's reasonable for nonnegative_p to reflect this. > IMHO, the true bug is that we can't fold away (any) comparisons against > NaN when flag_trapping_math, irrespective

Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-27 Thread Joseph Myers
On Thu, 26 Nov 2020, Richard Biener wrote: > Is copysign (x, NaN) supposed to be well-defined? We'd stop folding copysign with NaN arguments (including sNaN) is well-defined and copies the sign bit without raising any exceptions. > this then, no? I think the ABS_EXPR < 0 to false folding is >

RE: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-27 Thread Roger Sayle
Doh! Wrong patch2.txt file. Sorry. -Original Message- From: Roger Sayle Sent: 27 November 2020 10:52 To: 'Jakub Jelinek' ; 'Joseph S. Myers' Cc: 'Richard Biener' ; 'gcc-patches@gcc.gnu.org' Subject: RE: [PATCH] fold-const: Don't c

RE: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-27 Thread Roger Sayle
Hi Jakub, Technically, PR97965 doesn't explicitly mention equality/inequality, but you're right, it makes sense to tackle this missed optimization at the same time as we fix the wrong-code. On Thu, Nov 26, 2020, Jakub Jelinek wrote: >On Thu, Nov 26, 2020 at 01:56:03PM -, Roger Sayle wrote: >>

Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-26 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 26, 2020 at 01:56:03PM -, Roger Sayle wrote: > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -3998,7 +3998,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (cmp @0 { build_real (TREE_TYPE (@1), dconst0); })) > /* x != NaN is always true, other ops are always false. */ > (if

Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-26 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 26, 2020 at 03:13:22PM +0100, Jakub Jelinek via Gcc-patches wrote: > On Thu, Nov 26, 2020 at 01:56:03PM -, Roger Sayle wrote: > > My completely untested solution is the attached patch. My apologies, I'm > > not > > even set up to compile things on the laptop that I'm composing this

Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-26 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 26, 2020 at 01:56:03PM -, Roger Sayle wrote: > My completely untested solution is the attached patch. My apologies, I'm > not > even set up to compile things on the laptop that I'm composing this e-mail > on, > but my notes/proposals on tackling PR97965 are easier expressed as the

RE: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-26 Thread Roger Sayle
From: Richard Biener Sent: 26 November 2020 10:04 To: Jakub Jelinek Cc: Joseph S. Myers ; Jason Merrill ; gcc-patches@gcc.gnu.org; ro...@nextmovesoftware.com Subject: Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965] On Thu, 26 Nov 2020, Jakub Jelinek wrote: > On Thu, N

Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-26 Thread Richard Biener
On Thu, 26 Nov 2020, Jakub Jelinek wrote: > On Thu, Nov 26, 2020 at 09:16:29AM +, Richard Biener wrote: > > > So, I really don't know if we want this or not, posting it for > > > discussions. > > > > Is copysign (x, NaN) supposed to be well-defined? We'd stop folding > > this then, no? > >

Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-26 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 26, 2020 at 09:16:29AM +, Richard Biener wrote: > > So, I really don't know if we want this or not, posting it for discussions. > > Is copysign (x, NaN) supposed to be well-defined? We'd stop folding > this then, no? Yes, we'd stop folding several cases with NaNs. > I think the

Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]

2020-11-26 Thread Richard Biener
On Thu, 26 Nov 2020, Jakub Jelinek wrote: > Hi! > > The testcase in the PR > constexpr bool a = __builtin_nan ("") > 0.0; > constexpr bool b = __builtin_nans ("") > 0.0; > constexpr bool c = __builtin_nan ("") < 0.0; > constexpr bool d = __builtin_nans ("") < 0.0; > constexpr bool e = __builtin_n