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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 23219002: Add double unary operation (negate). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | runtime/vm/flow_graph_type_propagator.cc » ('j') | runtime/vm/intermediate_language_mips.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 26122)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -1220,15 +1220,12 @@
} else if (HasOnlyOneDouble(*call->ic_data()) &&
(op_kind == Token::kNEGATE)) {
AddReceiverCheck(call);
- ConstantInstr* minus_one =
- flow_graph()->GetConstant(Double::ZoneHandle(Double::NewCanonical(-1)));
- unary_op = new BinaryDoubleOpInstr(Token::kMUL,
- new Value(input),
- new Value(minus_one),
- call->deopt_id());
+ unary_op = new UnaryDoubleOpInstr(
+ Token::kNEGATE, new Value(input), call->deopt_id());
+ } else {
+ return false;
}
- if (unary_op == NULL) return false;
-
+ ASSERT(unary_op != NULL);
ReplaceCall(call, unary_op);
return true;
}
@@ -6356,6 +6353,17 @@
}
+void ConstantPropagator::VisitUnaryDoubleOp(UnaryDoubleOpInstr* instr) {
+ const Object& value = instr->value()->definition()->constant_value();
+ if (IsNonConstant(value)) {
+ SetValue(instr, non_constant_);
+ } else if (IsConstant(value)) {
+ // TODO(kmillikin): Handle unary operations.
+ SetValue(instr, non_constant_);
+ }
+}
+
+
void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) {
const Object& value = instr->value()->definition()->constant_value();
if (IsConstant(value) && value.IsInteger()) {
« no previous file with comments | « no previous file | runtime/vm/flow_graph_type_propagator.cc » ('j') | runtime/vm/intermediate_language_mips.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698