[llvm] [LoopIdiomRecognize] Enable clmul optimization for CRC loops (PR #203405)
Sean Clarke via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 11:49:07 PDT 2026
================
@@ -1572,6 +1580,156 @@ bool LoopIdiomRecognize::avoidLIRForMultiBlockLoop(bool IsMemset,
}
bool LoopIdiomRecognize::optimizeCRCLoop(const PolynomialInfo &Info) {
+ if (ForceCRCClmul)
+ return optimizeCRCLoopUsingClmul(Info) ||
+ (!ApplyCodeSizeHeuristics && optimizeCRCLoopUsingTableLookup(Info));
+
+ // FIXME: Once intrinsic cost modeling is more reliable for clmul, that should
+ // be used to determine which optimization to use. Until then, only apply the
+ // clmul optimization when optimizing for size, since a lookup table is not
+ // viable in that case. On some platforms, TC=8 for clmul seems to be slower
+ // than even the unoptimized loop, so bail on that case as well.
+ return ApplyCodeSizeHeuristics
+ ? Info.TripCount > 8 && optimizeCRCLoopUsingClmul(Info)
+ : optimizeCRCLoopUsingTableLookup(Info);
----------------
xarkenz wrote:
The dip in the CRC-64 TC=32 case should be remediated by https://github.com/llvm/llvm-project/pull/209265. That doesn't affect the mergeability of this PR, though-- for now, this optimization only applies when the table optimization cannot be applied.
https://github.com/llvm/llvm-project/pull/203405
More information about the llvm-commits
mailing list