[PATCH] D32971: [scudo] CRC32 optimizations

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 13:11:11 PDT 2017


alekseyshl added inline comments.


================
Comment at: lib/scudo/scudo_allocator.cpp:78
     for (uptr i = 0; i < ARRAY_SIZE(HeaderHolder); i++)
       Crc = computeCRC32(Crc, HeaderHolder[i], HashType);
+#endif  // defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
----------------
Would it make sense to check algorithm once and duplicate the code here, instead of comparing on every loop iteration? More code, but since we're after the performance...

  if (HashType == CRC32Hardware) {
    Crc = computeHardwareCRC32(Cookie, reinterpret_cast<uptr>(this));
    for (uptr i = 0; i < ARRAY_SIZE(HeaderHolder); i++)
      Crc = computeHardwareCRC32(Crc, HeaderHolder[i]);
  } else {
    Crc = computeSoftwareCRC32(Cookie, reinterpret_cast<uptr>(this));
    for (uptr i = 0; i < ARRAY_SIZE(HeaderHolder); i++)
      Crc = computeSoftwareCRC32(Crc, HeaderHolder[i]);
  }


================
Comment at: lib/scudo/scudo_crc32.cpp:23
 }
 #endif  // defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
 
----------------
Please remind me, does it mean that computeHardwareCRC32 != 0 only when defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)? Or is it expected to come from other libraries too?


https://reviews.llvm.org/D32971





More information about the llvm-commits mailing list