[llvm] [GlobalISel] Optimize ULEB128 usage (PR #90565)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 05:50:25 PDT 2024


================
@@ -713,6 +713,27 @@ class GIMatchTableExecutor {
     memcpy(&Ret, MatchTable, sizeof(Ret));
     return Ret;
   }
+
+public:
+  // Faster ULEB128 decoder tailored for the Match Table Executor.
+  //
+  // - Arguments are fixed to avoid mid-function checks.
+  // - Unchecked execution, assumes no error.
+  // - Fast common case handling (1 byte values).
+  LLVM_ATTRIBUTE_ALWAYS_INLINE static uint64_t
+  fastDecodeULEB128(const uint8_t *__restrict MatchTable,
----------------
Pierre-vh wrote:

It's very small: https://godbolt.org/z/f9341f1Ea
Though I sometimes wonder why we don't use restrict in more places. Seems like a useful thing in some cases.

I'd say let's do without it for now and start a discussion on Discourse? Using restrict would set a precedent and I think it's better to get community approval before using that in non-runtime code

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


More information about the llvm-commits mailing list