public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111147] New: bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more
@ 2023-08-25  1:37 pinskia at gcc dot gnu.org
  2023-08-25  1:37 ` [Bug tree-optimization/111147] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-25  1:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111147
           Summary: bitwise_inverted_equal_p can be used in the `(x | y) &
                    (~x ^ y)` pattern to catch more
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
int g(int x, int y)
{
  return (x | y) & (~x ^ y); // x & y
}
int g0(int x, int y)
{
  return (~x | y) & (x ^ y); // ~x & y
}
```

g is correctly optimized to `x & y` but g0 is not optimized to `~x & y` even
though it could be.

If this pattern used bitwise_inverted_equal_p it could be.

Note this could also be used to catch comparisons too.

Filing this not to lose this idea.

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

* [Bug tree-optimization/111147] bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more
  2023-08-25  1:37 [Bug tree-optimization/111147] New: bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more pinskia at gcc dot gnu.org
@ 2023-08-25  1:37 ` pinskia at gcc dot gnu.org
  2023-08-28 20:14 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-25  1:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-25
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

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

* [Bug tree-optimization/111147] bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more
  2023-08-25  1:37 [Bug tree-optimization/111147] New: bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more pinskia at gcc dot gnu.org
  2023-08-25  1:37 ` [Bug tree-optimization/111147] " pinskia at gcc dot gnu.org
@ 2023-08-28 20:14 ` pinskia at gcc dot gnu.org
  2023-08-29  8:06 ` cvs-commit at gcc dot gnu.org
  2023-08-29  8:07 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-28 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628600.html

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

* [Bug tree-optimization/111147] bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more
  2023-08-25  1:37 [Bug tree-optimization/111147] New: bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more pinskia at gcc dot gnu.org
  2023-08-25  1:37 ` [Bug tree-optimization/111147] " pinskia at gcc dot gnu.org
  2023-08-28 20:14 ` pinskia at gcc dot gnu.org
@ 2023-08-29  8:06 ` cvs-commit at gcc dot gnu.org
  2023-08-29  8:07 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-29  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:7c04da768c1fc22e0607e3ccad87e2c793499797

commit r14-3540-g7c04da768c1fc22e0607e3ccad87e2c793499797
Author: Andrew Pinski <apinski@marvell.com>
Date:   Mon Aug 28 10:04:00 2023 -0700

    MATCH: Move `(x | y) & (~x ^ y)` over to use bitwise_inverted_equal_p

    This moves the match pattern `(x | y) & (~x ^ y)` over to use
bitwise_inverted_equal_p.
    This now also allows to optmize comparisons and also catches the missed
`(~x | y) & (x ^ y)`
    transformation into `~x & y`.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    gcc/ChangeLog:

            PR tree-optimization/111147
            * match.pd (`(x | y) & (~x ^ y)`) Use bitwise_inverted_equal_p
            instead of matching bit_not.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/111147
            * gcc.dg/tree-ssa/cmpbit-4.c: New test.

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

* [Bug tree-optimization/111147] bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more
  2023-08-25  1:37 [Bug tree-optimization/111147] New: bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-08-29  8:06 ` cvs-commit at gcc dot gnu.org
@ 2023-08-29  8:07 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-29  8:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2023-08-29  8:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-25  1:37 [Bug tree-optimization/111147] New: bitwise_inverted_equal_p can be used in the `(x | y) & (~x ^ y)` pattern to catch more pinskia at gcc dot gnu.org
2023-08-25  1:37 ` [Bug tree-optimization/111147] " pinskia at gcc dot gnu.org
2023-08-28 20:14 ` pinskia at gcc dot gnu.org
2023-08-29  8:06 ` cvs-commit at gcc dot gnu.org
2023-08-29  8:07 ` 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).