Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions llvm/include/llvm/Support/InstructionCost.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class InstructionCost {
State = Invalid;
}

static CostType getMaxValue() { return std::numeric_limits<CostType>::max(); }
static CostType getMinValue() { return std::numeric_limits<CostType>::min(); }
static constexpr CostType MaxValue = std::numeric_limits<CostType>::max();
static constexpr CostType MinValue = std::numeric_limits<CostType>::min();

public:
// A default constructed InstructionCost is a valid zero cost
Expand All @@ -69,8 +69,8 @@ class InstructionCost {
InstructionCost(CostState) = delete;
InstructionCost(CostType Val) : Value(Val), State(Valid) {}

static InstructionCost getMax() { return getMaxValue(); }
static InstructionCost getMin() { return getMinValue(); }
static InstructionCost getMax() { return MaxValue; }
static InstructionCost getMin() { return MinValue; }
static InstructionCost getInvalid(CostType Val = 0) {
InstructionCost Tmp(Val);
Tmp.setInvalid();
Expand Down Expand Up @@ -102,7 +102,7 @@ class InstructionCost {
// Saturating addition.
InstructionCost::CostType Result;
if (AddOverflow(Value, RHS.Value, Result))
Result = RHS.Value > 0 ? getMaxValue() : getMinValue();
Result = RHS.Value > 0 ? MaxValue : MinValue;

Value = Result;
return *this;
Expand All @@ -120,7 +120,7 @@ class InstructionCost {
// Saturating subtract.
InstructionCost::CostType Result;
if (SubOverflow(Value, RHS.Value, Result))
Result = RHS.Value > 0 ? getMinValue() : getMaxValue();
Result = RHS.Value > 0 ? MinValue : MaxValue;
Value = Result;
return *this;
}
Expand All @@ -138,9 +138,9 @@ class InstructionCost {
InstructionCost::CostType Result;
if (MulOverflow(Value, RHS.Value, Result)) {
if ((Value > 0 && RHS.Value > 0) || (Value < 0 && RHS.Value < 0))
Result = getMaxValue();
Result = MaxValue;
else
Result = getMinValue();
Result = MinValue;
}

Value = Result;
Expand Down