From: Craig Topper Date: Sat, 1 Apr 2023 05:54:10 +0000 (-0700) Subject: [TableGen] Reduce code duplication. NFC X-Git-Tag: upstream/17.0.6~12988 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2f29adb24a578bb8b4b0e4b4f5e136fb4f0f34a;p=platform%2Fupstream%2Fllvm.git [TableGen] Reduce code duplication. NFC --- 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";