From 6de3afeaef70f35ab10384625cefaba5311c1d64 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 10 Apr 2023 11:29:01 -0700 Subject: [PATCH] [TableGen] Simplify how commuted variants are generated in GenerateVariantsOf. NFC We don't need to copy the ChildVariants vector into a new vector. We're using std::move on every entry we copy so they clearly aren't needed again. We can swap entries in the vector and reuse it instead. --- llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 3bd5bfa..c2c5601 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -4695,17 +4695,10 @@ static void GenerateVariantsOf(TreePatternNodePtr N, } // Consider the commuted order. if (NoRegisters) { - std::vector> Variants; - unsigned i = 0; - if (isCommIntrinsic) - Variants.push_back(std::move(ChildVariants[i++])); // Intrinsic id. - Variants.push_back(std::move(ChildVariants[i + 1])); - Variants.push_back(std::move(ChildVariants[i])); - i += 2; - // Remaining operands are not commuted. - for (; i != N->getNumChildren(); ++i) - Variants.push_back(std::move(ChildVariants[i])); - CombineChildVariants(N, Variants, OutVariants, CDP, DepVars); + // Swap the first two operands after the intrinsic id, if present. + unsigned i = isCommIntrinsic ? 1 : 0; + std::swap(ChildVariants[i], ChildVariants[i + 1]); + CombineChildVariants(N, ChildVariants, OutVariants, CDP, DepVars); } } } -- 2.7.4