[all-commits] [llvm/llvm-project] 4ca860: [InstructionCost] Don't conflate Invalid costs wit...

sdesmalen-arm via All-commits all-commits at lists.llvm.org
Tue Mar 30 01:31:04 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4ca860742d5e0dd8ba77e0cbda9653ba46aaf738
      https://github.com/llvm/llvm-project/commit/4ca860742d5e0dd8ba77e0cbda9653ba46aaf738
  Author: Sander de Smalen <sander.desmalen at arm.com>
  Date:   2021-03-30 (Tue, 30 Mar 2021)

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

  Log Message:
  -----------
  [InstructionCost] Don't conflate Invalid costs with Unknown costs.

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.

Reviewed By: paulwalker-arm, dmgreen

Differential Revision: https://reviews.llvm.org/D99502




More information about the All-commits mailing list