blob: 41ce6ae69133c680a8b33cbd1dccdc4c16f28d31 [file] [log] [blame]
Chris Lattner36e646c2010-02-24 07:06:50 +00001//===- DAGISelMatcherOpt.cpp - Optimize a DAG Matcher ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the DAG Matcher optimizer.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattnerddfd5ab2010-02-27 07:49:13 +000014#define DEBUG_TYPE "isel-opt"
Chris Lattner36e646c2010-02-24 07:06:50 +000015#include "DAGISelMatcher.h"
Chris Lattner5cc7a832010-02-28 20:49:53 +000016#include "CodeGenDAGPatterns.h"
Chris Lattnercd632fb2010-02-25 07:45:24 +000017#include "llvm/ADT/DenseMap.h"
Chris Lattner2e9e6842010-03-01 06:59:22 +000018#include "llvm/ADT/StringSet.h"
Chris Lattnerddfd5ab2010-02-27 07:49:13 +000019#include "llvm/Support/Debug.h"
20#include "llvm/Support/raw_ostream.h"
Chris Lattnercd632fb2010-02-25 07:45:24 +000021#include <vector>
Chris Lattner36e646c2010-02-24 07:06:50 +000022using namespace llvm;
23
Chris Lattnerf4950d02010-02-27 06:22:57 +000024/// ContractNodes - Turn multiple matcher node patterns like 'MoveChild+Record'
25/// into single compound nodes like RecordChild.
Chris Lattner5cc7a832010-02-28 20:49:53 +000026static void ContractNodes(OwningPtr<Matcher> &MatcherPtr,
27 const CodeGenDAGPatterns &CGP) {
Chris Lattner3ee1bc42010-02-24 07:31:45 +000028 // If we reached the end of the chain, we're done.
Chris Lattner9a515172010-02-25 02:04:40 +000029 Matcher *N = MatcherPtr.get();
Chris Lattner3ee1bc42010-02-24 07:31:45 +000030 if (N == 0) return;
31
Chris Lattner42363662010-02-25 19:00:39 +000032 // If we have a scope node, walk down all of the children.
33 if (ScopeMatcher *Scope = dyn_cast<ScopeMatcher>(N)) {
34 for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
35 OwningPtr<Matcher> Child(Scope->takeChild(i));
Chris Lattner5cc7a832010-02-28 20:49:53 +000036 ContractNodes(Child, CGP);
Chris Lattner42363662010-02-25 19:00:39 +000037 Scope->resetChild(i, Child.take());
38 }
39 return;
40 }
Chris Lattner3ee1bc42010-02-24 07:31:45 +000041
Chris Lattner9feb1e32010-02-24 19:52:48 +000042 // If we found a movechild node with a node that comes in a 'foochild' form,
43 // transform it.
Chris Lattner9a515172010-02-25 02:04:40 +000044 if (MoveChildMatcher *MC = dyn_cast<MoveChildMatcher>(N)) {
45 Matcher *New = 0;
46 if (RecordMatcher *RM = dyn_cast<RecordMatcher>(MC->getNext()))
Chris Lattner5377f912010-03-01 02:24:17 +000047 New = new RecordChildMatcher(MC->getChildNo(), RM->getWhatFor(),
48 RM->getResultNo());
Chris Lattner3c664b32010-02-24 20:15:25 +000049
Chris Lattner9a515172010-02-25 02:04:40 +000050 if (CheckTypeMatcher *CT= dyn_cast<CheckTypeMatcher>(MC->getNext()))
51 New = new CheckChildTypeMatcher(MC->getChildNo(), CT->getType());
Chris Lattner3c664b32010-02-24 20:15:25 +000052
53 if (New) {
54 // Insert the new node.
Chris Lattnerac10e4f2010-02-25 01:56:48 +000055 New->setNext(MatcherPtr.take());
56 MatcherPtr.reset(New);
Chris Lattner3c664b32010-02-24 20:15:25 +000057 // Remove the old one.
58 MC->setNext(MC->getNext()->takeNext());
Chris Lattner5cc7a832010-02-28 20:49:53 +000059 return ContractNodes(MatcherPtr, CGP);
Chris Lattner9feb1e32010-02-24 19:52:48 +000060 }
Chris Lattner3ee1bc42010-02-24 07:31:45 +000061 }
Chris Lattner9feb1e32010-02-24 19:52:48 +000062
Chris Lattner7a1dab42010-02-28 02:31:26 +000063 // Zap movechild -> moveparent.
Chris Lattner9a515172010-02-25 02:04:40 +000064 if (MoveChildMatcher *MC = dyn_cast<MoveChildMatcher>(N))
65 if (MoveParentMatcher *MP =
66 dyn_cast<MoveParentMatcher>(MC->getNext())) {
Chris Lattnerac10e4f2010-02-25 01:56:48 +000067 MatcherPtr.reset(MP->takeNext());
Chris Lattner5cc7a832010-02-28 20:49:53 +000068 return ContractNodes(MatcherPtr, CGP);
Chris Lattner9feb1e32010-02-24 19:52:48 +000069 }
Chris Lattner1f5ca1e2010-02-28 23:00:47 +000070
Chris Lattner304a3e12010-03-01 02:33:14 +000071 // Turn EmitNode->MarkFlagResults->CompleteMatch into
72 // MarkFlagResults->EmitNode->CompleteMatch when we can to encourage
73 // MorphNodeTo formation. This is safe because MarkFlagResults never refers
74 // to the root of the pattern.
75 if (isa<EmitNodeMatcher>(N) && isa<MarkFlagResultsMatcher>(N->getNext()) &&
76 isa<CompleteMatchMatcher>(N->getNext()->getNext())) {
77 // Unlink the two nodes from the list.
78 Matcher *EmitNode = MatcherPtr.take();
79 Matcher *MFR = EmitNode->takeNext();
80 Matcher *Tail = MFR->takeNext();
81
82 // Relink them.
83 MatcherPtr.reset(MFR);
84 MFR->setNext(EmitNode);
85 EmitNode->setNext(Tail);
86 return ContractNodes(MatcherPtr, CGP);
87 }
Chris Lattner1f5ca1e2010-02-28 23:00:47 +000088
Chris Lattner7dae4af2010-02-28 20:55:18 +000089 // Turn EmitNode->CompleteMatch into MorphNodeTo if we can.
Chris Lattner7a1dab42010-02-28 02:31:26 +000090 if (EmitNodeMatcher *EN = dyn_cast<EmitNodeMatcher>(N))
Chris Lattner19a1fbe2010-02-28 02:41:25 +000091 if (CompleteMatchMatcher *CM =
92 dyn_cast<CompleteMatchMatcher>(EN->getNext())) {
Chris Lattner7dae4af2010-02-28 20:55:18 +000093 // We can only use MorphNodeTo if the result values match up.
Chris Lattner5cc7a832010-02-28 20:49:53 +000094 unsigned RootResultFirst = EN->getFirstResultSlot();
95 bool ResultsMatch = true;
96 for (unsigned i = 0, e = CM->getNumResults(); i != e; ++i)
97 if (CM->getResult(i) != RootResultFirst+i)
98 ResultsMatch = false;
99
100 // If the selected node defines a subset of the flag/chain results, we
Chris Lattner7dae4af2010-02-28 20:55:18 +0000101 // can't use MorphNodeTo. For example, we can't use MorphNodeTo if the
Chris Lattner5cc7a832010-02-28 20:49:53 +0000102 // matched pattern has a chain but the root node doesn't.
103 const PatternToMatch &Pattern = CM->getPattern();
104
105 if (!EN->hasChain() &&
106 Pattern.getSrcPattern()->NodeHasProperty(SDNPHasChain, CGP))
107 ResultsMatch = false;
108
109 // If the matched node has a flag and the output root doesn't, we can't
Chris Lattner7dae4af2010-02-28 20:55:18 +0000110 // use MorphNodeTo.
Chris Lattner5cc7a832010-02-28 20:49:53 +0000111 //
112 // NOTE: Strictly speaking, we don't have to check for the flag here
113 // because the code in the pattern generator doesn't handle it right. We
114 // do it anyway for thoroughness.
Chris Lattner414bac82010-02-28 21:53:42 +0000115 if (!EN->hasOutFlag() &&
Chris Lattner5cc7a832010-02-28 20:49:53 +0000116 Pattern.getSrcPattern()->NodeHasProperty(SDNPOutFlag, CGP))
117 ResultsMatch = false;
118
119
120 // If the root result node defines more results than the source root node
121 // *and* has a chain or flag input, then we can't match it because it
122 // would end up replacing the extra result with the chain/flag.
123#if 0
124 if ((EN->hasFlag() || EN->hasChain()) &&
125 EN->getNumNonChainFlagVTs() > ... need to get no results reliably ...)
126 ResultMatch = false;
127#endif
128
129 if (ResultsMatch) {
130 const SmallVectorImpl<MVT::SimpleValueType> &VTs = EN->getVTList();
131 const SmallVectorImpl<unsigned> &Operands = EN->getOperandList();
Chris Lattner7dae4af2010-02-28 20:55:18 +0000132 MatcherPtr.reset(new MorphNodeToMatcher(EN->getOpcodeName(),
Chris Lattner414bac82010-02-28 21:53:42 +0000133 VTs.data(), VTs.size(),
Chris Lattner7dae4af2010-02-28 20:55:18 +0000134 Operands.data(),Operands.size(),
Chris Lattner414bac82010-02-28 21:53:42 +0000135 EN->hasChain(), EN->hasInFlag(),
136 EN->hasOutFlag(),
Chris Lattner7dae4af2010-02-28 20:55:18 +0000137 EN->hasMemRefs(),
138 EN->getNumFixedArityOperands(),
139 Pattern));
Chris Lattner5cc7a832010-02-28 20:49:53 +0000140 return;
141 }
142
Chris Lattner7dae4af2010-02-28 20:55:18 +0000143 // FIXME2: Kill off all the SelectionDAG::MorphNodeTo and getMachineNode
144 // variants.
Chris Lattner7a1dab42010-02-28 02:31:26 +0000145 }
146
Chris Lattner5cc7a832010-02-28 20:49:53 +0000147 ContractNodes(N->getNextPtr(), CGP);
Chris Lattnere0b45db2010-03-01 02:15:34 +0000148
149
150 // If we have a CheckType/CheckChildType/Record node followed by a
151 // CheckOpcode, invert the two nodes. We prefer to do structural checks
152 // before type checks, as this opens opportunities for factoring on targets
153 // like X86 where many operations are valid on multiple types.
154 if ((isa<CheckTypeMatcher>(N) || isa<CheckChildTypeMatcher>(N) ||
155 isa<RecordMatcher>(N)) &&
Chris Lattner2e9e6842010-03-01 06:59:22 +0000156 (isa<CheckOpcodeMatcher>(N->getNext()) ||
157 isa<CheckMultiOpcodeMatcher>(N->getNext()))) {
Chris Lattnere0b45db2010-03-01 02:15:34 +0000158 // Unlink the two nodes from the list.
159 Matcher *CheckType = MatcherPtr.take();
160 Matcher *CheckOpcode = CheckType->takeNext();
161 Matcher *Tail = CheckOpcode->takeNext();
162
163 // Relink them.
164 MatcherPtr.reset(CheckOpcode);
165 CheckOpcode->setNext(CheckType);
166 CheckType->setNext(Tail);
167 return ContractNodes(MatcherPtr, CGP);
168 }
Chris Lattner3ee1bc42010-02-24 07:31:45 +0000169}
170
Chris Lattnerf4950d02010-02-27 06:22:57 +0000171/// SinkPatternPredicates - Pattern predicates can be checked at any level of
172/// the matching tree. The generator dumps them at the top level of the pattern
173/// though, which prevents factoring from being able to see past them. This
174/// optimization sinks them as far down into the pattern as possible.
175///
176/// Conceptually, we'd like to sink these predicates all the way to the last
177/// matcher predicate in the series. However, it turns out that some
178/// ComplexPatterns have side effects on the graph, so we really don't want to
179/// run a the complex pattern if the pattern predicate will fail. For this
180/// reason, we refuse to sink the pattern predicate past a ComplexPattern.
181///
182static void SinkPatternPredicates(OwningPtr<Matcher> &MatcherPtr) {
183 // Recursively scan for a PatternPredicate.
184 // If we reached the end of the chain, we're done.
185 Matcher *N = MatcherPtr.get();
186 if (N == 0) return;
187
188 // Walk down all members of a scope node.
189 if (ScopeMatcher *Scope = dyn_cast<ScopeMatcher>(N)) {
190 for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
191 OwningPtr<Matcher> Child(Scope->takeChild(i));
192 SinkPatternPredicates(Child);
193 Scope->resetChild(i, Child.take());
194 }
195 return;
196 }
197
198 // If this node isn't a CheckPatternPredicateMatcher we keep scanning until
199 // we find one.
200 CheckPatternPredicateMatcher *CPPM =dyn_cast<CheckPatternPredicateMatcher>(N);
201 if (CPPM == 0)
202 return SinkPatternPredicates(N->getNextPtr());
203
204 // Ok, we found one, lets try to sink it. Check if we can sink it past the
205 // next node in the chain. If not, we won't be able to change anything and
206 // might as well bail.
207 if (!CPPM->getNext()->isSafeToReorderWithPatternPredicate())
208 return;
209
210 // Okay, we know we can sink it past at least one node. Unlink it from the
211 // chain and scan for the new insertion point.
212 MatcherPtr.take(); // Don't delete CPPM.
213 MatcherPtr.reset(CPPM->takeNext());
214
215 N = MatcherPtr.get();
216 while (N->getNext()->isSafeToReorderWithPatternPredicate())
217 N = N->getNext();
218
219 // At this point, we want to insert CPPM after N.
220 CPPM->setNext(N->takeNext());
221 N->setNext(CPPM);
222}
223
224/// FactorNodes - Turn matches like this:
225/// Scope
226/// OPC_CheckType i32
227/// ABC
228/// OPC_CheckType i32
229/// XYZ
230/// into:
231/// OPC_CheckType i32
232/// Scope
233/// ABC
234/// XYZ
235///
Chris Lattner9a515172010-02-25 02:04:40 +0000236static void FactorNodes(OwningPtr<Matcher> &MatcherPtr) {
Chris Lattner0acf2ba2010-02-25 01:57:41 +0000237 // If we reached the end of the chain, we're done.
Chris Lattner9a515172010-02-25 02:04:40 +0000238 Matcher *N = MatcherPtr.get();
Chris Lattner0acf2ba2010-02-25 01:57:41 +0000239 if (N == 0) return;
240
241 // If this is not a push node, just scan for one.
Chris Lattner42363662010-02-25 19:00:39 +0000242 ScopeMatcher *Scope = dyn_cast<ScopeMatcher>(N);
243 if (Scope == 0)
Chris Lattner0acf2ba2010-02-25 01:57:41 +0000244 return FactorNodes(N->getNextPtr());
245
Chris Lattner42363662010-02-25 19:00:39 +0000246 // Okay, pull together the children of the scope node into a vector so we can
Chris Lattnercd632fb2010-02-25 07:45:24 +0000247 // inspect it more easily. While we're at it, bucket them up by the hash
248 // code of their first predicate.
Chris Lattner9a515172010-02-25 02:04:40 +0000249 SmallVector<Matcher*, 32> OptionsToMatch;
Chris Lattner0acf2ba2010-02-25 01:57:41 +0000250
Chris Lattner42363662010-02-25 19:00:39 +0000251 for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
Chris Lattnercd632fb2010-02-25 07:45:24 +0000252 // Factor the subexpression.
Chris Lattner42363662010-02-25 19:00:39 +0000253 OwningPtr<Matcher> Child(Scope->takeChild(i));
254 FactorNodes(Child);
255
Chris Lattner92a22462010-02-26 08:08:41 +0000256 if (Matcher *N = Child.take())
Chris Lattner42363662010-02-25 19:00:39 +0000257 OptionsToMatch.push_back(N);
Chris Lattnercd632fb2010-02-25 07:45:24 +0000258 }
Chris Lattner0acf2ba2010-02-25 01:57:41 +0000259
Chris Lattnercd632fb2010-02-25 07:45:24 +0000260 SmallVector<Matcher*, 32> NewOptionsToMatch;
Chris Lattner2e9e6842010-03-01 06:59:22 +0000261
Chris Lattner92a22462010-02-26 08:08:41 +0000262 // Loop over options to match, merging neighboring patterns with identical
263 // starting nodes into a shared matcher.
Chris Lattnerddfd5ab2010-02-27 07:49:13 +0000264 for (unsigned OptionIdx = 0, e = OptionsToMatch.size(); OptionIdx != e;) {
Chris Lattnercd632fb2010-02-25 07:45:24 +0000265 // Find the set of matchers that start with this node.
Chris Lattnerddfd5ab2010-02-27 07:49:13 +0000266 Matcher *Optn = OptionsToMatch[OptionIdx++];
267
268 if (OptionIdx == e) {
Chris Lattnercd632fb2010-02-25 07:45:24 +0000269 NewOptionsToMatch.push_back(Optn);
270 continue;
271 }
272
Chris Lattnerddfd5ab2010-02-27 07:49:13 +0000273 // See if the next option starts with the same matcher. If the two
274 // neighbors *do* start with the same matcher, we can factor the matcher out
275 // of at least these two patterns. See what the maximal set we can merge
276 // together is.
Chris Lattner92a22462010-02-26 08:08:41 +0000277 SmallVector<Matcher*, 8> EqualMatchers;
278 EqualMatchers.push_back(Optn);
Chris Lattner92a22462010-02-26 08:08:41 +0000279
Chris Lattnerddfd5ab2010-02-27 07:49:13 +0000280 // Factor all of the known-equal matchers after this one into the same
281 // group.
282 while (OptionIdx != e && OptionsToMatch[OptionIdx]->isEqual(Optn))
283 EqualMatchers.push_back(OptionsToMatch[OptionIdx++]);
284
285 // If we found a non-equal matcher, see if it is contradictory with the
286 // current node. If so, we know that the ordering relation between the
287 // current sets of nodes and this node don't matter. Look past it to see if
288 // we can merge anything else into this matching group.
289 unsigned Scan = OptionIdx;
290 while (1) {
291 while (Scan != e && Optn->isContradictory(OptionsToMatch[Scan]))
292 ++Scan;
293
294 // Ok, we found something that isn't known to be contradictory. If it is
295 // equal, we can merge it into the set of nodes to factor, if not, we have
296 // to cease factoring.
297 if (Scan == e || !Optn->isEqual(OptionsToMatch[Scan])) break;
298
299 // If is equal after all, add the option to EqualMatchers and remove it
300 // from OptionsToMatch.
301 EqualMatchers.push_back(OptionsToMatch[Scan]);
302 OptionsToMatch.erase(OptionsToMatch.begin()+Scan);
303 --e;
304 }
305
Chris Lattnere9f720b2010-02-27 21:48:43 +0000306 if (Scan != e &&
307 // Don't print it's obvious nothing extra could be merged anyway.
308 Scan+1 != e) {
Chris Lattner086af322010-02-27 08:11:15 +0000309 DEBUG(errs() << "Couldn't merge this:\n";
310 Optn->print(errs(), 4);
311 errs() << "into this:\n";
312 OptionsToMatch[Scan]->print(errs(), 4);
Chris Lattner53d3ec92010-02-27 08:13:23 +0000313 if (Scan+1 != e)
Chris Lattner086af322010-02-27 08:11:15 +0000314 OptionsToMatch[Scan+1]->printOne(errs());
Chris Lattner53d3ec92010-02-27 08:13:23 +0000315 if (Scan+2 < e)
Chris Lattner086af322010-02-27 08:11:15 +0000316 OptionsToMatch[Scan+2]->printOne(errs());
Chris Lattnerddfd5ab2010-02-27 07:49:13 +0000317 errs() << "\n");
318 }
319
320 // If we only found one option starting with this matcher, no factoring is
321 // possible.
322 if (EqualMatchers.size() == 1) {
323 NewOptionsToMatch.push_back(EqualMatchers[0]);
324 continue;
325 }
Chris Lattner92a22462010-02-26 08:08:41 +0000326
Chris Lattnercd632fb2010-02-25 07:45:24 +0000327 // Factor these checks by pulling the first node off each entry and
Chris Lattnerb0e68102010-02-26 07:36:37 +0000328 // discarding it. Take the first one off the first entry to reuse.
329 Matcher *Shared = Optn;
330 Optn = Optn->takeNext();
331 EqualMatchers[0] = Optn;
332
Chris Lattner92a22462010-02-26 08:08:41 +0000333 // Remove and delete the first node from the other matchers we're factoring.
334 for (unsigned i = 1, e = EqualMatchers.size(); i != e; ++i) {
335 Matcher *Tmp = EqualMatchers[i]->takeNext();
336 delete EqualMatchers[i];
337 EqualMatchers[i] = Tmp;
338 }
Chris Lattnercd632fb2010-02-25 07:45:24 +0000339
Chris Lattnerb0e68102010-02-26 07:36:37 +0000340 Shared->setNext(new ScopeMatcher(&EqualMatchers[0], EqualMatchers.size()));
341
342 // Recursively factor the newly created node.
343 FactorNodes(Shared->getNextPtr());
344
345 NewOptionsToMatch.push_back(Shared);
Chris Lattnercd632fb2010-02-25 07:45:24 +0000346 }
Chris Lattner2e9e6842010-03-01 06:59:22 +0000347
348 // If we're down to a single pattern to match, then we don't need this scope
349 // anymore.
350 if (NewOptionsToMatch.size() == 1) {
351 MatcherPtr.reset(NewOptionsToMatch[0]);
352 return;
353 }
354
355 // If our factoring failed (didn't achieve anything) see if we can simplify in
356 // other ways.
357
358 // Check to see if all of the leading entries are now opcode checks. If so,
359 // we can convert this Scope to be a OpcodeSwitch instead.
360 bool AllOpcodeChecks = true;
361 for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) {
362 if (isa<CheckOpcodeMatcher>(NewOptionsToMatch[i])) continue;
363
364#if 0
365 if (i > 3) {
366 errs() << "FAILING OPC #" << i << "\n";
367 NewOptionsToMatch[i]->dump();
368 }
369#endif
370
371 AllOpcodeChecks = false;
372 break;
373 }
374
375 // If all the options are CheckOpcode's, we can form the SwitchOpcode, woot.
376 if (AllOpcodeChecks) {
377 StringSet<> Opcodes;
378 SmallVector<std::pair<const SDNodeInfo*, Matcher*>, 8> Cases;
379 for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) {
380 CheckOpcodeMatcher *COM =cast<CheckOpcodeMatcher>(NewOptionsToMatch[i]);
381 assert(Opcodes.insert(COM->getOpcode().getEnumName()) &&
382 "Duplicate opcodes not factored?");
383 Cases.push_back(std::make_pair(&COM->getOpcode(), COM->getNext()));
384 }
385
386 MatcherPtr.reset(new SwitchOpcodeMatcher(&Cases[0], Cases.size()));
387 return;
388 }
389
Chris Lattnercd632fb2010-02-25 07:45:24 +0000390
391 // Reassemble a new Scope node.
Chris Lattner2e9e6842010-03-01 06:59:22 +0000392 assert(!NewOptionsToMatch.empty() &&
393 "Where'd all our children go? Did we really factor everything??");
Chris Lattner5cc7a832010-02-28 20:49:53 +0000394 if (NewOptionsToMatch.empty())
395 MatcherPtr.reset(0);
Chris Lattnerb0e68102010-02-26 07:36:37 +0000396 else {
397 Scope->setNumChildren(NewOptionsToMatch.size());
398 for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i)
399 Scope->resetChild(i, NewOptionsToMatch[i]);
400 }
Chris Lattner0acf2ba2010-02-25 01:57:41 +0000401}
402
Chris Lattner5cc7a832010-02-28 20:49:53 +0000403Matcher *llvm::OptimizeMatcher(Matcher *TheMatcher,
404 const CodeGenDAGPatterns &CGP) {
Chris Lattner9a515172010-02-25 02:04:40 +0000405 OwningPtr<Matcher> MatcherPtr(TheMatcher);
Chris Lattner5cc7a832010-02-28 20:49:53 +0000406 ContractNodes(MatcherPtr, CGP);
Chris Lattnerf4950d02010-02-27 06:22:57 +0000407 SinkPatternPredicates(MatcherPtr);
Chris Lattner0acf2ba2010-02-25 01:57:41 +0000408 FactorNodes(MatcherPtr);
Chris Lattner3ee1bc42010-02-24 07:31:45 +0000409 return MatcherPtr.take();
Chris Lattner36e646c2010-02-24 07:06:50 +0000410}