Re: [PATCH] Simplify floating point comparisons

2018-11-12 Thread Richard Biener
On Fri, Nov 9, 2018 at 6:05 PM Wilco Dijkstra wrote: > > Richard Biener wrote: > >Marc Glisse wrote: > >> Let's try with C = DBL_MIN and x = 婊BL_MAX. I don't believe it involves > >> signed zeros or infinities, just an underflow. First, the result depends on > >> the rounding mode. And in the defa

Re: [PATCH] Simplify floating point comparisons

2018-11-09 Thread Wilco Dijkstra
Richard Biener wrote: >Marc Glisse wrote: >> Let's try with C = DBL_MIN and x = 婊BL_MAX. I don't believe it involves >> signed zeros or infinities, just an underflow. First, the result depends on >> the rounding mode. And in the default round-to-nearest, both divisions give >> 0, and thus compare t

Re: [PATCH] Simplify floating point comparisons

2018-05-02 Thread Richard Biener
On Mon, Apr 30, 2018 at 8:49 PM, Marc Glisse wrote: > On Fri, 12 Jan 2018, Wilco Dijkstra wrote: > >> Hi, >> >> Here is the updated version: >> >> This patch implements some of the optimizations discussed in >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026. >> >> Simplify (C / x >= 0.0) into

Re: [PATCH] Simplify floating point comparisons

2018-04-30 Thread Marc Glisse
On Fri, 12 Jan 2018, Wilco Dijkstra wrote: Hi, Here is the updated version: This patch implements some of the optimizations discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026. Simplify (C / x >= 0.0) into x >= 0.0 with -fno-signed-zeros and -ffinite-math-only. If C is negative t

Re: [PATCH] Simplify floating point comparisons

2018-04-30 Thread Jeff Law
On 01/12/2018 06:21 AM, Wilco Dijkstra wrote: > Hi, > > Here is the updated version: > > This patch implements some of the optimizations discussed in > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026. > > Simplify (C / x >= 0.0) into x >= 0.0 with -fno-signed-zeros > and -ffinite-math-only.

Re: [PATCH] Simplify floating point comparisons

2018-01-12 Thread Wilco Dijkstra
Hi, Here is the updated version: This patch implements some of the optimizations discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026. Simplify (C / x >= 0.0) into x >= 0.0 with -fno-signed-zeros and -ffinite-math-only. If C is negative the comparison is reversed. Only handle >= and

Re: [PATCH] Simplify floating point comparisons

2018-01-09 Thread Wilco Dijkstra
Richard Biener wrote: >On Thu, Jan 4, 2018 at 10:27 PM, Marc Glisse wrote: >> I don't understand how the check you added helps. It simply blocks the transformation for infinity: + (if (!REAL_VALUE_ISINF (TREE_REAL_CST (@0))) + (switch + (if (real_less (&dconst0, TREE_REAL_CST_P

Re: [PATCH] Simplify floating point comparisons

2018-01-05 Thread Richard Biener
On Thu, Jan 4, 2018 at 10:27 PM, Marc Glisse wrote: > (just a log of my thoughts while reading the patch) > > On Thu, 4 Jan 2018, Wilco Dijkstra wrote: > >> Richard Biener wrote: >>> >>> On Tue, Oct 17, 2017 at 6:28 PM, Wilco Dijkstra >>> wrote: >> >> +(if (flag_unsafe_math_optimizations) >>

Re: [PATCH] Simplify floating point comparisons

2018-01-04 Thread Marc Glisse
(just a log of my thoughts while reading the patch) On Thu, 4 Jan 2018, Wilco Dijkstra wrote: Richard Biener wrote: On Tue, Oct 17, 2017 at 6:28 PM, Wilco Dijkstra wrote: +(if (flag_unsafe_math_optimizations) +  /* Simplify (C / x op 0.0) to x op 0.0 for C > 0.  */ +  (for op (lt le gt ge)

Re: [PATCH] Simplify floating point comparisons

2018-01-04 Thread Wilco Dijkstra
ping (note also Jeff's reply https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01916.html) From: Wilco Dijkstra Sent: 15 November 2017 15:36 To: Richard Biener Cc: GCC Patches; nd Subject: Re: [PATCH] Simplify floating point comparisons   Richard Biener wrote: > On Tue, Oct 17, 2017 at

Re: [PATCH] Simplify floating point comparisons

2017-11-21 Thread Jeff Law
On 11/15/2017 08:36 AM, Wilco Dijkstra wrote: > Richard Biener wrote: >> On Tue, Oct 17, 2017 at 6:28 PM, Wilco Dijkstra >> wrote: > >>> +(if (flag_unsafe_math_optimizations) >>> +  /* Simplify (C / x op 0.0) to x op 0.0 for C > 0.  */ >>> +  (for op (lt le gt ge) >>> +   neg_op (gt ge lt le

Re: [PATCH] Simplify floating point comparisons

2017-11-15 Thread Wilco Dijkstra
Richard Biener wrote: > On Tue, Oct 17, 2017 at 6:28 PM, Wilco Dijkstra > wrote: >> +(if (flag_unsafe_math_optimizations) >> +  /* Simplify (C / x op 0.0) to x op 0.0 for C > 0.  */ >> +  (for op (lt le gt ge) >> +   neg_op (gt ge lt le) >> +    (simplify >> +  (op (rdiv REAL_CST@0 @1) r

Re: [PATCH] Simplify floating point comparisons

2017-10-18 Thread Joseph Myers
On Wed, 18 Oct 2017, Richard Biener wrote: > When overflow/underflow can be disregarded is there any reason remaining to > make this guarded by flag_unsafe_math_optimizations? Are there any cases > where rounding issues can flip the comparison result? Yes. E.g. (in round-to-nearest) 3.0f * 0xff

Re: [PATCH] Simplify floating point comparisons

2017-10-18 Thread Richard Biener
On Tue, Oct 17, 2017 at 6:28 PM, Wilco Dijkstra wrote: > This patch implements some of the optimizations discussed in > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026. > > Simplify (C / x > 0.0) into x > 0.0. > > If C is negative the comparison is reversed. > > Simplify (x * C1) > C2 into x >

Re: [PATCH] Simplify floating point comparisons

2017-10-18 Thread Prathamesh Kulkarni
On 17 October 2017 at 21:58, Wilco Dijkstra wrote: > This patch implements some of the optimizations discussed in > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026. > > Simplify (C / x > 0.0) into x > 0.0. > > If C is negative the comparison is reversed. > > Simplify (x * C1) > C2 into x > (C2

[PATCH] Simplify floating point comparisons

2017-10-17 Thread Wilco Dijkstra
This patch implements some of the optimizations discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026. Simplify (C / x > 0.0) into x > 0.0. If C is negative the comparison is reversed. Simplify (x * C1) > C2 into x > (C2 / C1). Again, if C1 is negative the comparison is reversed. Bot