Automatic Recognition and Replacement of Cyclic Redundancy Checks for Program Optimization
Mariam Arutunian, Sevak Sargsyan, Matevos Mehrabyan, Lilit Bareghamyan, Hayk Aslanyan · IEEE Access · 2024
Cyclic redundancy check (CRC) is a fundamental error-detection mechanism widely used in digital networks and storage systems to ensure data integrity. CRC can be implemented in various ways. Some methods, like bitwise implementations, are slow and less efficient. Other approaches, such as those using lookup tables, carry-less multiplication, or CRC instructions, offer better performance. This paper presents a novel method for automatic recognition and replacement of bitwise CRC implementations with more optimized alternatives. The method begins with the detection of potential code fragments containing bitwise CRC implementations using fast and simple checks. It then computes various parameters and employs a customized symbolic execution to verify the identified candidates. Subsequently, the method substitutes the CRC code fragment with more efficient alternatives. The method is implemented in the GCC compiler as a separate pass and is open-source available. Experimental evaluation was performed for x86-64, ARM64, and RISC-V architectures, and the results demonstrated up to 91%, 98%, and 93% performance improvements respectively, highlighting the effectiveness of the proposed optimization.