diff options
author | Elena Demikhovsky <elena.demikhovsky@intel.com> | 2017-08-20 12:34:29 +0000 |
---|---|---|
committer | Elena Demikhovsky <elena.demikhovsky@intel.com> | 2017-08-20 12:34:29 +0000 |
commit | f58f838495200ed71596d260f7c6e25d1b080fcb (patch) | |
tree | b3281f12a5f31258e3e4735fb7b9fa7ad5354eaf /llvm/lib/Target/X86/X86TargetTransformInfo.cpp | |
parent | d196930799224f906ba4c5d3c64bafa1cad8d156 (diff) | |
download | bcm5719-llvm-f58f838495200ed71596d260f7c6e25d1b080fcb.tar.gz bcm5719-llvm-f58f838495200ed71596d260f7c6e25d1b080fcb.zip |
Changed basic cost of store operation on X86
Store operation takes 2 UOps on X86 processors. The exact cost calculation affects several optimization passes including loop unroling.
This change compensates performance degradation caused by https://reviews.llvm.org/D34458 and shows improvements on some benchmarks.
Differential Revision: https://reviews.llvm.org/D35888
llvm-svn: 311285
Diffstat (limited to 'llvm/lib/Target/X86/X86TargetTransformInfo.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86TargetTransformInfo.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index 2f44d610840..6c73a6875c8 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -2113,6 +2113,21 @@ int X86TTIImpl::getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, return X86TTIImpl::getIntImmCost(Imm, Ty); } +unsigned X86TTIImpl::getUserCost(const User *U, + ArrayRef<const Value *> Operands) { + if (isa<StoreInst>(U)) { + Value *Ptr = U->getOperand(1); + // Store instruction with index and scale costs 2 Uops. + // Check the preceding GEP to identify non-const indices. + if (auto GEP = dyn_cast<GetElementPtrInst>(Ptr)) { + if (!all_of(GEP->indices(), [](Value *V) { return isa<Constant>(V); })) + return TTI::TCC_Basic * 2; + } + return TTI::TCC_Basic; + } + return BaseT::getUserCost(U, Operands); +} + // Return an average cost of Gather / Scatter instruction, maybe improved later int X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy, Value *Ptr, unsigned Alignment, unsigned AddressSpace) { |