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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 215363004: Support for multiple register values (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index 5ee1e2f8212f5569771f824a17dd8a236cb2bfff..68dabd8a3cdf299fa7e5868f71b06b1970d6e824 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -303,6 +303,17 @@ void FlowGraphOptimizer::AppendLoadIndexedForMerged(Definition* instr,
}
+void FlowGraphOptimizer::AppendExtractNthOutputForMerged(Definition* instr,
+ intptr_t index,
+ Representation rep) {
+ ExtractNthOutputInstr* extract = new ExtractNthOutputInstr(new Value(instr),
+ index,
+ rep);
+ instr->ReplaceUsesWith(extract);
+ flow_graph()->InsertAfter(instr, extract, NULL, Definition::kValue);
+}
+
+
// Dart:
// var x = d % 10;
// var y = d ~/ 10;
@@ -347,28 +358,28 @@ void FlowGraphOptimizer::TryMergeTruncDivMod(
(other_binop->left()->definition() == left_def) &&
(other_binop->right()->definition() == right_def)) {
(*merge_candidates)[k] = NULL; // Clear it.
- // Append a LoadIndexed behind TRUNC_DIV and MOD.
ASSERT(curr_instr->HasUses());
- AppendLoadIndexedForMerged(
+ AppendExtractNthOutputForMerged(
curr_instr,
- MergedMathInstr::ResultIndexOf(curr_instr->op_kind()),
- kArrayCid);
+ MergedMath2Instr::OutputIndexOf(curr_instr->op_kind()),
+ kTagged);
ASSERT(other_binop->HasUses());
- AppendLoadIndexedForMerged(
+ AppendExtractNthOutputForMerged(
other_binop,
- MergedMathInstr::ResultIndexOf(other_binop->op_kind()),
- kArrayCid);
+ MergedMath2Instr::OutputIndexOf(other_binop->op_kind()),
+ kTagged);
ZoneGrowableArray<Value*>* args = new ZoneGrowableArray<Value*>(2);
args->Add(new Value(curr_instr->left()->definition()));
args->Add(new Value(curr_instr->right()->definition()));
// Replace with TruncDivMod.
- MergedMathInstr* div_mod = new MergedMathInstr(
+ MergedMath2Instr* div_mod = new MergedMath2Instr(
args,
curr_instr->deopt_id(),
- MergedMathInstr::kTruncDivMod);
+ MergedMath2Instr::kTruncDivMod);
curr_instr->ReplaceWith(div_mod, current_iterator());
+ div_mod->set_ssa_temp_index2(flow_graph()->alloc_ssa_temp_index());
other_binop->ReplaceUsesWith(div_mod);
other_binop->RemoveFromGraph();
// Only one merge possible. Because canonicalization happens later,
@@ -396,12 +407,12 @@ void FlowGraphOptimizer::TryMergeMathUnary(
// Instruction was merged already.
continue;
}
- ASSERT((curr_instr->kind() == MethodRecognizer::kMathSin) ||
- (curr_instr->kind() == MethodRecognizer::kMathCos));
+ const intptr_t kind = curr_instr->kind();
+ ASSERT((kind == MethodRecognizer::kMathSin) ||
+ (kind == MethodRecognizer::kMathCos));
// Check if there is sin/cos binop with same inputs.
- const intptr_t other_kind =
- (curr_instr->kind() == MethodRecognizer::kMathSin) ?
- MethodRecognizer::kMathCos : MethodRecognizer::kMathSin;
+ const intptr_t other_kind = (kind == MethodRecognizer::kMathSin) ?
+ MethodRecognizer::kMathCos : MethodRecognizer::kMathSin;
Definition* def = curr_instr->value()->definition();
for (intptr_t k = i + 1; k < merge_candidates->length(); k++) {
MathUnaryInstr* other_op = (*merge_candidates)[k];
@@ -409,26 +420,24 @@ void FlowGraphOptimizer::TryMergeMathUnary(
if ((other_op != NULL) && (other_op->kind() == other_kind) &&
(other_op->value()->definition() == def)) {
(*merge_candidates)[k] = NULL; // Clear it.
- // Append a LoadIndexed behind SIN and COS.
ASSERT(curr_instr->HasUses());
- AppendLoadIndexedForMerged(
- curr_instr,
- MergedMathInstr::ResultIndexOf(curr_instr->kind()),
- kTypedDataFloat64ArrayCid);
+ // TODO(johnmccutchan): Fix up input indexes.
+ AppendExtractNthOutputForMerged(curr_instr,
+ MergedMath2Instr::OutputIndexOf(kind),
+ kUnboxedDouble);
ASSERT(other_op->HasUses());
- AppendLoadIndexedForMerged(
+ AppendExtractNthOutputForMerged(
other_op,
- MergedMathInstr::ResultIndexOf(other_op->kind()),
- kTypedDataFloat64ArrayCid);
+ MergedMath2Instr::OutputIndexOf(other_kind),
+ kUnboxedDouble);
ZoneGrowableArray<Value*>* args = new ZoneGrowableArray<Value*>(1);
args->Add(new Value(curr_instr->value()->definition()));
-
// Replace with SinCos.
- MergedMathInstr* sin_cos = new MergedMathInstr(
- args,
- curr_instr->DeoptimizationTarget(),
- MergedMathInstr::kSinCos);
+ MergedMath2Instr* sin_cos =
+ new MergedMath2Instr(args, curr_instr->DeoptimizationTarget(),
+ MergedMath2Instr::kSinCos);
curr_instr->ReplaceWith(sin_cos, current_iterator());
+ sin_cos->set_ssa_temp_index2(flow_graph()->alloc_ssa_temp_index());
other_op->ReplaceUsesWith(sin_cos);
other_op->RemoveFromGraph();
// Only one merge possible. Because canonicalization happens later,
@@ -755,7 +764,7 @@ static bool UnboxPhi(PhiInstr* phi) {
void FlowGraphOptimizer::SelectRepresentations() {
- // Convervatively unbox all phis that were proven to be of Double,
+ // Conservatively unbox all phis that were proven to be of Double,
// Float32x4, or Int32x4 type.
for (intptr_t i = 0; i < block_order_.length(); ++i) {
JoinEntryInstr* join_entry = block_order_[i]->AsJoinEntry();
@@ -7913,6 +7922,16 @@ void ConstantPropagator::VisitMergedMath(MergedMathInstr* instr) {
}
+void ConstantPropagator::VisitMergedMath2(MergedMath2Instr* instr) {
+ SetValue(instr, non_constant_);
+}
+
+
+void ConstantPropagator::VisitExtractNthOutput(ExtractNthOutputInstr* instr) {
+ SetValue(instr, non_constant_);
+}
+
+
void ConstantPropagator::VisitConstant(ConstantInstr* instr) {
SetValue(instr, instr->value());
}

Powered by Google App Engine
This is Rietveld 408576698