[PATCH] D99502: [InstructionCost] Don't conflate Invalid costs with Unknown costs.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 29 06:25:00 PDT 2021


sdesmalen created this revision.
Herald added subscribers: kerbowa, hiraditya, nhaehnle, jvesely.
sdesmalen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We previously made a change to getUserCost to return a Invalid cost
when one of the TTI costs returned '-1' (meaning 'unknown' or
'infinitely expensive'). It makes no sense to say that:

  shufflevector <2 x i8> %x, <2 x i8> %y, <4 x i32> <i32 0, i32 1, i32 2, i32 3>

has an invalid cost. Perhaps the cost is not known, but the IR is valid
and can be code-generated. Invalid should only be used for IR that
cannot possibly be code-generated and where a cost is nonsensical.

With more passes now asserting that the cost must be valid, it is possible
that those assertions will fail for perfectly valid IR. An incomplete
cost-model probably shouldn't be a reason for the compiler to break.

It's better to consider these costs as 'very expensive' and ignore them
for other reasons. At some point, we should consider replacing -1 with
some other mechanism.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99502

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/lib/Analysis/CostModel.cpp
  llvm/test/Analysis/CostModel/AMDGPU/br.ll
  llvm/test/Analysis/CostModel/AMDGPU/shufflevector.ll
  llvm/test/Analysis/CostModel/ARM/shuffle.ll
  llvm/test/Analysis/CostModel/X86/shuffle-extract_subvector.ll
  llvm/test/Analysis/CostModel/X86/shuffle-insert_subvector.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99502.333842.patch
Type: text/x-patch
Size: 242123 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210329/96245381/attachment-0001.bin>


More information about the llvm-commits mailing list