Skip to content

[TTI] Add alignment argument to TTI for compress/expand support #83516

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
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
16 changes: 8 additions & 8 deletions llvm/include/llvm/Analysis/TargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,9 @@ class TargetTransformInfo {
bool forceScalarizeMaskedScatter(VectorType *Type, Align Alignment) const;

/// Return true if the target supports masked compress store.
bool isLegalMaskedCompressStore(Type *DataType) const;
bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) const;
/// Return true if the target supports masked expand load.
bool isLegalMaskedExpandLoad(Type *DataType) const;
bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const;

/// Return true if the target supports strided load.
bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const;
Expand Down Expand Up @@ -1863,8 +1863,8 @@ class TargetTransformInfo::Concept {
Align Alignment) = 0;
virtual bool forceScalarizeMaskedScatter(VectorType *DataType,
Align Alignment) = 0;
virtual bool isLegalMaskedCompressStore(Type *DataType) = 0;
virtual bool isLegalMaskedExpandLoad(Type *DataType) = 0;
virtual bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) = 0;
virtual bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) = 0;
virtual bool isLegalStridedLoadStore(Type *DataType, Align Alignment) = 0;
virtual bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0,
unsigned Opcode1,
Expand Down Expand Up @@ -2358,11 +2358,11 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
Align Alignment) override {
return Impl.forceScalarizeMaskedScatter(DataType, Alignment);
}
bool isLegalMaskedCompressStore(Type *DataType) override {
return Impl.isLegalMaskedCompressStore(DataType);
bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) override {
return Impl.isLegalMaskedCompressStore(DataType, Alignment);
}
bool isLegalMaskedExpandLoad(Type *DataType) override {
return Impl.isLegalMaskedExpandLoad(DataType);
bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) override {
return Impl.isLegalMaskedExpandLoad(DataType, Alignment);
}
bool isLegalStridedLoadStore(Type *DataType, Align Alignment) override {
return Impl.isLegalStridedLoadStore(DataType, Alignment);
Expand Down
8 changes: 6 additions & 2 deletions llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,18 @@ class TargetTransformInfoImplBase {
return false;
}

bool isLegalMaskedCompressStore(Type *DataType) const { return false; }
bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) const {
return false;
}

bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1,
const SmallBitVector &OpcodeMask) const {
return false;
}

bool isLegalMaskedExpandLoad(Type *DataType) const { return false; }
bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const {
return false;
}

bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const {
return false;
Expand Down
10 changes: 6 additions & 4 deletions llvm/lib/Analysis/TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,14 @@ bool TargetTransformInfo::forceScalarizeMaskedScatter(VectorType *DataType,
return TTIImpl->forceScalarizeMaskedScatter(DataType, Alignment);
}

bool TargetTransformInfo::isLegalMaskedCompressStore(Type *DataType) const {
return TTIImpl->isLegalMaskedCompressStore(DataType);
bool TargetTransformInfo::isLegalMaskedCompressStore(Type *DataType,
Align Alignment) const {
return TTIImpl->isLegalMaskedCompressStore(DataType, Alignment);
}

bool TargetTransformInfo::isLegalMaskedExpandLoad(Type *DataType) const {
return TTIImpl->isLegalMaskedExpandLoad(DataType);
bool TargetTransformInfo::isLegalMaskedExpandLoad(Type *DataType,
Align Alignment) const {
return TTIImpl->isLegalMaskedExpandLoad(DataType, Alignment);
}

bool TargetTransformInfo::isLegalStridedLoadStore(Type *DataType,
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/X86/X86TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5938,7 +5938,7 @@ bool X86TTIImpl::isLegalBroadcastLoad(Type *ElementTy,
ElementTy == Type::getDoubleTy(ElementTy->getContext());
}

bool X86TTIImpl::isLegalMaskedExpandLoad(Type *DataTy) {
bool X86TTIImpl::isLegalMaskedExpandLoad(Type *DataTy, Align Alignment) {
if (!isa<VectorType>(DataTy))
return false;

Expand All @@ -5962,8 +5962,8 @@ bool X86TTIImpl::isLegalMaskedExpandLoad(Type *DataTy) {
((IntWidth == 8 || IntWidth == 16) && ST->hasVBMI2());
}

bool X86TTIImpl::isLegalMaskedCompressStore(Type *DataTy) {
return isLegalMaskedExpandLoad(DataTy);
bool X86TTIImpl::isLegalMaskedCompressStore(Type *DataTy, Align Alignment) {
return isLegalMaskedExpandLoad(DataTy, Alignment);
}

bool X86TTIImpl::supportsGather() const {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/X86/X86TargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
bool isLegalMaskedGatherScatter(Type *DataType, Align Alignment);
bool isLegalMaskedGather(Type *DataType, Align Alignment);
bool isLegalMaskedScatter(Type *DataType, Align Alignment);
bool isLegalMaskedExpandLoad(Type *DataType);
bool isLegalMaskedCompressStore(Type *DataType);
bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment);
bool isLegalMaskedCompressStore(Type *DataType, Align Alignment);
bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1,
const SmallBitVector &OpcodeMask) const;
bool hasDivRemOp(Type *DataType, bool IsSigned);
Expand Down
8 changes: 6 additions & 2 deletions llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,16 @@ static bool optimizeCallInst(CallInst *CI, bool &ModifiedDT,
return true;
}
case Intrinsic::masked_expandload:
if (TTI.isLegalMaskedExpandLoad(CI->getType()))
if (TTI.isLegalMaskedExpandLoad(
CI->getType(),
CI->getAttributes().getParamAttrs(0).getAlignment().valueOrOne()))
return false;
scalarizeMaskedExpandLoad(DL, CI, DTU, ModifiedDT);
return true;
case Intrinsic::masked_compressstore:
if (TTI.isLegalMaskedCompressStore(CI->getArgOperand(0)->getType()))
if (TTI.isLegalMaskedCompressStore(
CI->getArgOperand(0)->getType(),
CI->getAttributes().getParamAttrs(1).getAlignment().valueOrOne()))
return false;
scalarizeMaskedCompressStore(DL, CI, DTU, ModifiedDT);
return true;
Expand Down