[Bug tree-optimization/126810] New: simplify a ctz of a bit reversal

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

            Bug ID: 126810
           Summary: simplify a ctz of a bit reversal
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---

int f (unsigned x) { return __builtin_ctz (__builtin_bitreverse32 (x)); }

should be a single clz on aarch64 but GCC generates:
f:
        rbit    w0, w0
        rbit    w0, w0
        clz     w0, w0
        ret
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.