[Bug tree-optimization/126969] New: If x is racecar, bitreverse (x) -> x

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=126969

            Bug ID: 126969
           Summary: If x is racecar, bitreverse (x) -> x
           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/6qPf5584j

With -O2:

int
bitreverse8_racecar (unsigned char x)
{
  if (x != 0 && x != 255)
    __builtin_unreachable ();
  return __builtin_bitreverse8 (x);
}

should optimize to return x.
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.