[llvm] Expanding the Histogram Intrinsic (PR #127399)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 02:46:47 PST 2025
================
@@ -1277,24 +1278,51 @@ InstructionCost VPHistogramRecipe::computeCost(ElementCount VF,
IntrinsicCostAttributes ICA(Intrinsic::experimental_vector_histogram_add,
Type::getVoidTy(Ctx.LLVMCtx),
{PtrTy, IncTy, MaskTy});
+ auto *UpdateInst = getOperand(2)->getUnderlyingValue();
+ InstructionCost UpdateCost;
+ if (isa<IntrinsicInst>(UpdateInst)) {
+ IntrinsicCostAttributes UpdateICA(Opcode, IncTy, {IncTy, IncTy});
+ UpdateCost = Ctx.TTI.getIntrinsicInstrCost(UpdateICA, Ctx.CostKind);
+ } else
+ UpdateCost = Ctx.TTI.getArithmeticInstrCost(Opcode, VTy, Ctx.CostKind);
// Add the costs together with the add/sub operation.
return Ctx.TTI.getIntrinsicInstrCost(ICA, Ctx.CostKind) + MulCost +
- Ctx.TTI.getArithmeticInstrCost(Opcode, VTy, Ctx.CostKind);
+ UpdateCost;
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void VPHistogramRecipe::print(raw_ostream &O, const Twine &Indent,
VPSlotTracker &SlotTracker) const {
+ auto *UpdateInst = cast<Instruction>(getOperand(2)->getUnderlyingValue());
+ assert(isLegalUpdateInstruction(UpdateInst) &&
+ "Found Ilegal update instruction for histogram");
O << Indent << "WIDEN-HISTOGRAM buckets: ";
getOperand(0)->printAsOperand(O, SlotTracker);
- if (Opcode == Instruction::Sub)
- O << ", dec: ";
- else {
- assert(Opcode == Instruction::Add);
- O << ", inc: ";
+ std::string UpdateMsg;
----------------
huntergr-arm wrote:
No need for the temporary I think, you can just use `O << ", <update>: ";`
https://github.com/llvm/llvm-project/pull/127399
More information about the llvm-commits
mailing list