aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen/DAGISelMatcherOpt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-01 02:15:34 +0000
committerChris Lattner <sabre@nondot.org>2010-03-01 02:15:34 +0000
commite9eeda878beb8d36507a69a2be2fe08fcc968fef (patch)
treea592c260e96508c1e738d1c7887e3a03e5e34010 /utils/TableGen/DAGISelMatcherOpt.cpp
parent4d0c931ba7758a98864dc7e968a10df7fed7ab70 (diff)
downloadexternal_llvm-e9eeda878beb8d36507a69a2be2fe08fcc968fef.zip
external_llvm-e9eeda878beb8d36507a69a2be2fe08fcc968fef.tar.gz
external_llvm-e9eeda878beb8d36507a69a2be2fe08fcc968fef.tar.bz2
Emit redundant opcode checks for andimm and orimm tests at root
so that we get grouping at the top level. Add an optimization to reorder type check & record nodes after opcode checks. We prefer to expose tree shape matching which improves grouping and will enhance the next optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97432 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/DAGISelMatcherOpt.cpp')
-rw-r--r--utils/TableGen/DAGISelMatcherOpt.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp
index 37643c3..1181827 100644
--- a/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -127,6 +127,26 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr,
}
ContractNodes(N->getNextPtr(), CGP);
+
+
+ // If we have a CheckType/CheckChildType/Record node followed by a
+ // CheckOpcode, invert the two nodes. We prefer to do structural checks
+ // before type checks, as this opens opportunities for factoring on targets
+ // like X86 where many operations are valid on multiple types.
+ if ((isa<CheckTypeMatcher>(N) || isa<CheckChildTypeMatcher>(N) ||
+ isa<RecordMatcher>(N)) &&
+ isa<CheckOpcodeMatcher>(N->getNext())) {
+ // Unlink the two nodes from the list.
+ Matcher *CheckType = MatcherPtr.take();
+ Matcher *CheckOpcode = CheckType->takeNext();
+ Matcher *Tail = CheckOpcode->takeNext();
+
+ // Relink them.
+ MatcherPtr.reset(CheckOpcode);
+ CheckOpcode->setNext(CheckType);
+ CheckType->setNext(Tail);
+ return ContractNodes(MatcherPtr, CGP);
+ }
}
/// SinkPatternPredicates - Pattern predicates can be checked at any level of