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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 829303002: [turbofan] Generalize constant propagation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation on Mac Created 5 years, 11 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: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 2338866d6d2274830dff5b132128ca3f9216659b..5b9e3dbb98fa05335f8c7e88f590e7888e745de3 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -927,14 +927,21 @@ Reduction JSTypedLowering::ReduceJSStoreContext(Node* node) {
Reduction JSTypedLowering::Reduce(Node* node) {
// Check if the output type is a singleton. In that case we already know the
- // result value and can simply replace the node unless there are effects.
+ // result value and can simply replace the node if it's eliminatable.
Jarin 2015/01/05 09:41:21 eliminatable -> eliminable?
Benedikt Meurer 2015/01/05 12:37:12 Done.
if (NodeProperties::IsTyped(node) &&
- NodeProperties::GetBounds(node).upper->IsConstant() &&
!IrOpcode::IsLeafOpcode(node->opcode()) &&
- node->op()->EffectOutputCount() == 0) {
- return ReplaceEagerly(node, jsgraph()->Constant(
- NodeProperties::GetBounds(node).upper->AsConstant()->Value()));
- // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...?
+ node->op()->HasProperty(Operator::kEliminatable)) {
+ Type* upper = NodeProperties::GetBounds(node).upper;
+ if (upper->IsConstant()) {
+ Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value());
+ NodeProperties::ReplaceWithValue(node, replacement);
+ return Changed(replacement);
+ } else if (upper->Is(Type::Number()) &&
+ base::bit_equal_to<double>()(upper->Min(), upper->Max())) {
+ Node* replacement = jsgraph()->Constant(upper->Min());
+ NodeProperties::ReplaceWithValue(node, replacement);
+ return Changed(replacement);
+ }
}
switch (node->opcode()) {
case IrOpcode::kJSEqual:

Powered by Google App Engine
This is Rietveld 408576698