[llvm] [SCCP] Improve worklist management (PR #146321)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 30 04:06:25 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()))
----------------
dtcxzyw wrote:
```suggestion
if (BBVisited.contains(I->getParent()))
```
https://github.com/llvm/llvm-project/pull/146321
More information about the llvm-commits
mailing list