[llvm] [AArch64][CostModel] Model sve costs for ctpop (PR #192428)

Yashwant Singh via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 00:59:26 PDT 2026


================

----------------
yashssh wrote:

I tried updating the block like you suggested:
```
if (ST->isSVEorStreamingSVEAvailable() && MTy.isFixedLengthVector() &&
    MTy.getScalarSizeInBits() > 8) {
  EVT ScalableVT = MVT::getScalableVectorVT(
      MTy.getVectorElementType(), 128 / MTy.getScalarSizeInBits());
  if (const auto *Entry =
          CostTableLookup(CtpopCostTbl, ISD::CTPOP, ScalableVT.getSimpleVT()))
    return LT.first * Entry->Cost;
}
```
How do I model sve width in this? For eg for `v8i64` this should return 4 as default, 8 on 256 wide sve and 10+ on 512 wide sve (based on codegen here https://godbolt.org/z/WePMx4638)

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


More information about the llvm-commits mailing list