Take output type into account in JSTypedLowering reduction.
authorneis@chromium.org <neis@chromium.org>
Mon, 29 Sep 2014 13:15:41 +0000 (13:15 +0000)
committerneis@chromium.org <neis@chromium.org>
Mon, 29 Sep 2014 13:15:41 +0000 (13:15 +0000)
R=rossberg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/607033002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24287 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/compiler/js-typed-lowering.cc
src/compiler/opcodes.h

index 39104bb..e6610a7 100644 (file)
@@ -630,6 +630,15 @@ static Reduction ReplaceWithReduction(Node* node, Reduction reduction) {
 
 
 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.
+  if (node->bounds().upper->IsConstant() &&
+      !IrOpcode::IsLeafOpcode(node->opcode()) &&
+      !OperatorProperties::HasEffectOutput(node->op())) {
+    return ReplaceEagerly(node, jsgraph()->Constant(
+        node->bounds().upper->AsConstant()->Value()));
+    // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...?
+  }
   switch (node->opcode()) {
     case IrOpcode::kJSEqual:
       return ReduceJSEqual(node, false);
index e210abd..80d772d 100644 (file)
@@ -289,6 +289,18 @@ class IrOpcode {
     }
   }
 
+  static bool IsLeafOpcode(Value val) {
+    switch (val) {
+#define RETURN_NAME(x) \
+  case k##x:           \
+    return true;
+      LEAF_OP_LIST(RETURN_NAME)
+#undef RETURN_NAME
+      default:
+        return false;
+    }
+  }
+
   static bool IsCommonOpcode(Value val) {
     switch (val) {
 #define RETURN_NAME(x) \