[llvm-branch-commits] [llvm] TableGen: Keep the instregex prefix for patterns with a top-level ? (PR #235486)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Oct 25 09:42:04 PDT 2026
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/235486
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 at 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>
>From 2bdf62d296bbf4508a903a85308eb89766795e44 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 22 Oct 2026 17:50:25 -0700
Subject: [PATCH] TableGen: Keep the instregex prefix for patterns with a
top-level ?
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 at anthropic.com>
---
llvm/utils/TableGen/Common/CodeGenSchedule.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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;
More information about the llvm-branch-commits
mailing list