Hi all,
I have a patch consisting of a few commits implementing CRC recognition in the Loop Idiom Recognizer, replacing the loop with a lookup table. I would like to establish three things in this thread:
- Whether this something that is suitable for LLVM
- How it should be reviewed
- Volunteers for reviewers
The initial motivation was CoreMark, to which this patch increases performance by over 10% on our 32-bit RISC-V core. However, the application is broad enough to apply to any project implementing a bitwise CRC loop. A similar project was presented at the gnu couldron, to which claimed there are more than 200 bitwise implementations in Fedora packages. I have not verified this, but have collected a handful of crc implementations from the web (including the linux kernel), and adapted these into the unit tests.
The patch currently consists of seven commits, each containing a distinct piece of functionality. Would this be a separate review for each one, or one large PR for them all?
Current limitations:
- Only works on byte loops
CRC size can be any, but the data is limited to one byte. i.e. a loop with iteration count 8. - Only works on single-block loops
most CRC loops would have been flattened to one block with select instructions this far into the pipeline.
Both limitations were in effort to reduce complexity, especially for a first patch. The code can be fairly easily extended to overcome these limitations.
And lastly, a little bit about implementation details in a crude five step process!
- Check if the loop looks like CRC and extract some useful information
- Execute one iteration of the instruction of the loop to see what happens to our output value
- Ensure the output value is predicated on the value of the M/LSB of our input
- Construct an expected output value of one iteration of CRC using the extracted information from step one and compare
- Construct a lookup table and replace the output value with a lookup
Thanks all!
Joe