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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 16813002: Make constant propagation to fold x == x and re-run type propagation for better range analysis. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/flow_graph_optimizer.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
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 23800)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -450,35 +450,6 @@
}
-void FlowGraphOptimizer::UnboxPhis() {
- GrowableArray<PhiInstr*> worklist(5);
-
- // Convervatively unbox all phis that were proven to be of Double,
- // Float32x4, or Uint32x4 type.
- for (intptr_t i = 0; i < block_order_.length(); ++i) {
- JoinEntryInstr* join_entry = block_order_[i]->AsJoinEntry();
- if (join_entry != NULL) {
- for (PhiIterator it(join_entry); !it.Done(); it.Advance()) {
- PhiInstr* phi = it.Current();
- if (UnboxPhi(phi)) {
- worklist.Add(phi);
- }
- }
- }
- }
-
- while (!worklist.is_empty()) {
- PhiInstr* phi = worklist.RemoveLast();
- InsertConversionsFor(phi);
-
- for (intptr_t i = 0; i < phi->InputCount(); i++) {
- ConvertUse(phi->InputAt(i),
- phi->InputAt(i)->definition()->representation());
- }
- }
-}
-
-
void FlowGraphOptimizer::SelectRepresentations() {
// Convervatively unbox all phis that were proven to be of Double,
// Float32x4, or Uint32x4 type.
@@ -4822,6 +4793,7 @@
void ConstantPropagator::OptimizeBranches(FlowGraph* graph) {
GrowableArray<BlockEntryInstr*> ignored;
ConstantPropagator cp(graph, ignored);
+ cp.Analyze();
cp.VisitBranches();
cp.Transform();
}
@@ -5160,6 +5132,15 @@
const Object& left = instr->left()->definition()->constant_value();
const Object& right = instr->right()->definition()->constant_value();
+ if (instr->left()->definition() == instr->right()->definition()) {
+ // Fold x === x, and x !== x to true/false.
+ SetValue(instr,
+ (instr->kind() == Token::kEQ_STRICT)
+ ? Bool::True()
+ : Bool::False());
+ return;
+ }
+
if (IsNonConstant(left) || IsNonConstant(right)) {
// TODO(vegorov): incorporate nullability information into the lattice.
if ((left.IsNull() && instr->right()->Type()->HasDecidableNullability()) ||
@@ -5200,6 +5181,23 @@
void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) {
const Object& left = instr->left()->definition()->constant_value();
const Object& right = instr->right()->definition()->constant_value();
+
+ if (instr->left()->definition() == instr->right()->definition()) {
+ // Fold x == x, and x != x to true/false for numbers and checked strict
+ // comparisons.
+ switch (instr->receiver_class_id()) {
+ default:
+ if (!instr->is_checked_strict_equal()) break;
Kevin Millikin (Google) 2013/06/12 10:02:44 I have two things to say about this. 1. It is rea
Florian Schneider 2013/06/12 10:11:20 Undone. Using IsNumberCid instead of the switch.
+ // Fall through.
+ case kSmiCid:
+ case kMintCid:
+ case kDoubleCid:
+ SetValue(instr,
+ (instr->kind() == Token::kEQ) ? Bool::True() : Bool::False());
+ return;
+ }
+ }
+
if (IsNonConstant(left) || IsNonConstant(right)) {
SetValue(instr, non_constant_);
} else if (IsConstant(left) && IsConstant(right)) {
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698