Skip to content

Commit 9388e42

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (#128631)
1 parent 791da3c commit 9388e42

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/lib/CodeGen/SelectOptimize.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,9 @@ void SelectOptimizeImpl::findProfitableSIGroupsInnerLoops(
978978
// cost of the most expensive instruction of the group.
979979
Scaled64 SelectCost = Scaled64::getZero(), BranchCost = Scaled64::getZero();
980980
for (SelectLike &SI : ASI.Selects) {
981-
SelectCost = std::max(SelectCost, InstCostMap[SI.getI()].PredCost);
982-
BranchCost = std::max(BranchCost, InstCostMap[SI.getI()].NonPredCost);
981+
const auto &ICM = InstCostMap[SI.getI()];
982+
SelectCost = std::max(SelectCost, ICM.PredCost);
983+
BranchCost = std::max(BranchCost, ICM.NonPredCost);
983984
}
984985
if (BranchCost < SelectCost) {
985986
OptimizationRemark OR(DEBUG_TYPE, "SelectOpti",
@@ -1327,8 +1328,8 @@ bool SelectOptimizeImpl::computeLoopCosts(
13271328
// BranchCost = PredictedPathCost + MispredictCost
13281329
// PredictedPathCost = TrueOpCost * TrueProb + FalseOpCost * FalseProb
13291330
// MispredictCost = max(MispredictPenalty, CondCost) * MispredictRate
1330-
if (SImap.contains(&I)) {
1331-
auto SI = SImap.at(&I);
1331+
if (auto It = SImap.find(&I); It != SImap.end()) {
1332+
auto SI = It->second;
13321333
const auto *SG = SGmap.at(&I);
13331334
Scaled64 TrueOpCost = SI.getOpCostOnBranch(true, InstCostMap, TTI);
13341335
Scaled64 FalseOpCost = SI.getOpCostOnBranch(false, InstCostMap, TTI);

0 commit comments

Comments
 (0)