Skip to content

Commit

Permalink
[SCCPSolver] Speed up SCCPSolver by avoiding repeated work list elements
Browse files Browse the repository at this point in the history
If a value is already the last element of the worklist, then I think that we don't have to add it again, it is not needed to process it repeatedly.

For some long Triton-generated LLVM IR, this can cause a ~100x speedup.

Differential Revision: https://reviews.llvm.org/D153561
  • Loading branch information
tdanyluk authored and d0k committed Jun 23, 2023
1 parent 135e5bf commit 248b853
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions llvm/lib/Transforms/Utils/SCCPSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,9 +838,13 @@ bool SCCPInstVisitor::markBlockExecutable(BasicBlock *BB) {
}

void SCCPInstVisitor::pushToWorkList(ValueLatticeElement &IV, Value *V) {
if (IV.isOverdefined())
return OverdefinedInstWorkList.push_back(V);
InstWorkList.push_back(V);
if (IV.isOverdefined()) {
if (OverdefinedInstWorkList.empty() || OverdefinedInstWorkList.back() != V)
OverdefinedInstWorkList.push_back(V);
return;
}
if (InstWorkList.empty() || InstWorkList.back() != V)
InstWorkList.push_back(V);
}

void SCCPInstVisitor::pushToWorkListMsg(ValueLatticeElement &IV, Value *V) {
Expand Down

0 comments on commit 248b853

Please sign in to comment.