[llvm] [LoopIdiom] Use HashRecognize to optimize CRC (PR #143208)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 17 23:21:15 PDT 2025


================
@@ -620,9 +624,10 @@ HashRecognize::recognizeCRC() const {
   if (!checkExtractBits(ResultBits, TC, IsZero, *ByteOrderSwapped))
     return ErrBits(ResultBits, TC, *ByteOrderSwapped);
 
-  const Value *LHSAux = SimpleRecurrence ? SimpleRecurrence.Start : nullptr;
+  Value *LHSAux = SimpleRecurrence ? SimpleRecurrence.Start : nullptr;
+  const CRCTable &SarwateTable = genSarwateTable(GenPoly, *ByteOrderSwapped);
----------------
pfusik wrote:

What I meant was to refactor how the table is generated. Instead of returning the whole table by value, return one element at a time. I have no intuition how expensive `CRCTable` copies are. Why have a reference to a temporary object here?

https://github.com/llvm/llvm-project/pull/143208


More information about the llvm-commits mailing list