From b2f29adb24a578bb8b4b0e4b4f5e136fb4f0f34a Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 31 Mar 2023 22:54:10 -0700 Subject: [PATCH] [TableGen] Reduce code duplication. NFC --- llvm/utils/TableGen/DAGISelMatcherGen.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp index ac45de8..ab75181d 100644 --- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp +++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp @@ -281,7 +281,8 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) { return; } - if (LeafRec->getName() == "immAllOnesV") { + if (LeafRec->getName() == "immAllOnesV" || + LeafRec->getName() == "immAllZerosV") { // If this is the root of the dag we're matching, we emit a redundant opcode // check to ensure that this gets folded into the normal top-level // OpcodeSwitch. @@ -291,19 +292,11 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) { const SDNodeInfo &NI = CGP.getSDNodeInfo(CGP.getSDNodeNamed(Name)); AddMatcher(new CheckOpcodeMatcher(NI)); } - return AddMatcher(new CheckImmAllOnesVMatcher()); - } - if (LeafRec->getName() == "immAllZerosV") { - // If this is the root of the dag we're matching, we emit a redundant opcode - // check to ensure that this gets folded into the normal top-level - // OpcodeSwitch. - if (N == Pattern.getSrcPattern()) { - MVT VT = N->getSimpleType(0); - StringRef Name = VT.isScalableVector() ? "splat_vector" : "build_vector"; - const SDNodeInfo &NI = CGP.getSDNodeInfo(CGP.getSDNodeNamed(Name)); - AddMatcher(new CheckOpcodeMatcher(NI)); - } - return AddMatcher(new CheckImmAllZerosVMatcher()); + if (LeafRec->getName() == "immAllOnesV") + AddMatcher(new CheckImmAllOnesVMatcher()); + else + AddMatcher(new CheckImmAllZerosVMatcher()); + return; } errs() << "Unknown leaf kind: " << *N << "\n"; -- 2.7.4