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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Tamar Christina
<[email protected]>:

https://gcc.gnu.org/g:f403d5f08ae92b30fac43bb89ef9c9dad25a79ec

commit r15-11262-gf403d5f08ae92b30fac43bb89ef9c9dad25a79ec
Author: Tamar Christina <[email protected]>
Date:   Fri Apr 17 07:46:07 2026 +0100

    middle-end: disable CRC pass when -Os and the target does not have CRC
optabs [PR124900]

    The example

    #include <stdint.h>
    #include <stddef.h>

    uint32_t crc32(const uint8_t *data, size_t length)
    {
        uint8_t i;
        uint32_t crc = 0xffffffff; // Initial value
        while (length--) {
            crc ^= (uint32_t)(*data++) << 24;
    #pragma GCC unroll 0
            for (i = 0; i < 8; ++i) {
                if (crc & 0x80000000)
                    crc = (crc << 1) ^ 0x04C11DB7;
                else
                    crc <<= 1;
            }
        }
        return crc;
    }

    when compiled with -Os -march=armv8-a increases the codesize significantly
    because it generates a loop that's as big as the original but adds a lookup
    table of 255 * 4 bytes.  This means it's actively making codesize bigger
and
    introduces a codesize regression from before the pass was added.

    This patch disables the CRC table based expansion when compiling for size.

    gcc/ChangeLog:

            PR middle-end/124900
            * gimple-crc-optimization.cc (crc_optimization::optimize_crc_loop):
Do
            not expand to table when compiling for size.
            (class crc_optimization): Update prototype of optimize_crc_loop to
            include loop.
            (crc_optimization::execute): Pass loop to optimize_crc_loop.

    gcc/testsuite/ChangeLog:

            PR middle-end/124900
            * gcc.target/aarch64/crc-1.c: New test.
            * gcc.target/aarch64/crc-2.c: New test.
            * gcc.target/aarch64/crc-3.c: New test.
            * gcc.target/aarch64/crc-4.c: New test.

    (cherry picked from commit 26e88fe809de0f1a1812c99e2e0106afb03257b3)
  • [Bug middle-end/124900] [15 Reg... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to