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/machine-operator-reducer.h" | 5 #include "src/compiler/machine-operator-reducer.h" |
6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
7 #include "src/base/division-by-constant.h" | 7 #include "src/base/division-by-constant.h" |
8 #include "src/base/ieee754.h" | 8 #include "src/base/ieee754.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 } | 1457 } |
1458 { | 1458 { |
1459 Reduction const r = | 1459 Reduction const r = |
1460 Reduce(graph()->NewNode(machine()->Float64Atan2(), nan, p0)); | 1460 Reduce(graph()->NewNode(machine()->Float64Atan2(), nan, p0)); |
1461 ASSERT_TRUE(r.Changed()); | 1461 ASSERT_TRUE(r.Changed()); |
1462 EXPECT_EQ(nan, r.replacement()); | 1462 EXPECT_EQ(nan, r.replacement()); |
1463 } | 1463 } |
1464 } | 1464 } |
1465 | 1465 |
1466 // ----------------------------------------------------------------------------- | 1466 // ----------------------------------------------------------------------------- |
| 1467 // Float64Cos |
| 1468 |
| 1469 TEST_F(MachineOperatorReducerTest, Float64CosWithConstant) { |
| 1470 TRACED_FOREACH(double, x, kFloat64Values) { |
| 1471 Reduction const r = |
| 1472 Reduce(graph()->NewNode(machine()->Float64Cos(), Float64Constant(x))); |
| 1473 ASSERT_TRUE(r.Changed()); |
| 1474 EXPECT_THAT(r.replacement(), |
| 1475 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::cos(x)))); |
| 1476 } |
| 1477 } |
| 1478 |
| 1479 // ----------------------------------------------------------------------------- |
1467 // Float64Exp | 1480 // Float64Exp |
1468 | 1481 |
1469 TEST_F(MachineOperatorReducerTest, Float64ExpWithConstant) { | 1482 TEST_F(MachineOperatorReducerTest, Float64ExpWithConstant) { |
1470 TRACED_FOREACH(double, x, kFloat64Values) { | 1483 TRACED_FOREACH(double, x, kFloat64Values) { |
1471 Reduction const r = | 1484 Reduction const r = |
1472 Reduce(graph()->NewNode(machine()->Float64Exp(), Float64Constant(x))); | 1485 Reduce(graph()->NewNode(machine()->Float64Exp(), Float64Constant(x))); |
1473 ASSERT_TRUE(r.Changed()); | 1486 ASSERT_TRUE(r.Changed()); |
1474 EXPECT_THAT(r.replacement(), | 1487 EXPECT_THAT(r.replacement(), |
1475 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::exp(x)))); | 1488 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::exp(x)))); |
1476 } | 1489 } |
(...skipping 20 matching lines...) Expand all Loading... |
1497 Reduction const r = | 1510 Reduction const r = |
1498 Reduce(graph()->NewNode(machine()->Float64Log1p(), Float64Constant(x))); | 1511 Reduce(graph()->NewNode(machine()->Float64Log1p(), Float64Constant(x))); |
1499 ASSERT_TRUE(r.Changed()); | 1512 ASSERT_TRUE(r.Changed()); |
1500 EXPECT_THAT( | 1513 EXPECT_THAT( |
1501 r.replacement(), | 1514 r.replacement(), |
1502 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::log1p(x)))); | 1515 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::log1p(x)))); |
1503 } | 1516 } |
1504 } | 1517 } |
1505 | 1518 |
1506 // ----------------------------------------------------------------------------- | 1519 // ----------------------------------------------------------------------------- |
| 1520 // Float64Sin |
| 1521 |
| 1522 TEST_F(MachineOperatorReducerTest, Float64SinWithConstant) { |
| 1523 TRACED_FOREACH(double, x, kFloat64Values) { |
| 1524 Reduction const r = |
| 1525 Reduce(graph()->NewNode(machine()->Float64Sin(), Float64Constant(x))); |
| 1526 ASSERT_TRUE(r.Changed()); |
| 1527 EXPECT_THAT(r.replacement(), |
| 1528 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::sin(x)))); |
| 1529 } |
| 1530 } |
| 1531 |
| 1532 // ----------------------------------------------------------------------------- |
1507 // Float64InsertLowWord32 | 1533 // Float64InsertLowWord32 |
1508 | 1534 |
1509 TEST_F(MachineOperatorReducerTest, Float64InsertLowWord32WithConstant) { | 1535 TEST_F(MachineOperatorReducerTest, Float64InsertLowWord32WithConstant) { |
1510 TRACED_FOREACH(double, x, kFloat64Values) { | 1536 TRACED_FOREACH(double, x, kFloat64Values) { |
1511 TRACED_FOREACH(uint32_t, y, kUint32Values) { | 1537 TRACED_FOREACH(uint32_t, y, kUint32Values) { |
1512 Reduction const r = | 1538 Reduction const r = |
1513 Reduce(graph()->NewNode(machine()->Float64InsertLowWord32(), | 1539 Reduce(graph()->NewNode(machine()->Float64InsertLowWord32(), |
1514 Float64Constant(x), Uint32Constant(y))); | 1540 Float64Constant(x), Uint32Constant(y))); |
1515 ASSERT_TRUE(r.Changed()); | 1541 ASSERT_TRUE(r.Changed()); |
1516 EXPECT_THAT( | 1542 EXPECT_THAT( |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 Reduction r = Reduce(node); | 1773 Reduction r = Reduce(node); |
1748 ASSERT_TRUE(r.Changed()); | 1774 ASSERT_TRUE(r.Changed()); |
1749 EXPECT_THAT(r.replacement(), | 1775 EXPECT_THAT(r.replacement(), |
1750 IsStore(rep, base, index, value, effect, control)); | 1776 IsStore(rep, base, index, value, effect, control)); |
1751 } | 1777 } |
1752 } | 1778 } |
1753 | 1779 |
1754 } // namespace compiler | 1780 } // namespace compiler |
1755 } // namespace internal | 1781 } // namespace internal |
1756 } // namespace v8 | 1782 } // namespace v8 |
OLD | NEW |