public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112095] New: `((~x) & y) ^ (x | y)` is x
@ 2023-10-26  4:48 pinskia at gcc dot gnu.org
  2023-10-26  4:48 ` [Bug tree-optimization/112095] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-26  4:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112095
           Summary: `((~x) & y) ^ (x | y)` is x
           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 f(int x, int y)
{
  return ((~x) & y) ^ (x | y); // x
}

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

These should simplify to what is in the comments.

So something like:

(simplify
 (bit_xor:c (bit_ior:c @0 @1) (bit_and:c @2 @1))
 (with { bool wascmp; }
  (if (bitwise_inverted_equal_p (@0, @2, wascmp)
       && (!wascmp || element_precision (type) == 1))
   @0)))

The above pattern will catch both.

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

* [Bug tree-optimization/112095] `((~x) & y) ^ (x | y)` is x
  2023-10-26  4:48 [Bug tree-optimization/112095] New: `((~x) & y) ^ (x | y)` is x pinskia at gcc dot gnu.org
@ 2023-10-26  4:48 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-26  4:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-10-26
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

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

end of thread, other threads:[~2023-10-26  4:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-26  4:48 [Bug tree-optimization/112095] New: `((~x) & y) ^ (x | y)` is x pinskia at gcc dot gnu.org
2023-10-26  4:48 ` [Bug tree-optimization/112095] " 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).