diff options
author | David Green <david.green@arm.com> | 2025-04-23 07:46:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-23 07:46:27 +0100 |
commit | 98b6f8dc699d789d834e5b6d810ed217f560aad0 (patch) | |
tree | 2e6a97dca2bcd2f2376e2d127a819105200ee9e7 /llvm/lib/CodeGen/SelectOptimize.cpp | |
parent | 665914fea1433409015a87fef2837218bcd21460 (diff) | |
download | llvm-98b6f8dc699d789d834e5b6d810ed217f560aad0.zip llvm-98b6f8dc699d789d834e5b6d810ed217f560aad0.tar.gz llvm-98b6f8dc699d789d834e5b6d810ed217f560aad0.tar.bz2 |
[CostModel] Remove optional from InstructionCost::getValue() (#135596)
InstructionCost is already an optional value, containing an Invalid
state that can be checked with isValid(). There is little point in
returning another optional from getValue(). Most uses do not make use of
it being a std::optional, dereferencing the value directly (either
isValid has been checked previously or the Cost is assumed to be valid).
The one case that does in AMDGPU used value_or which has been replaced
by a isValid() check.
Diffstat (limited to 'llvm/lib/CodeGen/SelectOptimize.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectOptimize.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp index 00148b0..13ed8f2 100644 --- a/llvm/lib/CodeGen/SelectOptimize.cpp +++ b/llvm/lib/CodeGen/SelectOptimize.cpp @@ -206,7 +206,7 @@ public: getI()->getOpcode(), I->getType(), TargetTransformInfo::TCK_Latency, {TargetTransformInfo::OK_AnyValue, TargetTransformInfo::OP_None}, {TTI::OK_UniformConstantValue, TTI::OP_PowerOf2}); - auto TotalCost = Scaled64::get(*Cost.getValue()); + auto TotalCost = Scaled64::get(Cost.getValue()); if (auto *OpI = dyn_cast<Instruction>(I->getOperand(1 - CondIdx))) { auto It = InstCostMap.find(OpI); if (It != InstCostMap.end()) @@ -1380,8 +1380,8 @@ std::optional<uint64_t> SelectOptimizeImpl::computeInstCost(const Instruction *I) { InstructionCost ICost = TTI->getInstructionCost(I, TargetTransformInfo::TCK_Latency); - if (auto OC = ICost.getValue()) - return std::optional<uint64_t>(*OC); + if (ICost.isValid()) + return std::optional<uint64_t>(ICost.getValue()); return std::nullopt; } |