aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SCCPSolver.cpp
diff options
context:
space:
mode:
authorTamás Danyluk <tdanyluk@google.com>2023-06-23 10:14:25 +0200
committerBenjamin Kramer <benny.kra@googlemail.com>2023-06-23 10:23:53 +0200
commit248b85344b0807a2be91b403837909a61204e730 (patch)
treec680d9016c3ce7762c6b22eb9a2ff4e59459567e /llvm/lib/Transforms/Utils/SCCPSolver.cpp
parent135e5bf8940f3d965c44e31eb4c94b8f8388a100 (diff)
downloadllvm-248b85344b0807a2be91b403837909a61204e730.zip
llvm-248b85344b0807a2be91b403837909a61204e730.tar.gz
llvm-248b85344b0807a2be91b403837909a61204e730.tar.bz2
[SCCPSolver] Speed up SCCPSolver by avoiding repeated work list elements
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
Diffstat (limited to 'llvm/lib/Transforms/Utils/SCCPSolver.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SCCPSolver.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 24d1a46..de3626a 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -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) {