[llvm] [SDag][ARM][RISCV] Allow lowering CTPOP into a libcall (PR #101786)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 5 04:55:59 PDT 2024


s-barannikov wrote:

It looks like LookIdiomRecognize already [bails out](https://github.com/llvm/llvm-project/blob/3bf83e3866237cd35c9828880241f5863d625ed9/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp#L2075) if popcount isn't supported by hardware, and the hook is correctly [implemented](https://github.com/llvm/llvm-project/blob/ad8026587464f29e53c673e892d646a4b94f138b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp#L281) on RISC-V.
However, this hook [isn't called](https://github.com/llvm/llvm-project/blob/62e9f40949ddc52e9660b25ab146bd5d9b39ad88/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp#L291) from AggressiveInstCombine, and this might be the reason we see the libcall. Another possible reason is that it is created by `expandCTTZ` / `expandCTLZ` in the backend.

It would be nice to have a reproducer.


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


More information about the llvm-commits mailing list