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

            Bug ID: 123039
           Summary: crc loop recognition fails at -O3
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: camel-cdr at protonmail dot com
  Target Milestone: ---

I noticed that GCC fails to recognize CRC loops, e.g.:

    uint32_t
    crc32(uint8_t *src, size_t n, uint32_t crc)
    {
        const uint32_t POLY = 0x04C11DB7;
        for (size_t i = 0; i < n; ++i) {
            crc = crc ^ ((uint64_t)src[i] << 24);
            for (size_t j = 0; j < 8; ++j)
                crc = (crc & 1u<<31) ? (crc << 1) ^ POLY : (crc << 1);
        }
        return crc;
    }

pinskia pointed out that this seems to be an -O3 problem, as the loop is
recognized with -O2: https://godbolt.org/z/9E18h191v
  • [Bug tree-optimization/123039... camel-cdr at protonmail dot com via Gcc-bugs

Reply via email to