[PATCH] D30651: [InlineCost, -Oz] Don't take into account the penalty of a fast call of frequently used functions

Evgeny Astigeevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 14:43:37 PST 2017


eastig added a comment.

In https://reviews.llvm.org/D30651#697984, @efriedma wrote:

> > Should we have a check of inter-iteration dependencies in CallAnalyzer::visitGetElementPtr?
>
> The problem isn't really inter-iteration dependencies, exactly... it's that the computation which declares a GEP "free" (see getGEPCost in TargetTransformInfoImpl.h) isn't paying attention to the instructions which use the GEP.  A GEP can only be free if we can fold the addressing mode into a load or store instruction.


'getGEPCost' is not called. Execution ends here in InlineCost.cpp because an offset is a constant:

  439	  if (IsGEPOffsetConstant(I)) {
  440	    if (SROACandidate)
  441	      SROAArgValues[&I] = SROAArg;
  442	
  443	    // Constant GEPs are modeled as free.
  444	    return true;
  445	  }

I guess if it was not a loop GEP would have been folded into a load/store instruction. Anyway the cost calculation for GEP is not correct.
Maybe instead of 'return true' it should be 'return isGEPFree(I);'. Then TTI::getGEPCost would return it is not free.

> Not sure how relevant that is in practice, though.

Do you mean the IR code I provided? This is what a naive memcopy function is translated into.


https://reviews.llvm.org/D30651





More information about the llvm-commits mailing list