Skip to content

[SLP] getVectorCallCosts - don't provide scalar argument data for vector IntrinsicCostAttributes #124254

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

Merged
merged 1 commit into from
Jan 24, 2025
Merged
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
18 changes: 18 additions & 0 deletions llvm/lib/Target/X86/X86TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4719,6 +4719,24 @@ X86TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
if (const auto *Entry = CostTableLookup(X86CostTbl, ISD, MTy))
if (auto KindCost = Entry->Cost[CostKind])
return adjustTableCost(Entry->ISD, *KindCost, LT, ICA.getFlags());

// Without arg data, we need to compute the expanded costs of custom lowered
// intrinsics to prevent use of the (very low) default costs.
if (ICA.isTypeBasedOnly() &&
(IID == Intrinsic::fshl || IID == Intrinsic::fshr)) {
Type *CondTy = RetTy->getWithNewBitWidth(1);
InstructionCost Cost = 0;
Cost += getArithmeticInstrCost(BinaryOperator::Or, RetTy, CostKind);
Cost += getArithmeticInstrCost(BinaryOperator::Sub, RetTy, CostKind);
Cost += getArithmeticInstrCost(BinaryOperator::Shl, RetTy, CostKind);
Cost += getArithmeticInstrCost(BinaryOperator::LShr, RetTy, CostKind);
Cost += getArithmeticInstrCost(BinaryOperator::And, RetTy, CostKind);
Cost += getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
CmpInst::ICMP_EQ, CostKind);
Cost += getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
CmpInst::ICMP_EQ, CostKind);
return Cost;
}
}

return BaseT::getIntrinsicInstrCost(ICA, CostKind);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9031,9 +9031,7 @@ getVectorCallCosts(CallInst *CI, FixedVectorType *VecTy,
FastMathFlags FMF;
if (auto *FPCI = dyn_cast<FPMathOperator>(CI))
FMF = FPCI->getFastMathFlags();
SmallVector<const Value *> Arguments(CI->args());
IntrinsicCostAttributes CostAttrs(ID, VecTy, Arguments, ArgTys, FMF,
dyn_cast<IntrinsicInst>(CI));
IntrinsicCostAttributes CostAttrs(ID, VecTy, ArgTys, FMF);
auto IntrinsicCost =
TTI->getIntrinsicInstrCost(CostAttrs, TTI::TCK_RecipThroughput);

Expand Down
Loading
Loading