Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: src/compiler/loop-peeling.cc

Issue 859053002: [turbofan] Pull ResizeMergeOrPhi into CommonOperatorBuilder and use in ControlReducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/control-reducer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/loop-peeling.h" 7 #include "src/compiler/loop-peeling.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/compiler/node-marker.h" 9 #include "src/compiler/node-marker.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // TODO(turbofan): we use a simple linear search, since the peeled iteration 154 // TODO(turbofan): we use a simple linear search, since the peeled iteration
155 // is really only used in testing. 155 // is really only used in testing.
156 PeeledIterationImpl* impl = static_cast<PeeledIterationImpl*>(this); 156 PeeledIterationImpl* impl = static_cast<PeeledIterationImpl*>(this);
157 for (size_t i = 0; i < impl->node_pairs_.size(); i += 2) { 157 for (size_t i = 0; i < impl->node_pairs_.size(); i += 2) {
158 if (impl->node_pairs_[i] == node) return impl->node_pairs_[i + 1]; 158 if (impl->node_pairs_[i] == node) return impl->node_pairs_[i + 1];
159 } 159 }
160 return node; 160 return node;
161 } 161 }
162 162
163 163
164 static const Operator* ResizeMergeOrPhi(CommonOperatorBuilder* common,
165 const Operator* op, int size) {
166 if (op->opcode() == IrOpcode::kPhi) {
167 return common->Phi(OpParameter<MachineType>(op), size);
168 } else if (op->opcode() == IrOpcode::kEffectPhi) {
169 return common->EffectPhi(size);
170 } else if (op->opcode() == IrOpcode::kMerge) {
171 return common->Merge(size);
172 } else if (op->opcode() == IrOpcode::kLoop) {
173 return common->Loop(size);
174 } else {
175 UNREACHABLE();
176 return nullptr;
177 }
178 }
179
180
181 PeeledIteration* LoopPeeler::Peel(Graph* graph, CommonOperatorBuilder* common, 164 PeeledIteration* LoopPeeler::Peel(Graph* graph, CommonOperatorBuilder* common,
182 LoopTree* loop_tree, LoopTree::Loop* loop, 165 LoopTree* loop_tree, LoopTree::Loop* loop,
183 Zone* tmp_zone) { 166 Zone* tmp_zone) {
184 PeeledIterationImpl* iter = new (tmp_zone) PeeledIterationImpl(tmp_zone); 167 PeeledIterationImpl* iter = new (tmp_zone) PeeledIterationImpl(tmp_zone);
185 Peeling peeling(graph, tmp_zone, loop->TotalSize() * 2 + 2, 168 Peeling peeling(graph, tmp_zone, loop->TotalSize() * 2 + 2,
186 &iter->node_pairs_); 169 &iter->node_pairs_);
187 170
188 //============================================================================ 171 //============================================================================
189 // Construct the peeled iteration. 172 // Construct the peeled iteration.
190 //============================================================================ 173 //============================================================================
(...skipping 27 matching lines...) Expand all
218 // Merge values from the multiple output edges of the peeled iteration. 201 // Merge values from the multiple output edges of the peeled iteration.
219 for (Node* node : loop_tree->HeaderNodes(loop)) { 202 for (Node* node : loop_tree->HeaderNodes(loop)) {
220 if (node->opcode() == IrOpcode::kLoop) continue; // already done. 203 if (node->opcode() == IrOpcode::kLoop) continue; // already done.
221 inputs.clear(); 204 inputs.clear();
222 for (int i = 0; i < backedges; i++) { 205 for (int i = 0; i < backedges; i++) {
223 inputs.push_back(peeling.map(node->InputAt(1 + i))); 206 inputs.push_back(peeling.map(node->InputAt(1 + i)));
224 } 207 }
225 for (Node* input : inputs) { 208 for (Node* input : inputs) {
226 if (input != inputs[0]) { // Non-redundant phi. 209 if (input != inputs[0]) { // Non-redundant phi.
227 inputs.push_back(merge); 210 inputs.push_back(merge);
228 const Operator* op = ResizeMergeOrPhi(common, node->op(), backedges); 211 const Operator* op = common->ResizeMergeOrPhi(node->op(), backedges);
229 Node* phi = graph->NewNode(op, backedges + 1, &inputs[0]); 212 Node* phi = graph->NewNode(op, backedges + 1, &inputs[0]);
230 node->ReplaceInput(0, phi); 213 node->ReplaceInput(0, phi);
231 break; 214 break;
232 } 215 }
233 } 216 }
234 } 217 }
235 new_entry = merge; 218 new_entry = merge;
236 } else { 219 } else {
237 // Only one backedge, simply replace the input to loop with output of 220 // Only one backedge, simply replace the input to loop with output of
238 // peeling. 221 // peeling.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 330 }
348 } 331 }
349 } 332 }
350 333
351 return iter; 334 return iter;
352 } 335 }
353 336
354 } // namespace compiler 337 } // namespace compiler
355 } // namespace internal 338 } // namespace internal
356 } // namespace v8 339 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/control-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698