Revision: 18985
Author: [email protected]
Date: Fri Jan 31 12:03:32 2014 UTC
Log: Load elimination fix: load should not be replaced with another
load if the former is not dominated by the latter.
[email protected]
Review URL: https://codereview.chromium.org/151333003
http://code.google.com/p/v8/source/detail?r=18985
Modified:
/branches/bleeding_edge/src/hydrogen-load-elimination.cc
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/hydrogen.h
/branches/bleeding_edge/test/mjsunit/compiler/load-elimination.js
=======================================
--- /branches/bleeding_edge/src/hydrogen-load-elimination.cc Tue Jan 28
16:57:39 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen-load-elimination.cc Fri Jan 31
12:03:32 2014 UTC
@@ -203,9 +203,12 @@
// Load is not redundant. Fill out a new entry.
approx->last_value_ = instr;
return instr;
- } else {
+ } else if (approx->last_value_->block()->EqualToOrDominates(
+ instr->block())) {
// Eliminate the load. Reuse previously stored value or load
instruction.
return approx->last_value_;
+ } else {
+ return instr;
}
}
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Fri Jan 31 00:29:04 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc Fri Jan 31 12:03:32 2014 UTC
@@ -300,6 +300,12 @@
}
return false;
}
+
+
+bool HBasicBlock::EqualToOrDominates(HBasicBlock* other) const {
+ if (this == other) return true;
+ return Dominates(other);
+}
int HBasicBlock::LoopNestingDepth() const {
=======================================
--- /branches/bleeding_edge/src/hydrogen.h Thu Jan 30 13:18:41 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen.h Fri Jan 31 12:03:32 2014 UTC
@@ -112,6 +112,7 @@
void RemovePhi(HPhi* phi);
void AddInstruction(HInstruction* instr, int position);
bool Dominates(HBasicBlock* other) const;
+ bool EqualToOrDominates(HBasicBlock* other) const;
int LoopNestingDepth() const;
void SetInitialEnvironment(HEnvironment* env);
=======================================
--- /branches/bleeding_edge/test/mjsunit/compiler/load-elimination.js Tue
Jan 28 16:45:04 2014 UTC
+++ /branches/bleeding_edge/test/mjsunit/compiler/load-elimination.js Fri
Jan 31 12:03:32 2014 UTC
@@ -42,6 +42,26 @@
var a = new B(1, 2);
return a.x + a.x + a.x + a.x;
}
+
+
+function test_load_from_different_contexts() {
+ var r = 1;
+ this.f = function() {
+ var fr = r;
+ this.g = function(flag) {
+ var gr;
+ if (flag) {
+ gr = r;
+ } else {
+ gr = r;
+ }
+ return gr + r + fr;
+ };
+ };
+ this.f();
+ return this.g(true);
+}
+
function test_store_load() {
var a = new B(1, 2);
@@ -128,6 +148,7 @@
}
test(4, test_load);
+test(3, new test_load_from_different_contexts().g);
test(22, test_store_load);
test(8, test_nonaliasing_store1);
test(5, test_transitioning_store1);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.