public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107342] New: Optimization opportunity where integer '/' corresponds to '>>'
@ 2022-10-21  8:36 tschwinge at gcc dot gnu.org
  2022-10-21 19:04 ` [Bug tree-optimization/107342] " aldyh at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2022-10-21  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107342
           Summary: Optimization opportunity where integer '/' corresponds
                    to '>>'
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
                CC: aldyh at gcc dot gnu.org, amacleod at redhat dot com
  Target Milestone: ---

Created attachment 53742
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53742&action=edit
variant of 'gcc.dg/tree-ssa/pr107195-3.c'

Discovered during work on "Add 'gcc.dg/tree-ssa/pr107195-3.c' [PR107195]"
(which is pending approval for push to master branch) an optimization
opportunity where integer '/' corresponds to '>>'.  See discussion in
<https://inbox.sourceware.org/gcc-patches/CAGm3qMV5_7hEED6_NKNAFaiE5dFXapsrRGEd_MAqNiSsF15nmw@mail.gmail.com>
about 'f4b'/'foo4b', and the "variant of 'gcc.dg/tree-ssa/pr107195-3.c'"
attached here.

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

* [Bug tree-optimization/107342] Optimization opportunity where integer '/' corresponds to '>>'
  2022-10-21  8:36 [Bug tree-optimization/107342] New: Optimization opportunity where integer '/' corresponds to '>>' tschwinge at gcc dot gnu.org
@ 2022-10-21 19:04 ` aldyh at gcc dot gnu.org
  2022-10-21 19:10 ` aldyh at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-10-21 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-10-21

--- Comment #1 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Confirmed.

As mentioned on gcc-patches, if we track nonzero bits through the division, we
should be able to thread from the r *= 8U to the return.  This should allow
some other pass to remove the second call to foo4b.

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

* [Bug tree-optimization/107342] Optimization opportunity where integer '/' corresponds to '>>'
  2022-10-21  8:36 [Bug tree-optimization/107342] New: Optimization opportunity where integer '/' corresponds to '>>' tschwinge at gcc dot gnu.org
  2022-10-21 19:04 ` [Bug tree-optimization/107342] " aldyh at gcc dot gnu.org
@ 2022-10-21 19:10 ` aldyh at gcc dot gnu.org
  2022-10-22 18:01 ` aldyh at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-10-21 19:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Created attachment 53749
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53749&action=edit
untested patch

I'm sure somebody smarter could handle other shift amounts that are not powers
of 2, but this seems to do the trick for the test case. DOM2 does the threading
and DOM3 will remove the second call to foo4b.

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

* [Bug tree-optimization/107342] Optimization opportunity where integer '/' corresponds to '>>'
  2022-10-21  8:36 [Bug tree-optimization/107342] New: Optimization opportunity where integer '/' corresponds to '>>' tschwinge at gcc dot gnu.org
  2022-10-21 19:04 ` [Bug tree-optimization/107342] " aldyh at gcc dot gnu.org
  2022-10-21 19:10 ` aldyh at gcc dot gnu.org
@ 2022-10-22 18:01 ` aldyh at gcc dot gnu.org
  2022-11-04 14:18 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-10-22 18:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #53749|0                           |1
        is obsolete|                            |

--- Comment #3 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Created attachment 53758
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53758&action=edit
tested

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

* [Bug tree-optimization/107342] Optimization opportunity where integer '/' corresponds to '>>'
  2022-10-21  8:36 [Bug tree-optimization/107342] New: Optimization opportunity where integer '/' corresponds to '>>' tschwinge at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-10-22 18:01 ` aldyh at gcc dot gnu.org
@ 2022-11-04 14:18 ` cvs-commit at gcc dot gnu.org
  2022-11-04 14:20 ` aldyh at gcc dot gnu.org
  2022-11-28 22:13 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-04 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:679be32e66428f0ba81d1c1b55f7bd47f01cb295

commit r13-3688-g679be32e66428f0ba81d1c1b55f7bd47f01cb295
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Fri Nov 4 10:20:46 2022 +0100

    Set nonzero bits for multiplication and divisions by a power of 2.

    We're missing a lot of TLC in keeping track of nonzero bits across
    range-ops.  It isn't an oversight, but just limited amount of hours to
    implement stuff.

    This patch keeps better track of the nonzero mask (really
    maybe_nonzero bits as discussed) across multiplication and division
    when the RHS is a power of 2.

    It fixes PR107342 and also touches on PR55157.  In the latter, the
    nonzero mask is being set quite late (CCP2) but could be set by evrp
    time if we enhanced range-ops.  I have added tests from both PRs.

    Tested

            PR tree-optimization/107342

    gcc/ChangeLog:

            * range-op.cc (operator_mult::fold_range): New.
            (operator_div::fold_range): New.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/vrp122.c: New test.
            * gcc.dg/tree-ssa/vrp123.c: New test.

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

* [Bug tree-optimization/107342] Optimization opportunity where integer '/' corresponds to '>>'
  2022-10-21  8:36 [Bug tree-optimization/107342] New: Optimization opportunity where integer '/' corresponds to '>>' tschwinge at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-11-04 14:18 ` cvs-commit at gcc dot gnu.org
@ 2022-11-04 14:20 ` aldyh at gcc dot gnu.org
  2022-11-28 22:13 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-11-04 14:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug tree-optimization/107342] Optimization opportunity where integer '/' corresponds to '>>'
  2022-10-21  8:36 [Bug tree-optimization/107342] New: Optimization opportunity where integer '/' corresponds to '>>' tschwinge at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-11-04 14:20 ` aldyh at gcc dot gnu.org
@ 2022-11-28 22:13 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-28 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21  8:36 [Bug tree-optimization/107342] New: Optimization opportunity where integer '/' corresponds to '>>' tschwinge at gcc dot gnu.org
2022-10-21 19:04 ` [Bug tree-optimization/107342] " aldyh at gcc dot gnu.org
2022-10-21 19:10 ` aldyh at gcc dot gnu.org
2022-10-22 18:01 ` aldyh at gcc dot gnu.org
2022-11-04 14:18 ` cvs-commit at gcc dot gnu.org
2022-11-04 14:20 ` aldyh at gcc dot gnu.org
2022-11-28 22:13 ` 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).