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

Unified Diff: runtime/vm/constant_propagator.cc

Issue 943273004: Fold BIT_NOT and NEGATE during constant propagation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests. Created 5 years, 10 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 | « runtime/vm/constant_propagator.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/constant_propagator.cc
diff --git a/runtime/vm/constant_propagator.cc b/runtime/vm/constant_propagator.cc
index 8cbb12d2480cbd59db596ff84f3764831d91aa71..08f80d8d7c2207101e54e4ac63dd0355bd85ca46 100644
--- a/runtime/vm/constant_propagator.cc
+++ b/runtime/vm/constant_propagator.cc
@@ -957,20 +957,29 @@ void ConstantPropagator::VisitUnboxInt64(UnboxInt64Instr* instr) {
}
+void ConstantPropagator::VisitUnaryIntegerOp(UnaryIntegerOpInstr* unary_op) {
+ const Object& value = unary_op->value()->definition()->constant_value();
+ if (IsConstant(value) && value.IsInteger()) {
+ const Integer& value_int = Integer::Cast(value);
+ const Integer& result =
+ Integer::Handle(I, unary_op->Evaluate(value_int));
+ if (!result.IsNull()) {
+ SetValue(unary_op, Integer::ZoneHandle(I, result.raw()));
+ return;
+ }
+ }
+
+ SetValue(unary_op, non_constant_);
+}
+
+
void ConstantPropagator::VisitUnaryMintOp(UnaryMintOpInstr* instr) {
- // TODO(kmillikin): Handle unary operations.
- SetValue(instr, non_constant_);
+ VisitUnaryIntegerOp(instr);
}
void ConstantPropagator::VisitUnarySmiOp(UnarySmiOpInstr* 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_);
- }
+ VisitUnaryIntegerOp(instr);
}
« no previous file with comments | « runtime/vm/constant_propagator.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698