[llvm] [AMDGPU] AMDGPUIGroupLP: Avoid repeating reachability checks in greedy algorithm (PR #182463)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 00:52:28 PST 2026
================
@@ -729,21 +728,36 @@ void PipelineSolver::greedyFind(
LLVM_DEBUG(dbgs() << "SGID # " << CandSGID << " has conflicting rule\n");
continue;
}
- TempCost = addEdges(SyncPipeline, CurrSU.first, CandSGID, AddedEdges);
+
+ std::list<std::pair<SUnit *, SUnit *>> TempEdges;
+ TempCost = addEdges(SyncPipeline, CurrSU.first, CandSGID, TempEdges);
LLVM_DEBUG(dbgs() << "Cost of Group " << TempCost << "\n");
+
if (TempCost < BestNodeCost || BestNodeCost == -1) {
+ BestEdges = TempEdges;
BestGroup = Match;
BestNodeCost = TempCost;
BestGroupID = CandSGID;
+
+ if (BestNodeCost == 0)
+ break;
}
- removeEdges(AddedEdges);
- if (BestNodeCost == 0)
- break;
+
+ removeEdges(TempEdges);
}
if (BestGroupID != -1) {
BestGroup->add(*CurrSU.first);
- addEdges(SyncPipeline, CurrSU.first, BestGroupID, AddedEdges);
+ if (AddedEdges.empty())
+ AddedEdges = BestEdges;
+ else
+ AddedEdges.splice(std::prev(AddedEdges.cend()), BestEdges);
+ std::for_each(BestEdges.begin(), BestEdges.end(),
----------------
arsenm wrote:
Avoid std::for_each for normal code
https://github.com/llvm/llvm-project/pull/182463
More information about the llvm-commits
mailing list