[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
Loading
Please sign in to comment