[Bug tree-optimization/126743] New: If a != b, then (a | b) (==,!=) 0 -> (false, true)

kaelfandrew at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126743

            Bug ID: 126743
           Summary: If a != b, then (a | b) (==,!=) 0 -> (false, true)
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kaelfandrew at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/Y6Y9Ps3GE

With GCC trunk -O2:

```
_Bool
or_eq_zero (int a, int b)
{
  if (a == b)
    __builtin_unreachable ();
  // return 0;
  return (a | b) == 0;
}

_Bool
or_ne_zero (int a, int b)
{
  if (a == b)
    __builtin_unreachable ();
  // return 1;
  return (a | b) != 0;
}
```

Noticed from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117760#c11
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.