[all-commits] [llvm/llvm-project] 41b605: [InstructionCost] Add saturation support.

sdesmalen-arm via All-commits all-commits at lists.llvm.org
Sat Jul 10 03:56:59 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 41b6057641720e6ba7d4b6c7c2905f2870a885d3
      https://github.com/llvm/llvm-project/commit/41b6057641720e6ba7d4b6c7c2905f2870a885d3
  Author: Sander de Smalen <sander.desmalen at arm.com>
  Date:   2021-07-10 (Sat, 10 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Support/InstructionCost.h
    M llvm/unittests/Support/InstructionCostTest.cpp

  Log Message:
  -----------
  [InstructionCost] Add saturation support.

This patch makes the operations on InstructionCost saturate, so that when
costs are accumulated they saturate to <max value>.

One of the compelling reasons for wanting to have saturation support
is because in various places, arbitrary values are used to represent
a 'high' cost, but when accumulating the cost of some set of operations
or a loop, overflow is not taken into account, which may lead to unexpected
results. By defining the operations to saturate, we can express the cost
of something 'very expensive' as InstructionCost::getMax().

Reviewed By: kparzysz, dmgreen

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




More information about the All-commits mailing list