[PATCH] D140097: [MemDep] Reduce block limit

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 05:37:05 PST 2022


nikic created this revision.
nikic added reviewers: asbirlea, fhahn.
Herald added subscribers: kmitropoulou, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The non-local MemDep analysis has a limit on the number of blocks it will scan trying to find dependencies. The current limit of 1000 is ridiculously high, especially when we consider that each block scan can also visit up to 100 instructions. In degenerate cases (where we actually scan that many blocks) MemDep/GVN dominate overall compile-time, for little benefit.

This patch reduces the limit to 100, which is probably still too large, but at least avoids some of the more catastrophic cases. (For comparison, MSSA clobber walks consider up to 100 MemoryDefs/MemoryPhis, rather than 100 blocks * 100 instructions, but these limits aren't directly comparable.)

The impact on relevant GVN statistics from llvm-test-suite is as follows:

                     |   Old |   New |  Diff
  gvn.NumGVNLoad     | 19298 | 19246 | -0.27%
  gvn.NumPRELoad     | 13983 | 13963 | -0.14%
  gvn.NumPRELoopLoad |   703 |   702 | -0.14%

The impact on compile-time is as follows: http://llvm-compile-time-tracker.com/compare.php?from=92619956eb27ef08dd24045307593fc3d7f78db0&to=675a7cdab6ef84b994b00b2d0e2f146634056c9d&stat=instructions:u

          | geomean
  O3      |  -0.30%
  ThinLTO |  -0.52%
  LTO-g   |  -0.95%

In addition to the average improvement, this also fixes some degenerate cases. For example, libclamav_htmlnorm.c improves by 13-23%, depending on build configuration.

I know that we were kind of hoping that this issue would resolve itself in time, either by a switch to NewGVN or use of MSSA in GVN. But I think we should still address this in the meantime. Additionally, a switch to an MSSA-based implementation will effectively be doing this as well, in a roundabout way (by dint of MSSA having lower cutoffs than MDA).


https://reviews.llvm.org/D140097

Files:
  llvm/lib/Analysis/MemoryDependenceAnalysis.cpp


Index: llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -76,9 +76,9 @@
              "dependency analysis (default = 100)"));
 
 static cl::opt<unsigned>
-    BlockNumberLimit("memdep-block-number-limit", cl::Hidden, cl::init(1000),
+    BlockNumberLimit("memdep-block-number-limit", cl::Hidden, cl::init(100),
                      cl::desc("The number of blocks to scan during memory "
-                              "dependency analysis (default = 1000)"));
+                              "dependency analysis (default = 100)"));
 
 // Limit on the number of memdep results to process.
 static const unsigned int NumResultsLimit = 100;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140097.483137.patch
Type: text/x-patch
Size: 810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221215/b5da9273/attachment.bin>


More information about the llvm-commits mailing list