[llvm] 0e93801 - [RISCV] Speed up RISCVISAInfo::updateImplication.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 23:57:40 PDT 2024


Author: Craig Topper
Date: 2024-06-28T23:37:05-07:00
New Revision: 0e9380177092f0dfc1acf778aeb08d47623c4db3

URL: https://github.com/llvm/llvm-project/commit/0e9380177092f0dfc1acf778aeb08d47623c4db3
DIFF: https://github.com/llvm/llvm-project/commit/0e9380177092f0dfc1acf778aeb08d47623c4db3.diff

LOG: [RISCV] Speed up RISCVISAInfo::updateImplication.

We don't need to use a SmallSetVector to keep track of the worklist.
We only insert into the worklist if the extension is not already
in the Exts map. We immediately add it the Exts map at the same
time we add it to the worklist. If we encounter the extension again
it will already be in Exts so we won't try to add it to the worklist
again. We can just use a SmallVector for the Worklist.

Added: 
    

Modified: 
    llvm/lib/TargetParser/RISCVISAInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 8b3fba19fed38..2a6eceee45fca 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -840,9 +840,9 @@ void RISCVISAInfo::updateImplication() {
 
   // This loop may execute over 1 iteration since implication can be layered
   // Exits loop if no more implication is applied
-  SmallSetVector<StringRef, 16> WorkList;
+  SmallVector<StringRef, 16> WorkList;
   for (auto const &Ext : Exts)
-    WorkList.insert(Ext.first);
+    WorkList.push_back(Ext.first);
 
   while (!WorkList.empty()) {
     StringRef ExtName = WorkList.pop_back_val();
@@ -851,13 +851,11 @@ void RISCVISAInfo::updateImplication() {
     std::for_each(Range.first, Range.second,
                   [&](const ImpliedExtsEntry &Implied) {
                     const char *ImpliedExt = Implied.ImpliedExt;
-                    if (WorkList.count(ImpliedExt))
-                      return;
                     if (Exts.count(ImpliedExt))
                       return;
                     auto Version = findDefaultVersion(ImpliedExt);
                     addExtension(ImpliedExt, *Version);
-                    WorkList.insert(ImpliedExt);
+                    WorkList.push_back(ImpliedExt);
                   });
   }
 


        


More information about the llvm-commits mailing list