diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index 23281c362b17dd..f4ab0738a1733d 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -1024,8 +1024,8 @@ class TargetTransformInfo { /// \return The cost of masked Load and Store instructions. int getMaskedMemoryOpCost( - unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace, - TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const; + unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, + TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const; /// \return The cost of Gather or Scatter operation /// \p Opcode - is a type of memory access Load or Store @@ -1426,8 +1426,7 @@ class TargetTransformInfo::Concept { unsigned AddressSpace, TTI::TargetCostKind CostKind, const Instruction *I) = 0; - virtual int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, - unsigned Alignment, + virtual int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind) = 0; virtual int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, @@ -1844,7 +1843,7 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept { return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind, I); } - int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, + int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind) override { return Impl.getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace, diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h index d2b64bee61eb0b..6c994bf22e1ae4 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -464,7 +464,7 @@ class TargetTransformInfoImplBase { return 1; } - unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, + unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind) { return 1; diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h index 497f6f7da81e6f..094cfe1980e749 100644 --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -963,10 +963,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase { unsigned Cost; if (UseMaskForCond || UseMaskForGaps) Cost = static_cast(this)->getMaskedMemoryOpCost( - Opcode, VecTy, Alignment, AddressSpace, CostKind); + Opcode, VecTy, Align(Alignment), AddressSpace, CostKind); else Cost = static_cast(this)->getMemoryOpCost( - Opcode, VecTy, MaybeAlign(Alignment), AddressSpace, CostKind); + Opcode, VecTy, Align(Alignment), AddressSpace, CostKind); // Legalize the vector type, and get the legalized and unlegalized type // sizes. @@ -1389,13 +1389,13 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase { return 0; case Intrinsic::masked_store: { Type *Ty = Tys[0]; - unsigned TyAlign = ConcreteTTI->DL.getABITypeAlignment(Ty); + Align TyAlign = ConcreteTTI->DL.getABITypeAlign(Ty); return ConcreteTTI->getMaskedMemoryOpCost(Instruction::Store, Ty, TyAlign, 0, CostKind); } case Intrinsic::masked_load: { Type *Ty = RetTy; - unsigned TyAlign = ConcreteTTI->DL.getABITypeAlignment(Ty); + Align TyAlign = ConcreteTTI->DL.getABITypeAlign(Ty); return ConcreteTTI->getMaskedMemoryOpCost(Instruction::Load, Ty, TyAlign, 0, CostKind); } diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp index fe9fe077027d5f..a2d05365d0a8d6 100644 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -757,10 +757,9 @@ int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src, return Cost; } -int TargetTransformInfo::getMaskedMemoryOpCost(unsigned Opcode, Type *Src, - unsigned Alignment, - unsigned AddressSpace, - TTI::TargetCostKind CostKind) const { +int TargetTransformInfo::getMaskedMemoryOpCost( + unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, + TTI::TargetCostKind CostKind) const { int Cost = TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind); diff --git a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp index 4b9c4a2d7ae5bb..86d9a497477906 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp @@ -200,9 +200,10 @@ unsigned HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src, CostKind, I); } -unsigned HexagonTTIImpl::getMaskedMemoryOpCost(unsigned Opcode, - Type *Src, unsigned Alignment, unsigned AddressSpace, - TTI::TargetCostKind CostKind) { +unsigned HexagonTTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *Src, + Align Alignment, + unsigned AddressSpace, + TTI::TargetCostKind CostKind) { return BaseT::getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind); } diff --git a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h index 068a11d2cf01e2..fea233ddbb821f 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h +++ b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h @@ -115,9 +115,10 @@ class HexagonTTIImpl : public BasicTTIImplBase { unsigned AddressSpace, TTI::TargetCostKind CostKind, const Instruction *I = nullptr); - unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, - unsigned AddressSpace, - TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency); + unsigned + getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, + unsigned AddressSpace, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency); unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp); unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index 2fb7764bbbb019..0408bea17e1fc9 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -3031,8 +3031,7 @@ int X86TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src, } int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy, - unsigned Alignment, - unsigned AddressSpace, + Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind) { bool IsLoad = (Instruction::Load == Opcode); bool IsStore = (Instruction::Store == Opcode); @@ -3040,14 +3039,13 @@ int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy, VectorType *SrcVTy = dyn_cast(SrcTy); if (!SrcVTy) // To calculate scalar take the regular cost, without mask - return getMemoryOpCost(Opcode, SrcTy, MaybeAlign(Alignment), AddressSpace, - CostKind); + return getMemoryOpCost(Opcode, SrcTy, Alignment, AddressSpace, CostKind); unsigned NumElem = SrcVTy->getNumElements(); auto *MaskTy = FixedVectorType::get(Type::getInt8Ty(SrcVTy->getContext()), NumElem); - if ((IsLoad && !isLegalMaskedLoad(SrcVTy, Align(Alignment))) || - (IsStore && !isLegalMaskedStore(SrcVTy, Align(Alignment))) || + if ((IsLoad && !isLegalMaskedLoad(SrcVTy, Alignment)) || + (IsStore && !isLegalMaskedStore(SrcVTy, Alignment)) || !isPowerOf2_32(NumElem)) { // Scalarization APInt DemandedElts = APInt::getAllOnesValue(NumElem); @@ -3062,8 +3060,7 @@ int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy, getScalarizationOverhead(SrcVTy, DemandedElts, IsLoad, IsStore); int MemopCost = NumElem * BaseT::getMemoryOpCost(Opcode, SrcVTy->getScalarType(), - MaybeAlign(Alignment), AddressSpace, - CostKind); + Alignment, AddressSpace, CostKind); return MemopCost + ValueSplitCost + MaskSplitCost + MaskCmpCost; } diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.h b/llvm/lib/Target/X86/X86TargetTransformInfo.h index f0aa28bca33c17..58cd344838b286 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.h +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.h @@ -141,9 +141,9 @@ class X86TTIImpl : public BasicTTIImplBase { unsigned AddressSpace, TTI::TargetCostKind CostKind, const Instruction *I = nullptr); - int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, - unsigned AddressSpace, - TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency); + int getMaskedMemoryOpCost( + unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency); int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, unsigned Alignment, TTI::TargetCostKind CostKind, diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 919f1c5fef4032..2f9b8f370f5300 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -5890,8 +5890,8 @@ unsigned LoopVectorizationCostModel::getConsecutiveMemOpCost(Instruction *I, const Align Alignment = getLoadStoreAlignment(I); unsigned Cost = 0; if (Legal->isMaskRequired(I)) - Cost += TTI.getMaskedMemoryOpCost(I->getOpcode(), VectorTy, - Alignment.value(), AS, CostKind); + Cost += TTI.getMaskedMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS, + CostKind); else Cost += TTI.getMemoryOpCost(I->getOpcode(), VectorTy, Alignment, AS, CostKind, I);