From db5b73a77fc5a553b11440a28effea62c113297c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 1 Mar 2010 02:33:14 +0000 Subject: [PATCH] pull MarkFlagResult out from between an EmitNode/CompleteMatch pair. This encourages MorphNodeTo formation, this gets us 200 more MorphNodeTo's on X86 and shrinks the table a bit. llvm-svn: 97434 --- llvm/utils/TableGen/DAGISelMatcherOpt.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp index f8dfe6d82c51..5fe21f67389e 100644 --- a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp @@ -67,7 +67,23 @@ static void ContractNodes(OwningPtr &MatcherPtr, return ContractNodes(MatcherPtr, CGP); } - // FIXME: Handle OPC_MarkFlagResults. + // Turn EmitNode->MarkFlagResults->CompleteMatch into + // MarkFlagResults->EmitNode->CompleteMatch when we can to encourage + // MorphNodeTo formation. This is safe because MarkFlagResults never refers + // to the root of the pattern. + if (isa(N) && isa(N->getNext()) && + isa(N->getNext()->getNext())) { + // Unlink the two nodes from the list. + Matcher *EmitNode = MatcherPtr.take(); + Matcher *MFR = EmitNode->takeNext(); + Matcher *Tail = MFR->takeNext(); + + // Relink them. + MatcherPtr.reset(MFR); + MFR->setNext(EmitNode); + EmitNode->setNext(Tail); + return ContractNodes(MatcherPtr, CGP); + } // Turn EmitNode->CompleteMatch into MorphNodeTo if we can. if (EmitNodeMatcher *EN = dyn_cast(N))