Put a heuristic in place to prevent GVN from falling into bad cases with massively complicated CFGs.
This speeds up a particular testcase from 12+ hours to 5 seconds with little perceptible loss of quality.
llvm-svn: 55391
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 272ad1b..42fbc786 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -862,6 +862,12 @@
DenseMap<BasicBlock*, Value*> deps;
MD.getNonLocalDependency(L, deps);
+ // If we had to process more than one hundred blocks to find the
+ // dependencies, this load isn't worth worrying about. Optimizing
+ // it will be too expensive.
+ if (deps.size() > 100)
+ return false;
+
DenseMap<BasicBlock*, Value*> repl;
// Filter out useless results (non-locals, etc)