Index: lib/Analysis/TargetTransformInfo.cpp =================================================================== --- lib/Analysis/TargetTransformInfo.cpp +++ lib/Analysis/TargetTransformInfo.cpp @@ -584,6 +584,12 @@ return Cost; } +int TargetTransformInfo::getMemcpyCost(const Instruction *I) const { + int Cost = TTIImpl->getMemcpyCost(I); + assert(Cost >= 0 && "TTI should not produce negative costs!"); + return Cost; +} + int TargetTransformInfo::getArithmeticReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm) const { int Cost = TTIImpl->getArithmeticReductionCost(Opcode, Ty, IsPairwiseForm); Index: lib/Target/ARM/ARMTargetTransformInfo.h =================================================================== --- lib/Target/ARM/ARMTargetTransformInfo.h +++ lib/Target/ARM/ARMTargetTransformInfo.h @@ -161,6 +161,8 @@ int getAddressComputationCost(Type *Val, ScalarEvolution *SE, const SCEV *Ptr); + int getMemcpyCost(const Instruction *I); + int getArithmeticInstrCost( unsigned Opcode, Type *Ty, TTI::OperandValueKind Op1Info = TTI::OK_AnyValue, Index: lib/Target/ARM/ARMTargetTransformInfo.cpp =================================================================== --- lib/Target/ARM/ARMTargetTransformInfo.cpp +++ lib/Target/ARM/ARMTargetTransformInfo.cpp @@ -401,6 +401,25 @@ return 1; } +int ARMTTIImpl::getMemcpyCost(const Instruction *I) { + std::vector MemOps; + const Function *F = I->getParent()->getParent(); + getTLI()->findOptimalMemOpLowering(MemOps, + 100 /*Limit*/, + 32 /*Size*/, + 4 /*DstAlign*/, + 4 /*SrcAlign*/, + false /*IsMemset*/, + false /*ZeroMemset*/, + false /*MemcpyStrSrc*/, + false /*AllowOverlap*/, + 4 /*DstAS*/, + 4 /*SrcAS*/, + *F); + return MemOps.size() * 2; +} + + int ARMTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp) { if (Kind == TTI::SK_Broadcast) {