Chris Lattner | e732743 | 2010-02-24 07:06:50 +0000 | [diff] [blame] | 1 | //===- 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 | |
| 14 | #include "DAGISelMatcher.h" |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 15 | #include "CodeGenDAGPatterns.h" |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/DenseSet.h" |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/StringSet.h" |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 18 | #include "llvm/Support/Debug.h" |
| 19 | #include "llvm/Support/raw_ostream.h" |
Chris Lattner | e732743 | 2010-02-24 07:06:50 +0000 | [diff] [blame] | 20 | using namespace llvm; |
| 21 | |
Chandler Carruth | 97acce2 | 2014-04-22 03:06:00 +0000 | [diff] [blame] | 22 | #define DEBUG_TYPE "isel-opt" |
| 23 | |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 24 | /// ContractNodes - Turn multiple matcher node patterns like 'MoveChild+Record' |
| 25 | /// into single compound nodes like RecordChild. |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 26 | static void ContractNodes(std::unique_ptr<Matcher> &MatcherPtr, |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 27 | const CodeGenDAGPatterns &CGP) { |
Chris Lattner | ab41756 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 28 | // If we reached the end of the chain, we're done. |
Chris Lattner | 2c3f649 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 29 | Matcher *N = MatcherPtr.get(); |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 30 | if (!N) return; |
Chris Lattner | ab41756 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 31 | |
Chris Lattner | f7fc2d8 | 2010-02-25 19:00:39 +0000 | [diff] [blame] | 32 | // 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) { |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 35 | std::unique_ptr<Matcher> Child(Scope->takeChild(i)); |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 36 | ContractNodes(Child, CGP); |
Ahmed Charles | 96c9d95 | 2014-03-05 10:19:29 +0000 | [diff] [blame] | 37 | Scope->resetChild(i, Child.release()); |
Chris Lattner | f7fc2d8 | 2010-02-25 19:00:39 +0000 | [diff] [blame] | 38 | } |
| 39 | return; |
| 40 | } |
Chris Lattner | ab41756 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 41 | |
Chris Lattner | 6b79232 | 2010-02-24 19:52:48 +0000 | [diff] [blame] | 42 | // If we found a movechild node with a node that comes in a 'foochild' form, |
| 43 | // transform it. |
Chris Lattner | 2c3f649 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 44 | if (MoveChildMatcher *MC = dyn_cast<MoveChildMatcher>(N)) { |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 45 | Matcher *New = nullptr; |
Chris Lattner | 2c3f649 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 46 | if (RecordMatcher *RM = dyn_cast<RecordMatcher>(MC->getNext())) |
Chris Lattner | f57437a | 2010-03-16 00:35:11 +0000 | [diff] [blame] | 47 | if (MC->getChildNo() < 8) // Only have RecordChild0...7 |
| 48 | New = new RecordChildMatcher(MC->getChildNo(), RM->getWhatFor(), |
| 49 | RM->getResultNo()); |
Craig Topper | 7ca1d18 | 2014-02-05 05:44:28 +0000 | [diff] [blame] | 50 | |
Chris Lattner | 6c2d178 | 2010-03-24 00:41:19 +0000 | [diff] [blame] | 51 | if (CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(MC->getNext())) |
| 52 | if (MC->getChildNo() < 8 && // Only have CheckChildType0...7 |
| 53 | CT->getResNo() == 0) // CheckChildType checks res #0 |
Chris Lattner | f57437a | 2010-03-16 00:35:11 +0000 | [diff] [blame] | 54 | New = new CheckChildTypeMatcher(MC->getChildNo(), CT->getType()); |
Craig Topper | a1bbc32 | 2013-10-05 05:38:16 +0000 | [diff] [blame] | 55 | |
| 56 | if (CheckSameMatcher *CS = dyn_cast<CheckSameMatcher>(MC->getNext())) |
| 57 | if (MC->getChildNo() < 4) // Only have CheckChildSame0...3 |
| 58 | New = new CheckChildSameMatcher(MC->getChildNo(), CS->getMatchNumber()); |
| 59 | |
Craig Topper | 7ca1d18 | 2014-02-05 05:44:28 +0000 | [diff] [blame] | 60 | if (CheckIntegerMatcher *CS = dyn_cast<CheckIntegerMatcher>(MC->getNext())) |
| 61 | if (MC->getChildNo() < 5) // Only have CheckChildInteger0...4 |
| 62 | New = new CheckChildIntegerMatcher(MC->getChildNo(), CS->getValue()); |
| 63 | |
Chris Lattner | 0c95baa | 2010-02-24 20:15:25 +0000 | [diff] [blame] | 64 | if (New) { |
| 65 | // Insert the new node. |
Ahmed Charles | 96c9d95 | 2014-03-05 10:19:29 +0000 | [diff] [blame] | 66 | New->setNext(MatcherPtr.release()); |
Chris Lattner | ac55f9d | 2010-02-25 01:56:48 +0000 | [diff] [blame] | 67 | MatcherPtr.reset(New); |
Chris Lattner | 0c95baa | 2010-02-24 20:15:25 +0000 | [diff] [blame] | 68 | // Remove the old one. |
| 69 | MC->setNext(MC->getNext()->takeNext()); |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 70 | return ContractNodes(MatcherPtr, CGP); |
Chris Lattner | 6b79232 | 2010-02-24 19:52:48 +0000 | [diff] [blame] | 71 | } |
Chris Lattner | ab41756 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 72 | } |
Chris Lattner | 6b79232 | 2010-02-24 19:52:48 +0000 | [diff] [blame] | 73 | |
Chris Lattner | c3f80e0 | 2010-02-28 02:31:26 +0000 | [diff] [blame] | 74 | // Zap movechild -> moveparent. |
Chris Lattner | 2c3f649 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 75 | if (MoveChildMatcher *MC = dyn_cast<MoveChildMatcher>(N)) |
| 76 | if (MoveParentMatcher *MP = |
| 77 | dyn_cast<MoveParentMatcher>(MC->getNext())) { |
Chris Lattner | ac55f9d | 2010-02-25 01:56:48 +0000 | [diff] [blame] | 78 | MatcherPtr.reset(MP->takeNext()); |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 79 | return ContractNodes(MatcherPtr, CGP); |
Chris Lattner | 6b79232 | 2010-02-24 19:52:48 +0000 | [diff] [blame] | 80 | } |
Chris Lattner | 560169d | 2010-02-28 23:00:47 +0000 | [diff] [blame] | 81 | |
Chris Lattner | db5b73a | 2010-03-01 02:33:14 +0000 | [diff] [blame] | 82 | // Turn EmitNode->MarkFlagResults->CompleteMatch into |
| 83 | // MarkFlagResults->EmitNode->CompleteMatch when we can to encourage |
| 84 | // MorphNodeTo formation. This is safe because MarkFlagResults never refers |
| 85 | // to the root of the pattern. |
Chris Lattner | f7f9e8c | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 86 | if (isa<EmitNodeMatcher>(N) && isa<MarkGlueResultsMatcher>(N->getNext()) && |
Chris Lattner | db5b73a | 2010-03-01 02:33:14 +0000 | [diff] [blame] | 87 | isa<CompleteMatchMatcher>(N->getNext()->getNext())) { |
| 88 | // Unlink the two nodes from the list. |
Ahmed Charles | 96c9d95 | 2014-03-05 10:19:29 +0000 | [diff] [blame] | 89 | Matcher *EmitNode = MatcherPtr.release(); |
Chris Lattner | db5b73a | 2010-03-01 02:33:14 +0000 | [diff] [blame] | 90 | Matcher *MFR = EmitNode->takeNext(); |
| 91 | Matcher *Tail = MFR->takeNext(); |
| 92 | |
| 93 | // Relink them. |
| 94 | MatcherPtr.reset(MFR); |
| 95 | MFR->setNext(EmitNode); |
| 96 | EmitNode->setNext(Tail); |
| 97 | return ContractNodes(MatcherPtr, CGP); |
| 98 | } |
Chris Lattner | 560169d | 2010-02-28 23:00:47 +0000 | [diff] [blame] | 99 | |
Chris Lattner | 9d67dca | 2010-02-28 20:55:18 +0000 | [diff] [blame] | 100 | // Turn EmitNode->CompleteMatch into MorphNodeTo if we can. |
Chris Lattner | c3f80e0 | 2010-02-28 02:31:26 +0000 | [diff] [blame] | 101 | if (EmitNodeMatcher *EN = dyn_cast<EmitNodeMatcher>(N)) |
Chris Lattner | abb1c79 | 2010-02-28 02:41:25 +0000 | [diff] [blame] | 102 | if (CompleteMatchMatcher *CM = |
| 103 | dyn_cast<CompleteMatchMatcher>(EN->getNext())) { |
Chris Lattner | 9d67dca | 2010-02-28 20:55:18 +0000 | [diff] [blame] | 104 | // We can only use MorphNodeTo if the result values match up. |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 105 | unsigned RootResultFirst = EN->getFirstResultSlot(); |
| 106 | bool ResultsMatch = true; |
| 107 | for (unsigned i = 0, e = CM->getNumResults(); i != e; ++i) |
| 108 | if (CM->getResult(i) != RootResultFirst+i) |
| 109 | ResultsMatch = false; |
| 110 | |
Chris Lattner | f7f9e8c | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 111 | // If the selected node defines a subset of the glue/chain results, we |
Chris Lattner | 9d67dca | 2010-02-28 20:55:18 +0000 | [diff] [blame] | 112 | // can't use MorphNodeTo. For example, we can't use MorphNodeTo if the |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 113 | // matched pattern has a chain but the root node doesn't. |
| 114 | const PatternToMatch &Pattern = CM->getPattern(); |
| 115 | |
| 116 | if (!EN->hasChain() && |
| 117 | Pattern.getSrcPattern()->NodeHasProperty(SDNPHasChain, CGP)) |
| 118 | ResultsMatch = false; |
| 119 | |
Chris Lattner | f7f9e8c | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 120 | // If the matched node has glue and the output root doesn't, we can't |
Chris Lattner | 9d67dca | 2010-02-28 20:55:18 +0000 | [diff] [blame] | 121 | // use MorphNodeTo. |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 122 | // |
Chris Lattner | f7f9e8c | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 123 | // NOTE: Strictly speaking, we don't have to check for glue here |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 124 | // because the code in the pattern generator doesn't handle it right. We |
| 125 | // do it anyway for thoroughness. |
Chris Lattner | a838264 | 2010-02-28 21:53:42 +0000 | [diff] [blame] | 126 | if (!EN->hasOutFlag() && |
Chris Lattner | 2a0a3b4 | 2010-12-23 18:28:41 +0000 | [diff] [blame] | 127 | Pattern.getSrcPattern()->NodeHasProperty(SDNPOutGlue, CGP)) |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 128 | ResultsMatch = false; |
| 129 | |
| 130 | |
| 131 | // If the root result node defines more results than the source root node |
Chris Lattner | f7f9e8c | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 132 | // *and* has a chain or glue input, then we can't match it because it |
| 133 | // would end up replacing the extra result with the chain/glue. |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 134 | #if 0 |
Chris Lattner | f7f9e8c | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 135 | if ((EN->hasGlue() || EN->hasChain()) && |
| 136 | EN->getNumNonChainGlueVTs() > ... need to get no results reliably ...) |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 137 | ResultMatch = false; |
| 138 | #endif |
| 139 | |
| 140 | if (ResultsMatch) { |
| 141 | const SmallVectorImpl<MVT::SimpleValueType> &VTs = EN->getVTList(); |
| 142 | const SmallVectorImpl<unsigned> &Operands = EN->getOperandList(); |
Chris Lattner | 9d67dca | 2010-02-28 20:55:18 +0000 | [diff] [blame] | 143 | MatcherPtr.reset(new MorphNodeToMatcher(EN->getOpcodeName(), |
Craig Topper | a2c6019 | 2014-01-21 07:20:05 +0000 | [diff] [blame] | 144 | VTs, Operands, |
Chris Lattner | a838264 | 2010-02-28 21:53:42 +0000 | [diff] [blame] | 145 | EN->hasChain(), EN->hasInFlag(), |
| 146 | EN->hasOutFlag(), |
Chris Lattner | 9d67dca | 2010-02-28 20:55:18 +0000 | [diff] [blame] | 147 | EN->hasMemRefs(), |
| 148 | EN->getNumFixedArityOperands(), |
| 149 | Pattern)); |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 150 | return; |
| 151 | } |
| 152 | |
Chris Lattner | 1e634e3 | 2010-03-01 22:29:19 +0000 | [diff] [blame] | 153 | // FIXME2: Kill off all the SelectionDAG::SelectNodeTo and getMachineNode |
Chris Lattner | 9d67dca | 2010-02-28 20:55:18 +0000 | [diff] [blame] | 154 | // variants. |
Chris Lattner | c3f80e0 | 2010-02-28 02:31:26 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 157 | ContractNodes(N->getNextPtr(), CGP); |
Chris Lattner | 90b1b9d | 2010-03-01 02:15:34 +0000 | [diff] [blame] | 158 | |
| 159 | |
| 160 | // If we have a CheckType/CheckChildType/Record node followed by a |
| 161 | // CheckOpcode, invert the two nodes. We prefer to do structural checks |
| 162 | // before type checks, as this opens opportunities for factoring on targets |
| 163 | // like X86 where many operations are valid on multiple types. |
| 164 | if ((isa<CheckTypeMatcher>(N) || isa<CheckChildTypeMatcher>(N) || |
| 165 | isa<RecordMatcher>(N)) && |
Chris Lattner | 053a28a | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 166 | isa<CheckOpcodeMatcher>(N->getNext())) { |
Chris Lattner | 90b1b9d | 2010-03-01 02:15:34 +0000 | [diff] [blame] | 167 | // Unlink the two nodes from the list. |
Ahmed Charles | 96c9d95 | 2014-03-05 10:19:29 +0000 | [diff] [blame] | 168 | Matcher *CheckType = MatcherPtr.release(); |
Chris Lattner | 90b1b9d | 2010-03-01 02:15:34 +0000 | [diff] [blame] | 169 | Matcher *CheckOpcode = CheckType->takeNext(); |
| 170 | Matcher *Tail = CheckOpcode->takeNext(); |
| 171 | |
| 172 | // Relink them. |
| 173 | MatcherPtr.reset(CheckOpcode); |
| 174 | CheckOpcode->setNext(CheckType); |
| 175 | CheckType->setNext(Tail); |
| 176 | return ContractNodes(MatcherPtr, CGP); |
| 177 | } |
Chris Lattner | ab41756 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 180 | /// SinkPatternPredicates - Pattern predicates can be checked at any level of |
| 181 | /// the matching tree. The generator dumps them at the top level of the pattern |
| 182 | /// though, which prevents factoring from being able to see past them. This |
| 183 | /// optimization sinks them as far down into the pattern as possible. |
| 184 | /// |
| 185 | /// Conceptually, we'd like to sink these predicates all the way to the last |
| 186 | /// matcher predicate in the series. However, it turns out that some |
| 187 | /// ComplexPatterns have side effects on the graph, so we really don't want to |
| 188 | /// run a the complex pattern if the pattern predicate will fail. For this |
| 189 | /// reason, we refuse to sink the pattern predicate past a ComplexPattern. |
| 190 | /// |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 191 | static void SinkPatternPredicates(std::unique_ptr<Matcher> &MatcherPtr) { |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 192 | // Recursively scan for a PatternPredicate. |
| 193 | // If we reached the end of the chain, we're done. |
| 194 | Matcher *N = MatcherPtr.get(); |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 195 | if (!N) return; |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 196 | |
| 197 | // Walk down all members of a scope node. |
| 198 | if (ScopeMatcher *Scope = dyn_cast<ScopeMatcher>(N)) { |
| 199 | for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) { |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 200 | std::unique_ptr<Matcher> Child(Scope->takeChild(i)); |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 201 | SinkPatternPredicates(Child); |
Ahmed Charles | 96c9d95 | 2014-03-05 10:19:29 +0000 | [diff] [blame] | 202 | Scope->resetChild(i, Child.release()); |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 203 | } |
| 204 | return; |
| 205 | } |
| 206 | |
| 207 | // If this node isn't a CheckPatternPredicateMatcher we keep scanning until |
| 208 | // we find one. |
| 209 | CheckPatternPredicateMatcher *CPPM =dyn_cast<CheckPatternPredicateMatcher>(N); |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 210 | if (!CPPM) |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 211 | return SinkPatternPredicates(N->getNextPtr()); |
| 212 | |
| 213 | // Ok, we found one, lets try to sink it. Check if we can sink it past the |
| 214 | // next node in the chain. If not, we won't be able to change anything and |
| 215 | // might as well bail. |
| 216 | if (!CPPM->getNext()->isSafeToReorderWithPatternPredicate()) |
| 217 | return; |
| 218 | |
| 219 | // Okay, we know we can sink it past at least one node. Unlink it from the |
| 220 | // chain and scan for the new insertion point. |
Ahmed Charles | 96c9d95 | 2014-03-05 10:19:29 +0000 | [diff] [blame] | 221 | MatcherPtr.release(); // Don't delete CPPM. |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 222 | MatcherPtr.reset(CPPM->takeNext()); |
| 223 | |
| 224 | N = MatcherPtr.get(); |
| 225 | while (N->getNext()->isSafeToReorderWithPatternPredicate()) |
| 226 | N = N->getNext(); |
| 227 | |
| 228 | // At this point, we want to insert CPPM after N. |
| 229 | CPPM->setNext(N->takeNext()); |
| 230 | N->setNext(CPPM); |
| 231 | } |
| 232 | |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 233 | /// FindNodeWithKind - Scan a series of matchers looking for a matcher with a |
| 234 | /// specified kind. Return null if we didn't find one otherwise return the |
| 235 | /// matcher. |
| 236 | static Matcher *FindNodeWithKind(Matcher *M, Matcher::KindTy Kind) { |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 237 | for (; M; M = M->getNext()) |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 238 | if (M->getKind() == Kind) |
| 239 | return M; |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 240 | return nullptr; |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 244 | /// FactorNodes - Turn matches like this: |
| 245 | /// Scope |
| 246 | /// OPC_CheckType i32 |
| 247 | /// ABC |
| 248 | /// OPC_CheckType i32 |
| 249 | /// XYZ |
| 250 | /// into: |
| 251 | /// OPC_CheckType i32 |
| 252 | /// Scope |
| 253 | /// ABC |
| 254 | /// XYZ |
| 255 | /// |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 256 | static void FactorNodes(std::unique_ptr<Matcher> &MatcherPtr) { |
Chris Lattner | c36ab92 | 2010-02-25 01:57:41 +0000 | [diff] [blame] | 257 | // If we reached the end of the chain, we're done. |
Chris Lattner | 2c3f649 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 258 | Matcher *N = MatcherPtr.get(); |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 259 | if (!N) return; |
Chris Lattner | c36ab92 | 2010-02-25 01:57:41 +0000 | [diff] [blame] | 260 | |
| 261 | // If this is not a push node, just scan for one. |
Chris Lattner | f7fc2d8 | 2010-02-25 19:00:39 +0000 | [diff] [blame] | 262 | ScopeMatcher *Scope = dyn_cast<ScopeMatcher>(N); |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 263 | if (!Scope) |
Chris Lattner | c36ab92 | 2010-02-25 01:57:41 +0000 | [diff] [blame] | 264 | return FactorNodes(N->getNextPtr()); |
| 265 | |
Chris Lattner | f7fc2d8 | 2010-02-25 19:00:39 +0000 | [diff] [blame] | 266 | // Okay, pull together the children of the scope node into a vector so we can |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 267 | // inspect it more easily. While we're at it, bucket them up by the hash |
| 268 | // code of their first predicate. |
Chris Lattner | 2c3f649 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 269 | SmallVector<Matcher*, 32> OptionsToMatch; |
Chris Lattner | c36ab92 | 2010-02-25 01:57:41 +0000 | [diff] [blame] | 270 | |
Chris Lattner | f7fc2d8 | 2010-02-25 19:00:39 +0000 | [diff] [blame] | 271 | for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) { |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 272 | // Factor the subexpression. |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 273 | std::unique_ptr<Matcher> Child(Scope->takeChild(i)); |
Chris Lattner | f7fc2d8 | 2010-02-25 19:00:39 +0000 | [diff] [blame] | 274 | FactorNodes(Child); |
| 275 | |
Ahmed Charles | 96c9d95 | 2014-03-05 10:19:29 +0000 | [diff] [blame] | 276 | if (Matcher *N = Child.release()) |
Chris Lattner | f7fc2d8 | 2010-02-25 19:00:39 +0000 | [diff] [blame] | 277 | OptionsToMatch.push_back(N); |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 278 | } |
Chris Lattner | c36ab92 | 2010-02-25 01:57:41 +0000 | [diff] [blame] | 279 | |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 280 | SmallVector<Matcher*, 32> NewOptionsToMatch; |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 281 | |
Chris Lattner | 4f9a671 | 2010-02-26 08:08:41 +0000 | [diff] [blame] | 282 | // Loop over options to match, merging neighboring patterns with identical |
| 283 | // starting nodes into a shared matcher. |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 284 | for (unsigned OptionIdx = 0, e = OptionsToMatch.size(); OptionIdx != e;) { |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 285 | // Find the set of matchers that start with this node. |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 286 | Matcher *Optn = OptionsToMatch[OptionIdx++]; |
| 287 | |
| 288 | if (OptionIdx == e) { |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 289 | NewOptionsToMatch.push_back(Optn); |
| 290 | continue; |
| 291 | } |
| 292 | |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 293 | // See if the next option starts with the same matcher. If the two |
| 294 | // neighbors *do* start with the same matcher, we can factor the matcher out |
| 295 | // of at least these two patterns. See what the maximal set we can merge |
| 296 | // together is. |
Chris Lattner | 4f9a671 | 2010-02-26 08:08:41 +0000 | [diff] [blame] | 297 | SmallVector<Matcher*, 8> EqualMatchers; |
| 298 | EqualMatchers.push_back(Optn); |
Chris Lattner | 4f9a671 | 2010-02-26 08:08:41 +0000 | [diff] [blame] | 299 | |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 300 | // Factor all of the known-equal matchers after this one into the same |
| 301 | // group. |
| 302 | while (OptionIdx != e && OptionsToMatch[OptionIdx]->isEqual(Optn)) |
| 303 | EqualMatchers.push_back(OptionsToMatch[OptionIdx++]); |
| 304 | |
| 305 | // If we found a non-equal matcher, see if it is contradictory with the |
| 306 | // current node. If so, we know that the ordering relation between the |
| 307 | // current sets of nodes and this node don't matter. Look past it to see if |
| 308 | // we can merge anything else into this matching group. |
| 309 | unsigned Scan = OptionIdx; |
| 310 | while (1) { |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 311 | // If we ran out of stuff to scan, we're done. |
| 312 | if (Scan == e) break; |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 313 | |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 314 | Matcher *ScanMatcher = OptionsToMatch[Scan]; |
| 315 | |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 316 | // If we found an entry that matches out matcher, merge it into the set to |
| 317 | // handle. |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 318 | if (Optn->isEqual(ScanMatcher)) { |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 319 | // If is equal after all, add the option to EqualMatchers and remove it |
| 320 | // from OptionsToMatch. |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 321 | EqualMatchers.push_back(ScanMatcher); |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 322 | OptionsToMatch.erase(OptionsToMatch.begin()+Scan); |
| 323 | --e; |
| 324 | continue; |
| 325 | } |
| 326 | |
| 327 | // If the option we're checking for contradicts the start of the list, |
| 328 | // skip over it. |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 329 | if (Optn->isContradictory(ScanMatcher)) { |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 330 | ++Scan; |
| 331 | continue; |
| 332 | } |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 333 | |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 334 | // If we're scanning for a simple node, see if it occurs later in the |
| 335 | // sequence. If so, and if we can move it up, it might be contradictory |
| 336 | // or the same as what we're looking for. If so, reorder it. |
| 337 | if (Optn->isSimplePredicateOrRecordNode()) { |
| 338 | Matcher *M2 = FindNodeWithKind(ScanMatcher, Optn->getKind()); |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 339 | if (M2 && M2 != ScanMatcher && |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 340 | M2->canMoveBefore(ScanMatcher) && |
| 341 | (M2->isEqual(Optn) || M2->isContradictory(Optn))) { |
| 342 | Matcher *MatcherWithoutM2 = ScanMatcher->unlinkNode(M2); |
| 343 | M2->setNext(MatcherWithoutM2); |
| 344 | OptionsToMatch[Scan] = M2; |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 345 | continue; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | // Otherwise, we don't know how to handle this entry, we have to bail. |
| 350 | break; |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Chris Lattner | 278606b | 2010-02-27 21:48:43 +0000 | [diff] [blame] | 353 | if (Scan != e && |
| 354 | // Don't print it's obvious nothing extra could be merged anyway. |
| 355 | Scan+1 != e) { |
Chris Lattner | c95d58d | 2010-03-07 07:21:24 +0000 | [diff] [blame] | 356 | DEBUG(errs() << "Couldn't merge this:\n"; |
Chris Lattner | 2586c86 | 2010-02-27 08:11:15 +0000 | [diff] [blame] | 357 | Optn->print(errs(), 4); |
| 358 | errs() << "into this:\n"; |
| 359 | OptionsToMatch[Scan]->print(errs(), 4); |
Chris Lattner | 21a7bf3 | 2010-02-27 08:13:23 +0000 | [diff] [blame] | 360 | if (Scan+1 != e) |
Chris Lattner | 2586c86 | 2010-02-27 08:11:15 +0000 | [diff] [blame] | 361 | OptionsToMatch[Scan+1]->printOne(errs()); |
Chris Lattner | 21a7bf3 | 2010-02-27 08:13:23 +0000 | [diff] [blame] | 362 | if (Scan+2 < e) |
Chris Lattner | 2586c86 | 2010-02-27 08:11:15 +0000 | [diff] [blame] | 363 | OptionsToMatch[Scan+2]->printOne(errs()); |
Chris Lattner | c95d58d | 2010-03-07 07:21:24 +0000 | [diff] [blame] | 364 | errs() << "\n"); |
Chris Lattner | c577b81 | 2010-02-27 07:49:13 +0000 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | // If we only found one option starting with this matcher, no factoring is |
| 368 | // possible. |
| 369 | if (EqualMatchers.size() == 1) { |
| 370 | NewOptionsToMatch.push_back(EqualMatchers[0]); |
| 371 | continue; |
| 372 | } |
Chris Lattner | 4f9a671 | 2010-02-26 08:08:41 +0000 | [diff] [blame] | 373 | |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 374 | // Factor these checks by pulling the first node off each entry and |
Chris Lattner | be5b634 | 2010-02-26 07:36:37 +0000 | [diff] [blame] | 375 | // discarding it. Take the first one off the first entry to reuse. |
| 376 | Matcher *Shared = Optn; |
| 377 | Optn = Optn->takeNext(); |
| 378 | EqualMatchers[0] = Optn; |
| 379 | |
Chris Lattner | 4f9a671 | 2010-02-26 08:08:41 +0000 | [diff] [blame] | 380 | // Remove and delete the first node from the other matchers we're factoring. |
| 381 | for (unsigned i = 1, e = EqualMatchers.size(); i != e; ++i) { |
| 382 | Matcher *Tmp = EqualMatchers[i]->takeNext(); |
| 383 | delete EqualMatchers[i]; |
| 384 | EqualMatchers[i] = Tmp; |
| 385 | } |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 386 | |
Craig Topper | a2c6019 | 2014-01-21 07:20:05 +0000 | [diff] [blame] | 387 | Shared->setNext(new ScopeMatcher(EqualMatchers)); |
Chris Lattner | be5b634 | 2010-02-26 07:36:37 +0000 | [diff] [blame] | 388 | |
| 389 | // Recursively factor the newly created node. |
| 390 | FactorNodes(Shared->getNextPtr()); |
| 391 | |
| 392 | NewOptionsToMatch.push_back(Shared); |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 393 | } |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 394 | |
| 395 | // If we're down to a single pattern to match, then we don't need this scope |
| 396 | // anymore. |
| 397 | if (NewOptionsToMatch.size() == 1) { |
| 398 | MatcherPtr.reset(NewOptionsToMatch[0]); |
| 399 | return; |
| 400 | } |
| 401 | |
Chris Lattner | 664ac98 | 2010-03-01 22:04:33 +0000 | [diff] [blame] | 402 | if (NewOptionsToMatch.empty()) { |
David Blaikie | b61064e | 2014-07-19 01:05:11 +0000 | [diff] [blame^] | 403 | MatcherPtr.reset(); |
Chris Lattner | 664ac98 | 2010-03-01 22:04:33 +0000 | [diff] [blame] | 404 | return; |
| 405 | } |
| 406 | |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 407 | // If our factoring failed (didn't achieve anything) see if we can simplify in |
| 408 | // other ways. |
| 409 | |
| 410 | // Check to see if all of the leading entries are now opcode checks. If so, |
| 411 | // we can convert this Scope to be a OpcodeSwitch instead. |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 412 | bool AllOpcodeChecks = true, AllTypeChecks = true; |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 413 | for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) { |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 414 | // Check to see if this breaks a series of CheckOpcodeMatchers. |
| 415 | if (AllOpcodeChecks && |
| 416 | !isa<CheckOpcodeMatcher>(NewOptionsToMatch[i])) { |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 417 | #if 0 |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 418 | if (i > 3) { |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 419 | errs() << "FAILING OPC #" << i << "\n"; |
| 420 | NewOptionsToMatch[i]->dump(); |
| 421 | } |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 422 | #endif |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 423 | AllOpcodeChecks = false; |
| 424 | } |
| 425 | |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 426 | // Check to see if this breaks a series of CheckTypeMatcher's. |
| 427 | if (AllTypeChecks) { |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 428 | CheckTypeMatcher *CTM = |
| 429 | cast_or_null<CheckTypeMatcher>(FindNodeWithKind(NewOptionsToMatch[i], |
| 430 | Matcher::CheckType)); |
Craig Topper | 2406477 | 2014-04-15 07:20:03 +0000 | [diff] [blame] | 431 | if (!CTM || |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 432 | // iPTR checks could alias any other case without us knowing, don't |
| 433 | // bother with them. |
| 434 | CTM->getType() == MVT::iPTR || |
Chris Lattner | 6c2d178 | 2010-03-24 00:41:19 +0000 | [diff] [blame] | 435 | // SwitchType only works for result #0. |
| 436 | CTM->getResNo() != 0 || |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 437 | // If the CheckType isn't at the start of the list, see if we can move |
| 438 | // it there. |
| 439 | !CTM->canMoveBefore(NewOptionsToMatch[i])) { |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 440 | #if 0 |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 441 | if (i > 3 && AllTypeChecks) { |
| 442 | errs() << "FAILING TYPE #" << i << "\n"; |
| 443 | NewOptionsToMatch[i]->dump(); |
| 444 | } |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 445 | #endif |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 446 | AllTypeChecks = false; |
| 447 | } |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 448 | } |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | // If all the options are CheckOpcode's, we can form the SwitchOpcode, woot. |
| 452 | if (AllOpcodeChecks) { |
| 453 | StringSet<> Opcodes; |
| 454 | SmallVector<std::pair<const SDNodeInfo*, Matcher*>, 8> Cases; |
| 455 | for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) { |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 456 | CheckOpcodeMatcher *COM = cast<CheckOpcodeMatcher>(NewOptionsToMatch[i]); |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 457 | assert(Opcodes.insert(COM->getOpcode().getEnumName()) && |
| 458 | "Duplicate opcodes not factored?"); |
| 459 | Cases.push_back(std::make_pair(&COM->getOpcode(), COM->getNext())); |
| 460 | } |
| 461 | |
Craig Topper | a2c6019 | 2014-01-21 07:20:05 +0000 | [diff] [blame] | 462 | MatcherPtr.reset(new SwitchOpcodeMatcher(Cases)); |
Chris Lattner | f4d1775 | 2010-03-01 06:59:22 +0000 | [diff] [blame] | 463 | return; |
| 464 | } |
| 465 | |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 466 | // If all the options are CheckType's, we can form the SwitchType, woot. |
| 467 | if (AllTypeChecks) { |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 468 | DenseMap<unsigned, unsigned> TypeEntry; |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 469 | SmallVector<std::pair<MVT::SimpleValueType, Matcher*>, 8> Cases; |
| 470 | for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) { |
Chris Lattner | a160389 | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 471 | CheckTypeMatcher *CTM = |
| 472 | cast_or_null<CheckTypeMatcher>(FindNodeWithKind(NewOptionsToMatch[i], |
| 473 | Matcher::CheckType)); |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 474 | Matcher *MatcherWithoutCTM = NewOptionsToMatch[i]->unlinkNode(CTM); |
| 475 | MVT::SimpleValueType CTMTy = CTM->getType(); |
| 476 | delete CTM; |
| 477 | |
| 478 | unsigned &Entry = TypeEntry[CTMTy]; |
| 479 | if (Entry != 0) { |
| 480 | // If we have unfactored duplicate types, then we should factor them. |
| 481 | Matcher *PrevMatcher = Cases[Entry-1].second; |
| 482 | if (ScopeMatcher *SM = dyn_cast<ScopeMatcher>(PrevMatcher)) { |
| 483 | SM->setNumChildren(SM->getNumChildren()+1); |
| 484 | SM->resetChild(SM->getNumChildren()-1, MatcherWithoutCTM); |
| 485 | continue; |
| 486 | } |
| 487 | |
| 488 | Matcher *Entries[2] = { PrevMatcher, MatcherWithoutCTM }; |
Craig Topper | a2c6019 | 2014-01-21 07:20:05 +0000 | [diff] [blame] | 489 | Cases[Entry-1].second = new ScopeMatcher(Entries); |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 490 | continue; |
| 491 | } |
| 492 | |
| 493 | Entry = Cases.size()+1; |
| 494 | Cases.push_back(std::make_pair(CTMTy, MatcherWithoutCTM)); |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 495 | } |
| 496 | |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 497 | if (Cases.size() != 1) { |
Craig Topper | a2c6019 | 2014-01-21 07:20:05 +0000 | [diff] [blame] | 498 | MatcherPtr.reset(new SwitchTypeMatcher(Cases)); |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 499 | } else { |
| 500 | // If we factored and ended up with one case, create it now. |
Chris Lattner | 6c2d178 | 2010-03-24 00:41:19 +0000 | [diff] [blame] | 501 | MatcherPtr.reset(new CheckTypeMatcher(Cases[0].first, 0)); |
Chris Lattner | b9071a2 | 2010-03-07 07:01:28 +0000 | [diff] [blame] | 502 | MatcherPtr->setNext(Cases[0].second); |
| 503 | } |
Chris Lattner | 3e1ffd0 | 2010-03-03 06:28:15 +0000 | [diff] [blame] | 504 | return; |
| 505 | } |
| 506 | |
Chris Lattner | 62702da0 | 2010-02-25 07:45:24 +0000 | [diff] [blame] | 507 | |
Chris Lattner | 00f2e4b | 2010-03-01 22:19:47 +0000 | [diff] [blame] | 508 | // Reassemble the Scope node with the adjusted children. |
| 509 | Scope->setNumChildren(NewOptionsToMatch.size()); |
| 510 | for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) |
| 511 | Scope->resetChild(i, NewOptionsToMatch[i]); |
Chris Lattner | c36ab92 | 2010-02-25 01:57:41 +0000 | [diff] [blame] | 512 | } |
| 513 | |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 514 | Matcher *llvm::OptimizeMatcher(Matcher *TheMatcher, |
| 515 | const CodeGenDAGPatterns &CGP) { |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 516 | std::unique_ptr<Matcher> MatcherPtr(TheMatcher); |
Chris Lattner | 102a8a0 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 517 | ContractNodes(MatcherPtr, CGP); |
Chris Lattner | d9e1e83 | 2010-02-27 06:22:57 +0000 | [diff] [blame] | 518 | SinkPatternPredicates(MatcherPtr); |
Chris Lattner | c36ab92 | 2010-02-25 01:57:41 +0000 | [diff] [blame] | 519 | FactorNodes(MatcherPtr); |
Ahmed Charles | 96c9d95 | 2014-03-05 10:19:29 +0000 | [diff] [blame] | 520 | return MatcherPtr.release(); |
Chris Lattner | e732743 | 2010-02-24 07:06:50 +0000 | [diff] [blame] | 521 | } |