[llvm] [NFC][MachineLICM] Use SmallDenseSet instead of SmallSet (PR #95201)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 00:09:22 PDT 2024


https://github.com/Pierre-vh created https://github.com/llvm/llvm-project/pull/95201

All values are small so no reason to ever use SmallSet really. In large programs we'll end up using std::set which is extremely slow compared to DenseSet. This brings a decent speedup to the pass in large programs.

>From 432ec88ec392e00782e2e165e9175581ed4771d3 Mon Sep 17 00:00:00 2001
From: pvanhout <pierre.vanhoutryve at amd.com>
Date: Wed, 12 Jun 2024 08:28:44 +0200
Subject: [PATCH] [NFC][MachineLICM] Use SmallDenseSet instead of SmallSet

All values are small so no reason to ever use SmallSet really. In large programs we'll end up using std::set which is extremely slow compared to DenseSet. This brings a decent speedup to the pass in large programs.
---
 llvm/lib/CodeGen/MachineLICM.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index edf8988512c78..6c5170e918e00 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -155,7 +155,7 @@ namespace {
     }
 
     // Track 'estimated' register pressure.
-    SmallSet<Register, 32> RegSeen;
+    SmallDenseSet<Register> RegSeen;
     SmallVector<unsigned, 8> RegPressure;
 
     // Register pressure "limit" per register pressure set. If the pressure
@@ -224,7 +224,7 @@ namespace {
                      MachineBasicBlock *CurPreheader);
 
     void ProcessMI(MachineInstr *MI, BitVector &RUDefs, BitVector &RUClobbers,
-                   SmallSet<int, 32> &StoredFIs,
+                   SmallDenseSet<int> &StoredFIs,
                    SmallVectorImpl<CandidateInfo> &Candidates,
                    MachineLoop *CurLoop);
 
@@ -464,7 +464,7 @@ static void applyBitsNotInRegMaskToRegUnitsMask(const TargetRegisterInfo &TRI,
 /// gather register def and frame object update information.
 void MachineLICMBase::ProcessMI(MachineInstr *MI, BitVector &RUDefs,
                                 BitVector &RUClobbers,
-                                SmallSet<int, 32> &StoredFIs,
+                                SmallDenseSet<int> &StoredFIs,
                                 SmallVectorImpl<CandidateInfo> &Candidates,
                                 MachineLoop *CurLoop) {
   bool RuledOut = false;
@@ -568,7 +568,7 @@ void MachineLICMBase::HoistRegionPostRA(MachineLoop *CurLoop,
   BitVector RUClobbers(NumRegUnits); // RUs defined more than once.
 
   SmallVector<CandidateInfo, 32> Candidates;
-  SmallSet<int, 32> StoredFIs;
+  SmallDenseSet<int> StoredFIs;
 
   // Walk the entire region, count number of defs for each register, and
   // collect potential LICM candidates.



More information about the llvm-commits mailing list