[llvm] [DAGCombiner] Use SmallDenseMap (NFC) (PR #79681)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 23:59:29 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-selectiondag

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

The use of SmallDenseMap saves 0.48% of heap allocations during the
compilation of a large preprocessed file, namely X86ISelLowering.cpp,
for the X86 target.  During the experiment, the maximum size of
WorklistMap was 24 or less 74% of the time.  (Note that DenseMap has
the maximum occupancy rate of 3/4.)


---
Full diff: https://github.com/llvm/llvm-project/pull/79681.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 87184fe409eade..ab572c5eca7399 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -174,7 +174,7 @@ namespace {
     /// This is used to find and remove nodes from the worklist (by nulling
     /// them) when they are deleted from the underlying DAG. It relies on
     /// stable indices of nodes within the worklist.
-    DenseMap<SDNode *, unsigned> WorklistMap;
+    SmallDenseMap<SDNode *, unsigned, 32> WorklistMap;
 
     /// This records all nodes attempted to be added to the worklist since we
     /// considered a new worklist entry. As we keep do not add duplicate nodes

``````````

</details>


https://github.com/llvm/llvm-project/pull/79681


More information about the llvm-commits mailing list