| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
| 8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
| 9 #include "src/compiler/simplified-operator-reducer.h" | 9 #include "src/compiler/simplified-operator-reducer.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 const double kNaNs[] = {-std::numeric_limits<double>::quiet_NaN(), | 113 const double kNaNs[] = {-std::numeric_limits<double>::quiet_NaN(), |
| 114 std::numeric_limits<double>::quiet_NaN(), | 114 std::numeric_limits<double>::quiet_NaN(), |
| 115 bit_cast<double>(V8_UINT64_C(0x7FFFFFFFFFFFFFFF)), | 115 bit_cast<double>(V8_UINT64_C(0x7FFFFFFFFFFFFFFF)), |
| 116 bit_cast<double>(V8_UINT64_C(0xFFFFFFFFFFFFFFFF))}; | 116 bit_cast<double>(V8_UINT64_C(0xFFFFFFFFFFFFFFFF))}; |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| 119 | 119 |
| 120 | 120 |
| 121 // ----------------------------------------------------------------------------- | 121 // ----------------------------------------------------------------------------- |
| 122 // AnyToBoolean | |
| 123 | |
| 124 | |
| 125 TEST_F(SimplifiedOperatorReducerTest, AnyToBooleanWithBoolean) { | |
| 126 Node* p = Parameter(Type::Boolean()); | |
| 127 Reduction r = Reduce(graph()->NewNode(simplified()->AnyToBoolean(), p)); | |
| 128 ASSERT_TRUE(r.Changed()); | |
| 129 EXPECT_EQ(p, r.replacement()); | |
| 130 } | |
| 131 | |
| 132 | |
| 133 TEST_F(SimplifiedOperatorReducerTest, AnyToBooleanWithOrderedNumber) { | |
| 134 Node* p = Parameter(Type::OrderedNumber()); | |
| 135 Reduction r = Reduce(graph()->NewNode(simplified()->AnyToBoolean(), p)); | |
| 136 ASSERT_TRUE(r.Changed()); | |
| 137 EXPECT_THAT(r.replacement(), | |
| 138 IsBooleanNot(IsNumberEqual(p, IsNumberConstant(0)))); | |
| 139 } | |
| 140 | |
| 141 | |
| 142 TEST_F(SimplifiedOperatorReducerTest, AnyToBooleanWithString) { | |
| 143 Node* p = Parameter(Type::String()); | |
| 144 Reduction r = Reduce(graph()->NewNode(simplified()->AnyToBoolean(), p)); | |
| 145 ASSERT_TRUE(r.Changed()); | |
| 146 EXPECT_THAT(r.replacement(), | |
| 147 IsBooleanNot( | |
| 148 IsNumberEqual(IsLoadField(AccessBuilder::ForStringLength(), p, | |
| 149 graph()->start(), graph()->start()), | |
| 150 IsNumberConstant(0)))); | |
| 151 } | |
| 152 | |
| 153 | |
| 154 // ----------------------------------------------------------------------------- | |
| 155 // BooleanNot | 122 // BooleanNot |
| 156 | 123 |
| 157 | 124 |
| 158 TEST_F(SimplifiedOperatorReducerTest, BooleanNotWithBooleanNot) { | 125 TEST_F(SimplifiedOperatorReducerTest, BooleanNotWithBooleanNot) { |
| 159 Node* param0 = Parameter(0); | 126 Node* param0 = Parameter(0); |
| 160 Reduction reduction = Reduce( | 127 Reduction reduction = Reduce( |
| 161 graph()->NewNode(simplified()->BooleanNot(), | 128 graph()->NewNode(simplified()->BooleanNot(), |
| 162 graph()->NewNode(simplified()->BooleanNot(), param0))); | 129 graph()->NewNode(simplified()->BooleanNot(), param0))); |
| 163 ASSERT_TRUE(reduction.Changed()); | 130 ASSERT_TRUE(reduction.Changed()); |
| 164 EXPECT_EQ(param0, reduction.replacement()); | 131 EXPECT_EQ(param0, reduction.replacement()); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), | 396 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), |
| 430 Int32Constant(bit_cast<int32_t>(n)))); | 397 Int32Constant(bit_cast<int32_t>(n)))); |
| 431 ASSERT_TRUE(reduction.Changed()); | 398 ASSERT_TRUE(reduction.Changed()); |
| 432 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastUI2D(n)))); | 399 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastUI2D(n)))); |
| 433 } | 400 } |
| 434 } | 401 } |
| 435 | 402 |
| 436 } // namespace compiler | 403 } // namespace compiler |
| 437 } // namespace internal | 404 } // namespace internal |
| 438 } // namespace v8 | 405 } // namespace v8 |
| OLD | NEW |