[llvm] [LoopIdiomRecognize] Enable clmul optimization for CRC loops (PR #203405)
Piotr Fusik via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 07:59:14 PDT 2026
pfusik wrote:
> I've run some benchmarks on this optimization, and the results are somewhat disappointing. It seems that at least on my Macbook (which supports ARM `pmull`), the only real case where there is a net benefit of this approach over table lookup is for CRC32 with TripCount=32. The performance decreases slightly for smaller CRC widths, and decreases dramatically for smaller TripCounts. (In fact, CRC32 TC=8 seems to perform worse than the _unoptimized_ version, which is _really_ bad.) I think the two main paths forward that I can see are (a) rigorous cost modeling to try and ensure that this optimization will actually be beneficial on the target, and/or (b) restricting this to optimizing for size. I'm open to suggestions. (Option (a) may also allow for stronger optimization of e.g. CRC64 or TC=64, where performing clmul on integers larger than i64 may still be somewhat fast, so I think I'll try implementing and benchmarking that.)
>
> If it's easier to simply do option (b) for now and defer (a) to another PR, I can do that. I am worried about the TC=8 case, though, so I think at least _some_ cost modeling is in order.
Another option is (c) have this transform under a dedicated option that is disabled by default.
https://github.com/llvm/llvm-project/pull/203405
More information about the llvm-commits
mailing list