[llvm] [LoopIdiomRecognize] Enable clmul optimization for CRC loops (PR #203405)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 05:02:59 PDT 2026


================
@@ -88,6 +88,17 @@ class HashRecognize {
   LLVM_ABI static CRCTable genSarwateTable(const APInt &GenPoly,
                                            bool IsBigEndian);
 
+  // Auxilary entry point after analysis to generate constants for a GF(2)
+  // Barrett Reduction.
+  // Returns a pair of Mu of bitwidth TC+1 and FullGenPoly of bitwidth BW+1.
+  // Mu is used in the first clmul operation. Mu = floor(x^(BW+TC) / P(x)).
+  // FullGenPoly is used in the second clmul operation, and is \p GenPoly
+  // with the implied BW'th bit.
+  // Endianness is accounted for using \p IsBigEndian.
+  LLVM_ABI static std::pair<APInt, APInt>
+  genBarrettConstants(const APInt &GenPoly, unsigned TripCount,
+                      bool IsBigEndian);
----------------
pfusik wrote:

All the three parameters are members of `PolynomialInfo`, and are passed with the members of one `PolynomialInfo` in both call sites. I suggest passing `const PolynomialInfo &` instead.

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


More information about the llvm-commits mailing list