[RISCV] Add TTI support for cpop with Zbb
authorCraig Topper <craig.topper@sifive.com>
Wed, 24 Mar 2021 17:53:23 +0000 (10:53 -0700)
committerCraig Topper <craig.topper@sifive.com>
Wed, 24 Mar 2021 17:58:42 +0000 (10:58 -0700)
commitf24f09d256ae8a67569f3fb2f766dad3712d9c19
treed45e4767b34ce6a241e47c3d549867a10edef06e
parentc5d53efeff5ca3943af6684e999c8802d9f48702
[RISCV] Add TTI support for cpop with Zbb

This will tell loop idiom recognize that it can make popcount loops countable
using the ctpop intrinsic. I didn't bother checking for illegal types.
Type legalization knows how to split a ctpop into multiple ctops added together.
Assuming we only receive reasonable integer bit widths, a few cpop instructions
added together is probably better than the loop.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D99203
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
llvm/test/Transforms/LoopIdiom/RISCV/lit.local.cfg [new file with mode: 0644]
llvm/test/Transforms/LoopIdiom/RISCV/popcnt.ll [new file with mode: 0644]