[llvm] 248b853 - [SCCPSolver] Speed up SCCPSolver by avoiding repeated work list elements

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 01:24:03 PDT 2023


Author: Tamás Danyluk
Date: 2023-06-23T10:23:53+02:00
New Revision: 248b85344b0807a2be91b403837909a61204e730

URL: https://github.com/llvm/llvm-project/commit/248b85344b0807a2be91b403837909a61204e730
DIFF: https://github.com/llvm/llvm-project/commit/248b85344b0807a2be91b403837909a61204e730.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SCCPSolver.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 24d1a46cfd40f..de3626a24212c 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) {


        


More information about the llvm-commits mailing list