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

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


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

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.)


>From 6f8234068ffd530f728344a64e6f1d7c5902ed41 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 24 Jan 2024 10:08:00 -0800
Subject: [PATCH] [DAGCombiner] Use SmallDenseMap (NFC)

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.)
---
 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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



More information about the llvm-commits mailing list