Skip to content

Commit

Permalink
[X86][BF16] Do not scalarize masked load for BF16 when we have AVX512…
Browse files Browse the repository at this point in the history
…BF16

Fixes #63017

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D155952
  • Loading branch information
phoebewang committed Jul 22, 2023
1 parent e295330 commit f11526b
Show file tree
Hide file tree
Showing 2 changed files with 586 additions and 3 deletions.
11 changes: 8 additions & 3 deletions llvm/lib/Target/X86/X86TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5839,6 +5839,9 @@ bool X86TTIImpl::isLegalMaskedLoad(Type *DataTy, Align Alignment) {
if (ScalarTy->isHalfTy() && ST->hasBWI())
return true;

if (ScalarTy->isBFloatTy() && ST->hasBF16())
return true;

if (!ScalarTy->isIntegerTy())
return false;

Expand Down Expand Up @@ -6294,16 +6297,18 @@ InstructionCost X86TTIImpl::getInterleavedMemoryOpCost(
bool UseMaskForCond, bool UseMaskForGaps) {
auto *VecTy = cast<FixedVectorType>(BaseTy);

auto isSupportedOnAVX512 = [&](Type *VecTy, bool HasBW) {
auto isSupportedOnAVX512 = [&](Type *VecTy) {
Type *EltTy = cast<VectorType>(VecTy)->getElementType();
if (EltTy->isFloatTy() || EltTy->isDoubleTy() || EltTy->isIntegerTy(64) ||
EltTy->isIntegerTy(32) || EltTy->isPointerTy())
return true;
if (EltTy->isIntegerTy(16) || EltTy->isIntegerTy(8) || EltTy->isHalfTy())
return HasBW;
return ST->hasBWI();
if (EltTy->isBFloatTy())
return ST->hasBF16();
return false;
};
if (ST->hasAVX512() && isSupportedOnAVX512(VecTy, ST->hasBWI()))
if (ST->hasAVX512() && isSupportedOnAVX512(VecTy))
return getInterleavedMemoryOpCostAVX512(
Opcode, VecTy, Factor, Indices, Alignment,
AddressSpace, CostKind, UseMaskForCond, UseMaskForGaps);
Expand Down

0 comments on commit f11526b

Please sign in to comment.