[llvm] 1c1310d - [SelectionDAG] Use a simpler version of decodeSLEB128 in GetSignedVBR to improve compile time. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 31 13:02:58 PST 2025


Author: Craig Topper
Date: 2025-12-31T13:02:42-08:00
New Revision: 1c1310d02231eff75c96203eefe9145e5cabdd20

URL: https://github.com/llvm/llvm-project/commit/1c1310d02231eff75c96203eefe9145e5cabdd20
DIFF: https://github.com/llvm/llvm-project/commit/1c1310d02231eff75c96203eefe9145e5cabdd20.diff

LOG: [SelectionDAG] Use a simpler version of decodeSLEB128 in GetSignedVBR to improve compile time. NFC

This reduces a compile time regression after 7f780046e2 seen here
https://llvm-compile-time-tracker.com/compare.php?from=01e75e2eafcea00c448e289154d8adeecc1c6c3a&to=7f780046e2ae79218dd6abc2d008c1a9eeddedc7&stat=instructions:u

decodeSLEB128 has some code to check for errors that we don't need.
Writing a simpler version seems to recover most of the regression.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 5bee87bb52322..91c4a37d9885c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -96,7 +96,6 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/KnownBits.h"
-#include "llvm/Support/LEB128.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
@@ -2722,9 +2721,18 @@ GetVBR(uint64_t Val, const uint8_t *MatcherTable, unsigned &Idx) {
 
 LLVM_ATTRIBUTE_ALWAYS_INLINE static int64_t
 GetSignedVBR(const unsigned char *MatcherTable, unsigned &Idx) {
-  unsigned Len;
-  int64_t Val = decodeSLEB128(&MatcherTable[Idx], &Len);
-  Idx += Len;
+  int64_t Val = 0;
+  unsigned Shift = 0;
+  uint64_t NextBits;
+  do {
+    NextBits = MatcherTable[Idx++];
+    Val |= (NextBits & 127) << Shift;
+    Shift += 7;
+  } while (NextBits & 128);
+
+  if (Shift < 64 && (NextBits & 0x40))
+    Val |= UINT64_MAX << Shift;
+
   return Val;
 }
 


        


More information about the llvm-commits mailing list