[llvm] [AArch64][CostModel] Fix stale costs for "ctpop" Intrinsic (PR #191769)
Yashwant Singh via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 05:00:18 PDT 2026
yashssh wrote:
Thanks for the review @davemgreen! Are you suggesting instead of hardcoding scalar costs in table I should add something like below?
```
if (!RetTy->isVectorTy()) {
Type *VecTy = VectorType::get(RetTy, 64 / RetTy->getScalarSizeInBits(), false);
InstructionCost Cost =
getVectorInstrCost(Instruction::InsertElement, VecTy, CostKind, 0, nullptr, nullptr) +
getIntrinsicInstrCost({Intrinsic::ctpop, {VecTy}, {}}, CostKind) +
getVectorInstrCost(Instruction::ExtractElement, VecTy, CostKind, 0, nullptr, nullptr);
return Cost;
}
```
This ends up giving even bigger costs
> See https://davemgreen.github.io/codesize.html?from=thru&instr=ctpop for the list of all the instructions.
Ah yes, I myself ended up here doing a similar comparison between TTI costs and LLVM-MCA, although I am focused more on Grace and Olympys.
https://github.com/llvm/llvm-project/pull/191769
More information about the llvm-commits
mailing list