public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111959] New: tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types
@ 2023-10-24 16:25 pinskia at gcc dot gnu.org
  2023-10-24 16:35 ` [Bug middle-end/111959] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-24 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111959
           Summary: tree_single_nonnegative_warnv_p could use
                    tree_nonzero_bits for SSA_NAMES and int types
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: internal-improvement, missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

I Noticed this while looking into PR 101590.

tree_single_nonnegative_warnv_p  currently does:
    case SSA_NAME:
      /* Limit the depth of recursion to avoid quadratic behavior.
         This is expected to catch almost all occurrences in practice.
         If this code misses important cases that unbounded recursion
         would not, passes that need this information could be revised
         to provide it through dataflow propagation.  */
      return (!name_registered_for_update_p (t)
              && depth < param_max_ssa_name_query_depth
              && gimple_stmt_nonnegative_warnv_p (SSA_NAME_DEF_STMT (t),
                                                  strict_overflow_p, depth));

But we could/should use tree_nonzero_bits first to see if the info is already
cached somewhere.  This might speed up things.

An example of where this would improve is:
```
int f(int a, int b)
{
  if (a & ~0xff) __builtin_unreachable();
  return a / (1<<b);
}
int f1(int a, int b)
{
  if (a & ~0xff) __builtin_unreachable();
  return a >>b;
}
```

There are other examples too.

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

* [Bug middle-end/111959] tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types
  2023-10-24 16:25 [Bug middle-end/111959] New: tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types pinskia at gcc dot gnu.org
@ 2023-10-24 16:35 ` pinskia at gcc dot gnu.org
  2023-10-24 17:35 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-24 16:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-10-24
             Status|UNCONFIRMED                 |NEW
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

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

* [Bug middle-end/111959] tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types
  2023-10-24 16:25 [Bug middle-end/111959] New: tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types pinskia at gcc dot gnu.org
  2023-10-24 16:35 ` [Bug middle-end/111959] " pinskia at gcc dot gnu.org
@ 2023-10-24 17:35 ` pinskia at gcc dot gnu.org
  2023-10-24 20:36 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-24 17:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Floating point could also use the ranger too.
I do wonder if we want to use the global or local ranger here ...
I am going to start with the global one.

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

* [Bug middle-end/111959] tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types
  2023-10-24 16:25 [Bug middle-end/111959] New: tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types pinskia at gcc dot gnu.org
  2023-10-24 16:35 ` [Bug middle-end/111959] " pinskia at gcc dot gnu.org
  2023-10-24 17:35 ` pinskia at gcc dot gnu.org
@ 2023-10-24 20:36 ` pinskia at gcc dot gnu.org
  2023-10-25  1:11 ` pinskia at gcc dot gnu.org
  2023-10-25  3:51 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-24 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 56195
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56195&action=edit
Patch which I am testing

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

* [Bug middle-end/111959] tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types
  2023-10-24 16:25 [Bug middle-end/111959] New: tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-10-24 20:36 ` pinskia at gcc dot gnu.org
@ 2023-10-25  1:11 ` pinskia at gcc dot gnu.org
  2023-10-25  3:51 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-25  1:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=80776

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Doing this causes PR 80776 to show up again.

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

* [Bug middle-end/111959] tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types
  2023-10-24 16:25 [Bug middle-end/111959] New: tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-10-25  1:11 ` pinskia at gcc dot gnu.org
@ 2023-10-25  3:51 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-25  3:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2023-October
                   |                            |/634205.html

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch submitted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-October/634205.html

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

end of thread, other threads:[~2023-10-25  3:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-24 16:25 [Bug middle-end/111959] New: tree_single_nonnegative_warnv_p could use tree_nonzero_bits for SSA_NAMES and int types pinskia at gcc dot gnu.org
2023-10-24 16:35 ` [Bug middle-end/111959] " pinskia at gcc dot gnu.org
2023-10-24 17:35 ` pinskia at gcc dot gnu.org
2023-10-24 20:36 ` pinskia at gcc dot gnu.org
2023-10-25  1:11 ` pinskia at gcc dot gnu.org
2023-10-25  3:51 ` 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).