[PATCH] D91174: [Analysis] Introduce a new InstructionCost class

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 08:43:00 PST 2020


david-arm created this revision.
david-arm added reviewers: sdesmalen, lattner, ctetreau, SjoerdMeijer, CarolineConcatto.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya, mgorny.
Herald added a project: LLVM.
david-arm requested review of this revision.

This is the first in a series of patches that attempts to migrate
existing cost instructions to return a new InstructionCost class
in place of a simple integer. This new class is intended to be
as light-weight and simple as possible, with a full range of
arithmetic and comparison operators that largely mirror the same
sets of operations on basic types, such as integers. The main
advantage to using an InstructionCost is that it can encode a
particular cost state in addition to a value. The initial
implementation only has two states - Normal and Invalid - but these
could be expanded over time if necessary. An invalid state can
be used to represent an unknown cost or an instruction that is
prohibitively expensive.

This patch adds the new class and changes the getInstructionCost
interface to return the new class. Other cost functions, such as
getUserCost, etc., will be migrated in future patches as I believe
this to be less disruptive. One benefit of this new class is that
it provides a way to unify many of the magic costs in the codebase
where the cost is set to a deliberately high number to prevent
optimisations taking place, e.g. vectorization. It also provides
a route to represent the extremely high, and unknown, cost of
scalarization of scalable vectors, which is not currently supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91174

Files:
  llvm/include/llvm/Analysis/InstructionCost.h
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/Analysis/CostModel.cpp
  llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/Transforms/IPO/HotColdSplitting.cpp
  llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/unittests/Analysis/CMakeLists.txt
  llvm/unittests/Analysis/InstructionCostTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91174.304202.patch
Type: text/x-patch
Size: 18914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201110/9e3a0550/attachment.bin>


More information about the llvm-commits mailing list