diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -660,7 +660,7 @@ /// \Returns true if the target supports broadcasting a load to a vector of /// type . - bool isLegalBroadcastLoad(Type *ElementTy, unsigned NumElements) const; + bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const; /// Return true if the target supports masked scatter. bool isLegalMaskedScatter(Type *DataType, Align Alignment) const; @@ -1561,7 +1561,7 @@ virtual bool isLegalNTStore(Type *DataType, Align Alignment) = 0; virtual bool isLegalNTLoad(Type *DataType, Align Alignment) = 0; virtual bool isLegalBroadcastLoad(Type *ElementTy, - unsigned NumElements) const = 0; + ElementCount NumElements) const = 0; virtual bool isLegalMaskedScatter(Type *DataType, Align Alignment) = 0; virtual bool isLegalMaskedGather(Type *DataType, Align Alignment) = 0; virtual bool forceScalarizeMaskedGather(VectorType *DataType, @@ -1970,7 +1970,7 @@ return Impl.isLegalNTLoad(DataType, Alignment); } bool isLegalBroadcastLoad(Type *ElementTy, - unsigned NumElements) const override { + ElementCount NumElements) const override { return Impl.isLegalBroadcastLoad(ElementTy, NumElements); } bool isLegalMaskedScatter(Type *DataType, Align Alignment) override { diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -256,7 +256,7 @@ return Alignment >= DataSize && isPowerOf2_32(DataSize); } - bool isLegalBroadcastLoad(Type *ElementTy, unsigned NumElements) const { + bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const { return false; } diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -397,7 +397,7 @@ } bool TargetTransformInfo::isLegalBroadcastLoad(Type *ElementTy, - unsigned NumElements) const { + ElementCount NumElements) const { return TTIImpl->isLegalBroadcastLoad(ElementTy, NumElements); } diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.h b/llvm/lib/Target/X86/X86TargetTransformInfo.h --- a/llvm/lib/Target/X86/X86TargetTransformInfo.h +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.h @@ -227,7 +227,7 @@ bool isLegalMaskedStore(Type *DataType, Align Alignment); bool isLegalNTLoad(Type *DataType, Align Alignment); bool isLegalNTStore(Type *DataType, Align Alignment); - bool isLegalBroadcastLoad(Type *ElementTy, unsigned NumElements) const; + bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const; bool forceScalarizeMaskedGather(VectorType *VTy, Align Alignment); bool forceScalarizeMaskedScatter(VectorType *VTy, Align Alignment) { return forceScalarizeMaskedGather(VTy, Alignment); diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -1558,7 +1558,7 @@ if (const auto *Entry = CostTableLookup(SSE3BroadcastLoadTbl, Kind, LT.second)) { assert(isLegalBroadcastLoad(BaseTp->getElementType(), - LT.second.getVectorNumElements()) && + LT.second.getVectorElementCount()) && "Table entry missing from isLegalBroadcastLoad()"); return LT.first * Entry->Cost; } @@ -5137,9 +5137,10 @@ } bool X86TTIImpl::isLegalBroadcastLoad(Type *ElementTy, - unsigned NumElements) const { + ElementCount NumElements) const { // movddup - return ST->hasSSE3() && NumElements == 2 && + return ST->hasSSE3() && !NumElements.isScalable() && + NumElements.getFixedValue() == 2 && ElementTy == Type::getDoubleTy(ElementTy->getContext()); } diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1176,7 +1176,8 @@ if (isa(V1)) { // A broadcast of a load can be cheaper on some targets. // TODO: For now accept a broadcast load with no other internal uses. - if (TTI->isLegalBroadcastLoad(V1->getType(), NumLanes) && + if (TTI->isLegalBroadcastLoad(V1->getType(), + ElementCount::getFixed(NumLanes)) && (int)V1->getNumUses() == NumLanes) return VLOperands::ScoreSplatLoads; }