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 struct ReassociatableOpc_match { template bool match(const MatchContext &Ctx, SDValue N) { + constexpr size_t NumPatterns = std::tuple_size_v>; + SmallVector Leaves; collectLeaves(N, Leaves); - if (Leaves.size() != std::tuple_size_v>) + if (Leaves.size() != NumPatterns) return false; // Matches[I][J] == true iff sd_context_match(Leaves[I], Ctx, // std::get(Patterns)) == true - std::array>> - Matches; - for (size_t I = 0, N = Leaves.size(); I < N; I++) { + std::array Matches; + for (size_t I = 0; I != NumPatterns; I++) { SmallVector MatchResults; std::apply( [&](auto &...P) { @@ -1163,7 +1164,7 @@ template struct ReassociatableOpc_match { Patterns); } - SmallBitVector Used(std::tuple_size_v>); + SmallBitVector Used(NumPatterns); return reassociatableMatchHelper(Matches, Used); }