[llvm] 1736f76 - [CostModel][X86] getTypeBasedIntrinsicInstrCost - adjustTableCost - split CostTblEntry into ISD/Cost pair. NFC
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 03:17:35 PDT 2022
Author: Simon Pilgrim
Date: 2022-08-26T11:17:22+01:00
New Revision: 1736f76948a630bf9f3547a0a0d50cd86ed20901
URL: https://github.com/llvm/llvm-project/commit/1736f76948a630bf9f3547a0a0d50cd86ed20901
DIFF: https://github.com/llvm/llvm-project/commit/1736f76948a630bf9f3547a0a0d50cd86ed20901.diff
LOG: [CostModel][X86] getTypeBasedIntrinsicInstrCost - adjustTableCost - split CostTblEntry into ISD/Cost pair. NFC
This will be necessary to allow us to reuse this for other cost kind types
Added:
Modified:
llvm/lib/Target/X86/X86TargetTransformInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 7c44cb09342f2..9351e6b5a22a7 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -3509,104 +3509,125 @@ X86TTIImpl::getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
if (ISD == ISD::FSQRT && CostKind == TTI::TCK_CodeSize)
return LT.first;
- auto adjustTableCost = [](const CostTblEntry &Entry,
+ auto adjustTableCost = [](int ISD, unsigned Cost,
InstructionCost LegalizationCost,
FastMathFlags FMF) {
// If there are no NANs to deal with, then these are reduced to a
// single MIN** or MAX** instruction instead of the MIN/CMP/SELECT that we
// assume is used in the non-fast case.
- if (Entry.ISD == ISD::FMAXNUM || Entry.ISD == ISD::FMINNUM) {
+ if (ISD == ISD::FMAXNUM || ISD == ISD::FMINNUM) {
if (FMF.noNaNs())
return LegalizationCost * 1;
}
- return LegalizationCost * (int)Entry.Cost;
+ return LegalizationCost * (int)Cost;
};
if (ST->useGLMDivSqrtCosts())
if (const auto *Entry = CostTableLookup(GLMCostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->useSLMArithCosts())
if (const auto *Entry = CostTableLookup(SLMCostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasBITALG())
if (const auto *Entry = CostTableLookup(AVX512BITALGCostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasVPOPCNTDQ())
if (const auto *Entry = CostTableLookup(AVX512VPOPCNTDQCostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasCDI())
if (const auto *Entry = CostTableLookup(AVX512CDCostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasBWI())
if (const auto *Entry = CostTableLookup(AVX512BWCostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasAVX512())
if (const auto *Entry = CostTableLookup(AVX512CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasXOP())
if (const auto *Entry = CostTableLookup(XOPCostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasAVX2())
if (const auto *Entry = CostTableLookup(AVX2CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasAVX())
if (const auto *Entry = CostTableLookup(AVX1CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasSSE42())
if (const auto *Entry = CostTableLookup(SSE42CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasSSE41())
if (const auto *Entry = CostTableLookup(SSE41CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasSSSE3())
if (const auto *Entry = CostTableLookup(SSSE3CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasSSE2())
if (const auto *Entry = CostTableLookup(SSE2CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasSSE1())
if (const auto *Entry = CostTableLookup(SSE1CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (ST->hasBMI()) {
if (ST->is64Bit())
if (const auto *Entry = CostTableLookup(BMI64CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (const auto *Entry = CostTableLookup(BMI32CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
}
if (ST->hasLZCNT()) {
if (ST->is64Bit())
if (const auto *Entry = CostTableLookup(LZCNT64CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (const auto *Entry = CostTableLookup(LZCNT32CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
}
if (ST->hasPOPCNT()) {
if (ST->is64Bit())
if (const auto *Entry = CostTableLookup(POPCNT64CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (const auto *Entry = CostTableLookup(POPCNT32CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
}
if (ISD == ISD::BSWAP && ST->hasMOVBE() && ST->hasFastMOVBE()) {
@@ -3622,10 +3643,11 @@ X86TTIImpl::getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
if (ST->is64Bit())
if (const auto *Entry = CostTableLookup(X64CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first,
+ ICA.getFlags());
if (const auto *Entry = CostTableLookup(X86CostTbl, ISD, MTy))
- return adjustTableCost(*Entry, LT.first, ICA.getFlags());
+ return adjustTableCost(Entry->ISD, Entry->Cost, LT.first, ICA.getFlags());
}
return BaseT::getIntrinsicInstrCost(ICA, CostKind);
More information about the llvm-commits
mailing list