diff --git a/llvm/utils/TableGen/DAGISelMatcher.h b/llvm/utils/TableGen/DAGISelMatcher.h index 8b6b32291429..1634cd2ecdd5 100644 --- a/llvm/utils/TableGen/DAGISelMatcher.h +++ b/llvm/utils/TableGen/DAGISelMatcher.h @@ -55,7 +55,6 @@ public: CheckPredicate, // Fail if node predicate fails. CheckOpcode, // Fail if not opcode. SwitchOpcode, // Dispatch based on opcode. - CheckMultiOpcode, // Fail if not in opcode list. CheckType, // Fail if not correct type. CheckChildType, // Fail if child has wrong type. CheckInteger, // Fail if wrong val. diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp index 95cfa5b251ce..62442d0c22c6 100644 --- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp +++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp @@ -205,8 +205,17 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) { AddMatcher(new CheckPredicateMatcher(N->getPredicateFns()[i])); // Direct match against an integer constant. - if (IntInit *II = dynamic_cast(N->getLeafValue())) + if (IntInit *II = dynamic_cast(N->getLeafValue())) { + // 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()) { + const SDNodeInfo &NI = CGP.getSDNodeInfo(CGP.getSDNodeNamed("imm")); + AddMatcher(new CheckOpcodeMatcher(NI)); + } + return AddMatcher(new CheckIntegerMatcher(II->getValue())); + } DefInit *DI = dynamic_cast(N->getLeafValue()); if (DI == 0) {