Skip to content

Commit 698c1c8

Browse files
committed
Remove getValueOr - move it inline
1 parent d747677 commit 698c1c8

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

llvm/include/llvm/Support/InstructionCost.h

-5
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ class InstructionCost {
8787
assert(isValid());
8888
return Value;
8989
}
90-
CostType getValueOr(CostType Alt) const {
91-
if (!isValid())
92-
return Alt;
93-
return Value;
94-
}
9590

9691
/// For all of the arithmetic operators provided here any invalid state is
9792
/// perpetuated and cannot be removed. Once a cost becomes invalid it stays

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ static CostType calculateFunctionCosts(GetTTIFn GetTTI, Module &M,
205205
TTI.getInstructionCost(&I, TargetTransformInfo::TCK_CodeSize);
206206
assert(Cost != InstructionCost::getMax());
207207
// Assume expensive if we can't tell the cost of an instruction.
208-
CostType CostVal = Cost.getValueOr(TargetTransformInfo::TCC_Expensive);
208+
CostType CostVal = Cost.isValid() ? Cost.getValue()
209+
: TargetTransformInfo::TCC_Expensive;
209210
assert((FnCost + CostVal) >= FnCost && "Overflow!");
210211
FnCost += CostVal;
211212
}

llvm/unittests/Support/InstructionCostTest.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ TEST_F(CostTest, Operators) {
7171

7272
// Test value extraction
7373
EXPECT_EQ(VThree.getValue(), 3);
74-
EXPECT_EQ(IThreeA.getValueOr(10), 10);
7574

7675
EXPECT_EQ(std::min(VThree, VNegTwo), -2);
7776
EXPECT_EQ(std::max(VThree, VSix), 6);

0 commit comments

Comments
 (0)