Reviewers: dcarney,
Description:
[turbofan] Avoid generating dead BooleanNot nodes in typed lowering.
Without this shortcut we generate one BooleanNot per JSUnaryNot with
number input, which is quite common in asm.js. This dead node then
survive until the late control reducer runs, and may prevent
optimizations in the mean time.
[email protected]
Please review this at https://codereview.chromium.org/963713002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+16, -0 lines):
M src/compiler/js-typed-lowering.cc
M test/unittests/compiler/js-typed-lowering-unittest.cc
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc
b/src/compiler/js-typed-lowering.cc
index
57669362a00ae42c44f0937b81d9047192f82658..26425c988e99500b23f2d0b37a423980835b9662
100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -516,6 +516,12 @@ Reduction JSTypedLowering::ReduceJSUnaryNot(Node*
node) {
node->set_op(simplified()->BooleanNot());
node->TrimInputCount(1);
return Changed(node);
+ } else if (input_type->Is(Type::OrderedNumber())) {
+ // JSUnaryNot(x:number,context) => NumberEqual(x,#0)
+ node->set_op(simplified()->NumberEqual());
+ node->ReplaceInput(1, jsgraph()->ZeroConstant());
+ DCHECK_EQ(2, node->InputCount());
+ return Changed(node);
}
// JSUnaryNot(x,context) => BooleanNot(AnyToBoolean(x))
node->set_op(simplified()->BooleanNot());
Index: test/unittests/compiler/js-typed-lowering-unittest.cc
diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc
b/test/unittests/compiler/js-typed-lowering-unittest.cc
index
d61a1817b21e00bba60d15a96909af2400431ba3..4fb4b2422be33b31d4f81e08d8d8c3d1c0711fb6
100644
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
@@ -119,6 +119,16 @@ TEST_F(JSTypedLoweringTest, JSUnaryNotWithBoolean) {
}
+TEST_F(JSTypedLoweringTest, JSUnaryNotWithOrderedNumber) {
+ Node* input = Parameter(Type::OrderedNumber(), 0);
+ Node* context = Parameter(Type::Any(), 1);
+ Reduction r =
+ Reduce(graph()->NewNode(javascript()->UnaryNot(), input, context));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsNumberEqual(input, IsNumberConstant(0)));
+}
+
+
TEST_F(JSTypedLoweringTest, JSUnaryNotWithFalsish) {
Node* input = Parameter(
Type::Union(
--
--
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/d/optout.