diff options
author | Craig Topper <craig.topper@intel.com> | 2018-11-28 18:11:42 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2018-11-28 18:11:42 +0000 |
commit | 81f1b4a36184114456b85553e9f465c71e674ea4 (patch) | |
tree | a83f302c9a3e6575c4dd91f3a4a783aa18de31dc /llvm/lib | |
parent | d3bb036bc93275e0b98fd19e93a0697f9aa097fa (diff) | |
download | bcm5719-llvm-81f1b4a36184114456b85553e9f465c71e674ea4.tar.gz bcm5719-llvm-81f1b4a36184114456b85553e9f465c71e674ea4.zip |
[X86] Make X86TTIImpl::getCastInstrCost properly handle the case where AVX512 is enabled, but 512-bit vectors aren't legal.
Unlike most cost model functions this code makes a lot of table lookups without using the results from getTypeLegalizationCost. This means 512-bit vectors can be looked up even when the type isn't legal.
This patch adds a check around the two tables that contain 512-bit types to make sure that neither of the types would be split by type legalization. Meaning 512 bit types are illegal. I wanted to write this in a somewhat generic way that uses type legalization query hooks. But if prefered, I can switch to just using is512BitVector and the subtarget feature.
Differential Revision: https://reviews.llvm.org/D54984
llvm-svn: 347786
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/X86/X86TargetTransformInfo.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index a77d8e04451..9ead6a614fc 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -1570,49 +1570,51 @@ int X86TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, if (!SrcTy.isSimple() || !DstTy.isSimple()) return BaseT::getCastInstrCost(Opcode, Dst, Src); - if (ST->hasBWI()) - if (const auto *Entry = ConvertCostTableLookup(AVX512BWConversionTbl, ISD, - DstTy.getSimpleVT(), - SrcTy.getSimpleVT())) - return Entry->Cost; + MVT SimpleSrcTy = SrcTy.getSimpleVT(); + MVT SimpleDstTy = DstTy.getSimpleVT(); + + // Make sure that neither type is going to be split before using the + // AVX512 tables. This handles -mprefer-vector-width=256 + // with -min-legal-vector-width<=256 + if (TLI->getTypeAction(SimpleSrcTy) != TargetLowering::TypeSplitVector && + TLI->getTypeAction(SimpleDstTy) != TargetLowering::TypeSplitVector) { + if (ST->hasBWI()) + if (const auto *Entry = ConvertCostTableLookup(AVX512BWConversionTbl, ISD, + SimpleDstTy, SimpleSrcTy)) + return Entry->Cost; - if (ST->hasDQI()) - if (const auto *Entry = ConvertCostTableLookup(AVX512DQConversionTbl, ISD, - DstTy.getSimpleVT(), - SrcTy.getSimpleVT())) - return Entry->Cost; + if (ST->hasDQI()) + if (const auto *Entry = ConvertCostTableLookup(AVX512DQConversionTbl, ISD, + SimpleDstTy, SimpleSrcTy)) + return Entry->Cost; - if (ST->hasAVX512()) - if (const auto *Entry = ConvertCostTableLookup(AVX512FConversionTbl, ISD, - DstTy.getSimpleVT(), - SrcTy.getSimpleVT())) - return Entry->Cost; + if (ST->hasAVX512()) + if (const auto *Entry = ConvertCostTableLookup(AVX512FConversionTbl, ISD, + SimpleDstTy, SimpleSrcTy)) + return Entry->Cost; + } if (ST->hasAVX2()) { if (const auto *Entry = ConvertCostTableLookup(AVX2ConversionTbl, ISD, - DstTy.getSimpleVT(), - SrcTy.getSimpleVT())) + SimpleDstTy, SimpleSrcTy)) return Entry->Cost; } if (ST->hasAVX()) { if (const auto *Entry = ConvertCostTableLookup(AVXConversionTbl, ISD, - DstTy.getSimpleVT(), - SrcTy.getSimpleVT())) + SimpleDstTy, SimpleSrcTy)) return Entry->Cost; } if (ST->hasSSE41()) { if (const auto *Entry = ConvertCostTableLookup(SSE41ConversionTbl, ISD, - DstTy.getSimpleVT(), - SrcTy.getSimpleVT())) + SimpleDstTy, SimpleSrcTy)) return Entry->Cost; } if (ST->hasSSE2()) { if (const auto *Entry = ConvertCostTableLookup(SSE2ConversionTbl, ISD, - DstTy.getSimpleVT(), - SrcTy.getSimpleVT())) + SimpleDstTy, SimpleSrcTy)) return Entry->Cost; } |