[llvm] 1d3d3f4 - [DAG] SDPatternMatch::ReassociatableOpc_match - pull out repeated pattern count expression. NFC. (#135187)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 11 02:53:31 PDT 2025
Author: Simon Pilgrim
Date: 2025-04-11T10:53:28+01:00
New Revision: 1d3d3f404ed134697405078411b0bd690a68be0e
URL: https://github.com/llvm/llvm-project/commit/1d3d3f404ed134697405078411b0bd690a68be0e
DIFF: https://github.com/llvm/llvm-project/commit/1d3d3f404ed134697405078411b0bd690a68be0e.diff
LOG: [DAG] SDPatternMatch::ReassociatableOpc_match - pull out repeated pattern count expression. NFC. (#135187)
Minor tidyup to remove so much template noise.
CC @esan5
Added:
Modified:
llvm/include/llvm/CodeGen/SDPatternMatch.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/SDPatternMatch.h b/llvm/include/llvm/CodeGen/SDPatternMatch.h
index 4e1e4fdccfea5..9532be67c92e1 100644
--- a/llvm/include/llvm/CodeGen/SDPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/SDPatternMatch.h
@@ -1145,16 +1145,17 @@ template <typename... PatternTs> struct ReassociatableOpc_match {
template <typename MatchContext>
bool match(const MatchContext &Ctx, SDValue N) {
+ constexpr size_t NumPatterns = std::tuple_size_v<std::tuple<PatternTs...>>;
+
SmallVector<SDValue> Leaves;
collectLeaves(N, Leaves);
- if (Leaves.size() != std::tuple_size_v<std::tuple<PatternTs...>>)
+ if (Leaves.size() != NumPatterns)
return false;
// Matches[I][J] == true iff sd_context_match(Leaves[I], Ctx,
// std::get<J>(Patterns)) == true
- std::array<SmallBitVector, std::tuple_size_v<std::tuple<PatternTs...>>>
- Matches;
- for (size_t I = 0, N = Leaves.size(); I < N; I++) {
+ std::array<SmallBitVector, NumPatterns> Matches;
+ for (size_t I = 0; I != NumPatterns; I++) {
SmallVector<bool> MatchResults;
std::apply(
[&](auto &...P) {
@@ -1163,7 +1164,7 @@ template <typename... PatternTs> struct ReassociatableOpc_match {
Patterns);
}
- SmallBitVector Used(std::tuple_size_v<std::tuple<PatternTs...>>);
+ SmallBitVector Used(NumPatterns);
return reassociatableMatchHelper(Matches, Used);
}
More information about the llvm-commits
mailing list