Skip to content

Commit 1d3d3f4

Browse files
authored
[DAG] SDPatternMatch::ReassociatableOpc_match - pull out repeated pattern count expression. NFC. (llvm#135187)
Minor tidyup to remove so much template noise. CC @Esan5
1 parent b0b723a commit 1d3d3f4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/include/llvm/CodeGen/SDPatternMatch.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,16 +1145,17 @@ template <typename... PatternTs> struct ReassociatableOpc_match {
11451145

11461146
template <typename MatchContext>
11471147
bool match(const MatchContext &Ctx, SDValue N) {
1148+
constexpr size_t NumPatterns = std::tuple_size_v<std::tuple<PatternTs...>>;
1149+
11481150
SmallVector<SDValue> Leaves;
11491151
collectLeaves(N, Leaves);
1150-
if (Leaves.size() != std::tuple_size_v<std::tuple<PatternTs...>>)
1152+
if (Leaves.size() != NumPatterns)
11511153
return false;
11521154

11531155
// Matches[I][J] == true iff sd_context_match(Leaves[I], Ctx,
11541156
// std::get<J>(Patterns)) == true
1155-
std::array<SmallBitVector, std::tuple_size_v<std::tuple<PatternTs...>>>
1156-
Matches;
1157-
for (size_t I = 0, N = Leaves.size(); I < N; I++) {
1157+
std::array<SmallBitVector, NumPatterns> Matches;
1158+
for (size_t I = 0; I != NumPatterns; I++) {
11581159
SmallVector<bool> MatchResults;
11591160
std::apply(
11601161
[&](auto &...P) {
@@ -1163,7 +1164,7 @@ template <typename... PatternTs> struct ReassociatableOpc_match {
11631164
Patterns);
11641165
}
11651166

1166-
SmallBitVector Used(std::tuple_size_v<std::tuple<PatternTs...>>);
1167+
SmallBitVector Used(NumPatterns);
11671168
return reassociatableMatchHelper(Matches, Used);
11681169
}
11691170

0 commit comments

Comments
 (0)