[llvm] [LoopIdiom] Use costing to determine CRC strategy (PR #211040)

Sean Clarke via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 09:03:56 PDT 2026


xarkenz wrote:

> > I may need some guidance regarding the behavior under optsize
> 
> CRC is normally a very small part of a program and we shouldn't over-engineer. I'd measure the code size for our tests and gather it in a table. This data should help us choose a simple strategy, even if it's suboptimal by a few bytes.

True, I would guess a typical program involving CRC would have *at most* one or two CRC loops. Being off by a few bytes isn't a big deal, then. The easiest thing to do would be to once again disable CRC optimization as a whole for optsize, since the only platform where clmul seems to reduce the code size in most cases is RISC-V. Alternatively, I could use a check for `isOperationLegal(CLMUL, IndexTy)` rather than `isOperationLegalOrCustom` to allow RISC-V to benefit while excluding X86/ARM since they require moving in/out of SIMD registers.

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


More information about the llvm-commits mailing list