[llvm] [SCCP] Improve worklist management (PR #146321)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 30 05:37:24 PDT 2025
================
@@ -985,27 +953,49 @@ bool SCCPInstVisitor::markBlockExecutable(BasicBlock *BB) {
return true;
}
-void SCCPInstVisitor::pushToWorkList(ValueLatticeElement &IV, Value *V) {
- if (IV.isOverdefined()) {
- if (OverdefinedInstWorkList.empty() || OverdefinedInstWorkList.back() != V)
- OverdefinedInstWorkList.push_back(V);
+void SCCPInstVisitor::pushToWorkList(Instruction *I) {
+ // If we're currently visiting a block, do not push any instructions in the
+ // same blocks that are after the current one, as they will be visited
+ // anyway. We do have to push updates to earlier instructions (e.g. phi
+ // nodes or loads of tracked globals).
+ if (CurI && I->getParent() == CurI->getParent() && !I->comesBefore(CurI))
return;
+ // Only push instructions in already visited blocks. Otherwise we'll handle
+ // it when we visit the block for the first time.
+ if (BBVisited.count(I->getParent()))
+ InstWorkList.insert(I);
+}
+
+void SCCPInstVisitor::pushUsersToWorkList(Value *V) {
+ for (User *U : V->users())
+ if (auto *UI = dyn_cast<Instruction>(U))
+ pushToWorkList(UI);
----------------
nikic wrote:
I see a negative effects from using a separate overdefined worklist: https://llvm-compile-time-tracker.com/compare.php?from=8f1fac228d7ebbddd8a2aa00e47ee3f5712db125&to=715c96e212becce2bb05cffd7a468891547ef992&stat=instructions:u
https://github.com/llvm/llvm-project/pull/146321
More information about the llvm-commits
mailing list