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

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).