diff options
author | Kazu Hirata <kazu@google.com> | 2025-02-25 09:02:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-25 09:02:19 -0800 |
commit | 9388e42a3c67a4399bbc3a427077ea95bac31323 (patch) | |
tree | eec7dfe2c3d8661c94a6ba75a18f6dfa826e3801 /llvm/lib/CodeGen/SelectOptimize.cpp | |
parent | 791da3c5c2efc13e952ec4fe041e88428e4a331a (diff) | |
download | llvm-9388e42a3c67a4399bbc3a427077ea95bac31323.zip llvm-9388e42a3c67a4399bbc3a427077ea95bac31323.tar.gz llvm-9388e42a3c67a4399bbc3a427077ea95bac31323.tar.bz2 |
[CodeGen] Avoid repeated hash lookups (NFC) (#128631)
Diffstat (limited to 'llvm/lib/CodeGen/SelectOptimize.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectOptimize.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp index 9c8dcac..b35f765 100644 --- a/llvm/lib/CodeGen/SelectOptimize.cpp +++ b/llvm/lib/CodeGen/SelectOptimize.cpp @@ -978,8 +978,9 @@ void SelectOptimizeImpl::findProfitableSIGroupsInnerLoops( // cost of the most expensive instruction of the group. Scaled64 SelectCost = Scaled64::getZero(), BranchCost = Scaled64::getZero(); for (SelectLike &SI : ASI.Selects) { - SelectCost = std::max(SelectCost, InstCostMap[SI.getI()].PredCost); - BranchCost = std::max(BranchCost, InstCostMap[SI.getI()].NonPredCost); + const auto &ICM = InstCostMap[SI.getI()]; + SelectCost = std::max(SelectCost, ICM.PredCost); + BranchCost = std::max(BranchCost, ICM.NonPredCost); } if (BranchCost < SelectCost) { OptimizationRemark OR(DEBUG_TYPE, "SelectOpti", @@ -1327,8 +1328,8 @@ bool SelectOptimizeImpl::computeLoopCosts( // BranchCost = PredictedPathCost + MispredictCost // PredictedPathCost = TrueOpCost * TrueProb + FalseOpCost * FalseProb // MispredictCost = max(MispredictPenalty, CondCost) * MispredictRate - if (SImap.contains(&I)) { - auto SI = SImap.at(&I); + if (auto It = SImap.find(&I); It != SImap.end()) { + auto SI = It->second; const auto *SG = SGmap.at(&I); Scaled64 TrueOpCost = SI.getOpCostOnBranch(true, InstCostMap, TTI); Scaled64 FalseOpCost = SI.getOpCostOnBranch(false, InstCostMap, TTI); |