Hello! This patch set detects bitwise CRC implementation loops (with branches) in the GIMPLE optimizers and replaces them with more optimal CRC implementations in RTL. These patches introduce new internal functions, built-in functions, and expanders for CRC generation, leveraging hardware instructions where available. Additionally, various tests are included to check CRC detection and generation. Main Features: 1. CRC Loop Detection and Replacement: - Detection of CRC loops involves two stages: fast checks to identify potential candidates and verification using symbolic execution. The algorithm detects only CRCs (8, 16, 32, and 64 bits, both bit-forward and bit-reversed) with constant polynomials used without the leading 1. This part can be improved to detect more implementation types. - Once identified, the CRC loops are replaced with calls to newly added internal functions. These internal functions use target-specific expanders if available, otherwise generating table-based CRCs. 2. Architecture-Specific Expanders: - Expanders are added for RISC-V, aarch64, and i386 architectures. - These expanders generate CRCs using either carry-less multiplication instructions or direct CRC instructions, based on the target architecture's capabilities. 3. New Internal and Built-In Functions: - Introduces internal functions and built-in functions for CRC generation, supporting various CRC and data sizes (8, 16, 32, and 64 bits). I presented this work during the GNU Tools Cauldron 2023. You can view the presentation here: GCC CRC optimization presentation . Previously, I submitted a patch to GCC upstream that included built-in parts and expanders for RISC-V. However, the main component of the previously sent patch has been changed. You can find the patch here: https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626279.html Best regards, Mariam