[PATCH] [TTI/CostModel] improve TTI::getGEPCost and use it in CostModel::getInstructionCost

Jingyue Wu jingyue at google.com
Sun May 17 22:14:50 PDT 2015


Hi chandlerc, hfinkel,

This patch updates TargetTransformInfoImplCRTPBase::getGEPCost to consider
addressing modes. It now returns TCC_Free when the GEP can be completely folded
to an addresing mode.

I started this patch as I refactored SLSR. Function isGEPFoldable looks common
and is indeed used by some WIP of mine. So I extracted that logic to getGEPCost.

Furthermore, I noticed getGEPCost wasn't directly tested anywhere. The best
testing bed seems CostModel, but its getInstructionCost method invokes
getAddressComputationCost for GEPs which provides very coarse estimation. So
this patch also makes getInstructionCost call the updated getGEPCost for GEPs.
This change inevitably breaks some tests because the cost model changes, but
nothing looks seriously wrong -- if we believe the new cost model is the right
way to go, these tests should be updated.

This patch is not perfect yet -- the comments in some tests need to be updated.
I want to know whether this is a right approach before fixing those details.

http://reviews.llvm.org/D9819

Files:
  include/llvm/Analysis/TargetTransformInfo.h
  include/llvm/Analysis/TargetTransformInfoImpl.h
  lib/Analysis/CostModel.cpp
  lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
  test/Analysis/CostModel/ARM/gep.ll
  test/Analysis/CostModel/no_info.ll
  test/Transforms/LoopVectorize/X86/metadata-enable.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9819.25943.patch
Type: text/x-patch
Size: 15270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150518/a5f039a0/attachment.bin>


More information about the llvm-commits mailing list