[llvm-branch-commits] [llvm] TableGen: Keep the instregex prefix for patterns with a top-level ? (PR #235486)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Oct 25 09:42:41 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tablegen

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

instregex discarded a pattern's literal prefix, and ran the regex on
every instruction, if the pattern had a ? outside parentheses, as in
LDPS?Wi. A ? only makes the atom before it optional, and an atom
directly before it is already dropped from the prefix. Only a top-level
| makes the prefix unusable.

AArch64GenSubtargetInfo.inc tablegen run:

            Gigainstructions  Gigacycles      CPU seconds
  Before    44.6              18.8            5.7
  After     43.1 (-3.4%)      17.8 (-4.9%)    5.4 (-4.6%)

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/235486.diff


1 Files Affected:

- (modified) llvm/utils/TableGen/Common/CodeGenSchedule.cpp (+3-2) 


``````````diff
diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
index f412663a11663..5236982d12224 100644
--- a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
@@ -121,8 +121,9 @@ struct InstRegexOp : public SetTheory::Operator {
         }
       }
 
-      // Look for top-level | or ?. We cannot optimize them to binary search.
-      if (removeParens(Original).find_first_of("|?") != std::string::npos)
+      // Look for top-level |. We cannot optimize them to binary search. A ?
+      // only applies to the preceding atom, which is not part of the prefix.
+      if (removeParens(Original).find('|') != std::string::npos)
         FirstMeta = 0;
 
       std::optional<Regex> Regexpr;

``````````

</details>


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


More information about the llvm-branch-commits mailing list