From 6966c48767f988dec21598bdb0e551caad0dea7b Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Mon, 31 Jul 2006 19:01:58 +0000 Subject: [PATCH] Remove an unneeded match condition: the type check for root node has been moved to outside the actual select routine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29415 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelEmitter.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index 3d93da9b144..a15a6ba0f94 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -1829,9 +1829,22 @@ static void GenerateVariantsOf(TreePatternNode *N, // If this node is commutative, consider the commuted order. if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) { assert(N->getNumChildren()==2 &&"Commutative but doesn't have 2 children!"); + // Don't count childrean which are actually + unsigned NC = 0; + for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { + TreePatternNode *Child = N->getChild(i); + if (Child->isLeaf()) + if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { + Record *RR = DI->getDef(); + if (RR->isSubClassOf("Register")) + continue; + } + NC++; + } // Consider the commuted order. - CombineChildVariants(N, ChildVariants[1], ChildVariants[0], - OutVariants, ISE); + if (NC == 2) + CombineChildVariants(N, ChildVariants[1], ChildVariants[0], + OutVariants, ISE); } } @@ -2845,13 +2858,15 @@ public: /// 'Pat' may be missing types. If we find an unresolved type to add a check /// for, this returns true otherwise false if Pat has all types. bool InsertOneTypeCheck(TreePatternNode *Pat, TreePatternNode *Other, - const std::string &Prefix) { + const std::string &Prefix, bool isRoot = false) { // Did we find one? if (Pat->getExtTypes() != Other->getExtTypes()) { // Move a type over from 'other' to 'pat'. Pat->setTypes(Other->getExtTypes()); - emitCheck(Prefix + ".Val->getValueType(0) == " + - getName(Pat->getTypeNum(0))); + // The top level node type is checked outside of the select function. + if (!isRoot) + emitCheck(Prefix + ".Val->getValueType(0) == " + + getName(Pat->getTypeNum(0))); return true; } @@ -3005,7 +3020,7 @@ void DAGISelEmitter::GenerateCodeForPattern(PatternToMatch &Pattern, // Insert a check for an unresolved type and add it to the tree. If we find // an unresolved type to add a check for, this returns true and we iterate, // otherwise we are done. - } while (Emitter.InsertOneTypeCheck(Pat, Pattern.getSrcPattern(), "N")); + } while (Emitter.InsertOneTypeCheck(Pat, Pattern.getSrcPattern(), "N", true)); Emitter.EmitResultCode(Pattern.getDstPattern(), false, true /*the root*/); delete Pat; @@ -3282,7 +3297,7 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) { // patterns after it CANNOT ever match. Error out. if (mightNotMatch == false && i != CodeForPatterns.size()-1) { std::cerr << "Pattern '"; - CodeForPatterns[i+1].first->getSrcPattern()->print(OS); + CodeForPatterns[i+1].first->getSrcPattern()->print(std::cerr); std::cerr << "' is impossible to select!\n"; exit(1); } -- 2.34.1