[llvm-branch-commits] [llvm] TableGen: Test register sub-classes with the member bit vectors (PR #234801)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 22 16:47:23 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tablegen

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

computeSubClasses checks whether one register class contains another
for most pairs of classes, by walking both sorted member lists. That
reads every member register, which is slow for AMDGPU's 913 classes.
Each class already has a bit vector of its members, so compare those
instead.

AMDGPU tablegen runs that build the register bank:

            Gigainstructions  Gigacycles     CPU seconds
  Before    596               365            117
  After     577 (-3.1%)       353 (-3.4%)    112 (-3.7%)

Co-authored-by: Claude Opus 5.5 <noreply@<!-- -->anthropic.com>

---

<sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>

---
Full diff: https://github.com/llvm/llvm-project/pull/234801.diff


2 Files Affected:

- (modified) llvm/utils/TableGen/Common/CodeGenRegisters.cpp (+4-1) 
- (modified) llvm/utils/TableGen/Common/CodeGenRegisters.h (+3) 


``````````diff
diff --git a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
index be3c81128e50f..1674db63afb72 100644
--- a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
@@ -987,8 +987,11 @@ bool CodeGenRegisterClass::Key::operator<(
 //
 static bool testSubClass(const CodeGenRegisterClass *A,
                          const CodeGenRegisterClass *B) {
+  // Compare the member bit vectors rather than the member lists, which would
+  // load every register.
   return A->RSI.isSubClassOf(B->RSI) &&
-         llvm::includes(A->getMembers(), B->getMembers(), deref<std::less<>>());
+         B->getMembers().size() <= A->getMembers().size() &&
+         !B->getMemberBV().test(A->getMemberBV());
 }
 
 /// Sorting predicate for register classes.  This provides a topological
diff --git a/llvm/utils/TableGen/Common/CodeGenRegisters.h b/llvm/utils/TableGen/Common/CodeGenRegisters.h
index b5cfa8e600aa8..8bc3447453acc 100644
--- a/llvm/utils/TableGen/Common/CodeGenRegisters.h
+++ b/llvm/utils/TableGen/Common/CodeGenRegisters.h
@@ -560,6 +560,9 @@ class CodeGenRegisterClass {
   // getOrder(0).
   const CodeGenRegister::Vec &getMembers() const { return Members; }
 
+  // The members as a bit vector indexed by CodeGenRegBank::getRegIndex().
+  const BitVector &getMemberBV() const { return MemberBV; }
+
   // Get a bit vector of TopoSigs of registers with super registers in this
   // register class.
   const BitVector &getRegsWithSuperRegsTopoSigs() const {

``````````

</details>


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


More information about the llvm-branch-commits mailing list