public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/68097] New: We should track ranges for floating-point values too
@ 2015-10-26  8:48 rsandifo at gcc dot gnu.org
  2015-10-26  8:50 ` [Bug tree-optimization/68097] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2015-10-26  8:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

            Bug ID: 68097
           Summary: We should track ranges for floating-point values too
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsandifo at gcc dot gnu.org
  Target Milestone: ---

We have functions to query things like whether a real is nonnegative and
whether it is integer-valued.  At the moment we recurse through SSA name
definitions, limited by --param max-ssa-name-query-depth, but it would be
better to record this information alongside the SSA name, as range_info_def
does for integers.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
@ 2015-10-26  8:50 ` pinskia at gcc dot gnu.org
  2015-10-26 10:36 ` glisse at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-10-26  8:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think I might have filed about this before.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
  2015-10-26  8:50 ` [Bug tree-optimization/68097] " pinskia at gcc dot gnu.org
@ 2015-10-26 10:36 ` glisse at gcc dot gnu.org
  2015-10-26 11:37 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: glisse at gcc dot gnu.org @ 2015-10-26 10:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> ---
If we are generalizing VRP, how about vectors? A single interval per vector
would be enough for most of the benefit.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
  2015-10-26  8:50 ` [Bug tree-optimization/68097] " pinskia at gcc dot gnu.org
  2015-10-26 10:36 ` glisse at gcc dot gnu.org
@ 2015-10-26 11:37 ` rguenth at gcc dot gnu.org
  2015-10-27 11:53 ` rsandifo at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-26 11:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-10-26
                 CC|                            |rguenth at gcc dot gnu.org
            Version|unknown                     |6.0
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.

Note the main part will be to make the FP "range info" available on SSA names.

Other useful queries would include "cannot be Inf/NaN/signed zero".

Note that transforms based on this (and also nonnegative!) need to be careful
as there are no data dependences on conditions.  Thus with

  if (x > 0.)
   foo (x);

we may not optimize foo based on 'nonnegative' as code motion has no barrier
that prevents it from hoisting it before the if.

Yes, vectors could also be handled (and yes, please one "value range" per
SSA name only).  Likewise complex (integer) types.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-10-26 11:37 ` rguenth at gcc dot gnu.org
@ 2015-10-27 11:53 ` rsandifo at gcc dot gnu.org
  2022-09-17 12:10 ` aldyh at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2015-10-27 11:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

--- Comment #4 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Author: rsandifo
Date: Tue Oct 27 11:52:54 2015
New Revision: 229423

URL: https://gcc.gnu.org/viewcvs?rev=229423&root=gcc&view=rev
Log:
Move signbit folds to match.pd

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.

gcc/
        * builtins.c (fold_builtin_signbit): Delete.
        (fold_builtin_2): Handle constant signbit arguments here.
        * match.pd: Add rules previously handled by fold_builtin_signbit.

gcc/testsuite/
        PR tree-optimization/68097
        * gcc.dg/torture/builtin-nonneg-1.c: Skip at -O0.  Add
        --param max-ssa-name-query-depth=3 to dg-options.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/match.pd
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/torture/builtin-nonneg-1.c


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-10-27 11:53 ` rsandifo at gcc dot gnu.org
@ 2022-09-17 12:10 ` aldyh at gcc dot gnu.org
  2022-09-19  7:03 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-09-17 12:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldyh at gcc dot gnu.org

--- Comment #6 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> Confirmed.
> 
> Note the main part will be to make the FP "range info" available on SSA
> names.
> 
> Other useful queries would include "cannot be Inf/NaN/signed zero".
> 
> Note that transforms based on this (and also nonnegative!) need to be careful
> as there are no data dependences on conditions.  Thus with
> 
>   if (x > 0.)
>    foo (x);
> 
> we may not optimize foo based on 'nonnegative' as code motion has no barrier
> that prevents it from hoisting it before the if.
> 
> Yes, vectors could also be handled (and yes, please one "value range" per
> SSA name only).  Likewise complex (integer) types.

Is this PR already solved?  FP range info is available on SSA names currently. 
We can also query inf/NAN/signed zeros/etc.

And regarding PR24021 which pinskia mentioned, there is support for VRP-FP now.
 We just don't understand the PLUS_EXPR.  I have a patch for that as well, and
should contribute it early next week.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-09-17 12:10 ` aldyh at gcc dot gnu.org
@ 2022-09-19  7:03 ` rguenth at gcc dot gnu.org
  2022-09-19  7:31 ` aldyh at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-19  7:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |compile-time-hog

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yes, I think fixed in that we can now record info on FP SSA names.  There are
other bugs for specific things.

What's not fixed is that we still recurse to SSA defs in
gimple_assign_nonnegative_warnv_p and friends.  We might think to fix that now,
so I'm leaving this bug open for this particular issue, it's a good thing to
try for GCC 13.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-09-19  7:03 ` rguenth at gcc dot gnu.org
@ 2022-09-19  7:31 ` aldyh at gcc dot gnu.org
  2022-09-20 17:36 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-09-19  7:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

--- Comment #8 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #7)
> Yes, I think fixed in that we can now record info on FP SSA names.  There
> are other bugs for specific things.
> 
> What's not fixed is that we still recurse to SSA defs in
> gimple_assign_nonnegative_warnv_p and friends.  We might think to fix that
> now,

I see.  If I understand things correctly, you may want to do something like:

  if (frange::supports_p (TREE_TYPE (name)))
    {
      frange r;
      bool sign;
      if (get_global_range_query ()->range_of_expr (r, name)
          && r.signbit_p (sign))
        return sign == false;
    }

That is, get the global range of the SSA name, and if it has a known signbit,
you should be able to determine if it's nonnegative.  The above works correctly
for signed zeros now too.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-09-19  7:31 ` aldyh at gcc dot gnu.org
@ 2022-09-20 17:36 ` cvs-commit at gcc dot gnu.org
  2022-11-08 15:57 ` aldyh at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-20 17:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Aldy Hernandez <aldyh@gcc.gnu.org>:

https://gcc.gnu.org/g:10d6109fe183d984a0377a7afe2854a0d794ebeb

commit r13-2741-g10d6109fe183d984a0377a7afe2854a0d794ebeb
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Mon Sep 19 09:59:01 2022 +0200

    frange::set_nonnegative should not contain -NAN.

    A specifically nonnegative range should not contain -NAN, otherwise
    signbit_p() would return false, because we'd be unsure of the sign.

            PR 68097/tree-optimization

    gcc/ChangeLog:

            * value-range.cc (frange::set_nonnegative): Set +NAN.
            (range_tests_signed_zeros): New test.
            * value-range.h (frange::update_nan): New overload to set NAN sign.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-09-20 17:36 ` cvs-commit at gcc dot gnu.org
@ 2022-11-08 15:57 ` aldyh at gcc dot gnu.org
  2022-11-17  8:54 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-11-08 15:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097
Bug 68097 depends on bug 24021, which changed state.

Bug 24021 Summary: VRP does not work with floating points
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24021

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-11-08 15:57 ` aldyh at gcc dot gnu.org
@ 2022-11-17  8:54 ` cvs-commit at gcc dot gnu.org
  2022-11-17  8:54 ` aldyh at gcc dot gnu.org
  2022-11-28 22:24 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-17  8:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Aldy Hernandez <aldyh@gcc.gnu.org>:

https://gcc.gnu.org/g:822a0823c012b912f0108a4da257cd97cbcdb7a3

commit r13-4125-g822a0823c012b912f0108a4da257cd97cbcdb7a3
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sat Nov 12 11:58:07 2022 +0100

    [PR68097] Try to avoid recursing for floats in
gimple_stmt_nonnegative_warnv_p.

    It irks me that a PR named "we should track ranges for floating-point
    hasn't been closed in this release.  This is an attempt to do just
    that.

    As mentioned in the PR, even though we track ranges for floats, it has
    been suggested that avoiding recursing through SSA defs in
    gimple_assign_nonnegative_warnv_p is also a goal.  This patch uses a
    global range query (no on-demand lookups, just global ranges and
    minimal folding) to determine if the range of a statement is known to
    be non-negative.

            PR tree-optimization/68097

    gcc/ChangeLog:

            * gimple-fold.cc (gimple_stmt_nonnegative_warnv_p): Call
            range_of_stmt for floats.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2022-11-17  8:54 ` cvs-commit at gcc dot gnu.org
@ 2022-11-17  8:54 ` aldyh at gcc dot gnu.org
  2022-11-28 22:24 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-11-17  8:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #11 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
fixed

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/68097] We should track ranges for floating-point values too
  2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2022-11-17  8:54 ` aldyh at gcc dot gnu.org
@ 2022-11-28 22:24 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-28 22:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68097

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-11-28 22:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26  8:48 [Bug tree-optimization/68097] New: We should track ranges for floating-point values too rsandifo at gcc dot gnu.org
2015-10-26  8:50 ` [Bug tree-optimization/68097] " pinskia at gcc dot gnu.org
2015-10-26 10:36 ` glisse at gcc dot gnu.org
2015-10-26 11:37 ` rguenth at gcc dot gnu.org
2015-10-27 11:53 ` rsandifo at gcc dot gnu.org
2022-09-17 12:10 ` aldyh at gcc dot gnu.org
2022-09-19  7:03 ` rguenth at gcc dot gnu.org
2022-09-19  7:31 ` aldyh at gcc dot gnu.org
2022-09-20 17:36 ` cvs-commit at gcc dot gnu.org
2022-11-08 15:57 ` aldyh at gcc dot gnu.org
2022-11-17  8:54 ` cvs-commit at gcc dot gnu.org
2022-11-17  8:54 ` aldyh at gcc dot gnu.org
2022-11-28 22:24 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).