Skip to content

[RISCV][TTI] Implement instruction cost for vp.reduce.* #114184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,37 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
return getCmpSelInstrCost(Instruction::Select, ICA.getReturnType(),
ICA.getArgTypes()[0], CmpInst::BAD_ICMP_PREDICATE,
CostKind);
case Intrinsic::vp_reduce_add:
case Intrinsic::vp_reduce_fadd:
case Intrinsic::vp_reduce_mul:
case Intrinsic::vp_reduce_fmul:
case Intrinsic::vp_reduce_and:
case Intrinsic::vp_reduce_or:
case Intrinsic::vp_reduce_xor: {
std::optional<Intrinsic::ID> RedID =
VPIntrinsic::getFunctionalIntrinsicIDForVP(ICA.getID());
assert(RedID.has_value());
unsigned RedOp = getArithmeticReductionInstruction(*RedID);
return getArithmeticReductionCost(RedOp,
cast<VectorType>(ICA.getArgTypes()[1]),
ICA.getFlags(), CostKind);
}
case Intrinsic::vp_reduce_smax:
case Intrinsic::vp_reduce_smin:
case Intrinsic::vp_reduce_umax:
case Intrinsic::vp_reduce_umin:
case Intrinsic::vp_reduce_fmax:
case Intrinsic::vp_reduce_fmaximum:
case Intrinsic::vp_reduce_fmin:
case Intrinsic::vp_reduce_fminimum: {
std::optional<Intrinsic::ID> RedID =
VPIntrinsic::getFunctionalIntrinsicIDForVP(ICA.getID());
assert(RedID.has_value());
Intrinsic::ID MinMaxID = getMinMaxReductionIntrinsicOp(*RedID);
return getMinMaxReductionCost(MinMaxID,
cast<VectorType>(ICA.getArgTypes()[1]),
ICA.getFlags(), CostKind);
}
}

if (ST->hasVInstructions() && RetTy->isVectorTy()) {
Expand Down
125 changes: 125 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-add.ll

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-and.ll

Large diffs are not rendered by default.

373 changes: 373 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-fadd.ll

Large diffs are not rendered by default.

172 changes: 172 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-fmaximum.ll

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-fminimum.ll

Large diffs are not rendered by default.

349 changes: 349 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-fmul.ll

Large diffs are not rendered by default.

252 changes: 251 additions & 1 deletion llvm/test/Analysis/CostModel/RISCV/reduce-max.ll

Large diffs are not rendered by default.

250 changes: 250 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-min.ll

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-or.ll

Large diffs are not rendered by default.

201 changes: 201 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-scalable-fp.ll

Large diffs are not rendered by default.

342 changes: 342 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-scalable-int.ll

Large diffs are not rendered by default.

125 changes: 125 additions & 0 deletions llvm/test/Analysis/CostModel/RISCV/reduce-xor.ll

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions llvm/test/Analysis/CostModel/RISCV/rvv-intrinsics.ll

Large diffs are not rendered by default.

Loading