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 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 TRACED_FOREACH(double, x, kFloat64Values) { | 1478 TRACED_FOREACH(double, x, kFloat64Values) { |
1479 Reduction const r = | 1479 Reduction const r = |
1480 Reduce(graph()->NewNode(machine()->Float64Cos(), Float64Constant(x))); | 1480 Reduce(graph()->NewNode(machine()->Float64Cos(), Float64Constant(x))); |
1481 ASSERT_TRUE(r.Changed()); | 1481 ASSERT_TRUE(r.Changed()); |
1482 EXPECT_THAT(r.replacement(), | 1482 EXPECT_THAT(r.replacement(), |
1483 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::cos(x)))); | 1483 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::cos(x)))); |
1484 } | 1484 } |
1485 } | 1485 } |
1486 | 1486 |
1487 // ----------------------------------------------------------------------------- | 1487 // ----------------------------------------------------------------------------- |
| 1488 // Float64Cosh |
| 1489 |
| 1490 TEST_F(MachineOperatorReducerTest, Float64CoshWithConstant) { |
| 1491 TRACED_FOREACH(double, x, kFloat64Values) { |
| 1492 Reduction const r = |
| 1493 Reduce(graph()->NewNode(machine()->Float64Cosh(), Float64Constant(x))); |
| 1494 ASSERT_TRUE(r.Changed()); |
| 1495 EXPECT_THAT( |
| 1496 r.replacement(), |
| 1497 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::cosh(x)))); |
| 1498 } |
| 1499 } |
| 1500 |
| 1501 // ----------------------------------------------------------------------------- |
1488 // Float64Exp | 1502 // Float64Exp |
1489 | 1503 |
1490 TEST_F(MachineOperatorReducerTest, Float64ExpWithConstant) { | 1504 TEST_F(MachineOperatorReducerTest, Float64ExpWithConstant) { |
1491 TRACED_FOREACH(double, x, kFloat64Values) { | 1505 TRACED_FOREACH(double, x, kFloat64Values) { |
1492 Reduction const r = | 1506 Reduction const r = |
1493 Reduce(graph()->NewNode(machine()->Float64Exp(), Float64Constant(x))); | 1507 Reduce(graph()->NewNode(machine()->Float64Exp(), Float64Constant(x))); |
1494 ASSERT_TRUE(r.Changed()); | 1508 ASSERT_TRUE(r.Changed()); |
1495 EXPECT_THAT(r.replacement(), | 1509 EXPECT_THAT(r.replacement(), |
1496 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::exp(x)))); | 1510 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::exp(x)))); |
1497 } | 1511 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 TRACED_FOREACH(double, x, kFloat64Values) { | 1545 TRACED_FOREACH(double, x, kFloat64Values) { |
1532 Reduction const r = | 1546 Reduction const r = |
1533 Reduce(graph()->NewNode(machine()->Float64Sin(), Float64Constant(x))); | 1547 Reduce(graph()->NewNode(machine()->Float64Sin(), Float64Constant(x))); |
1534 ASSERT_TRUE(r.Changed()); | 1548 ASSERT_TRUE(r.Changed()); |
1535 EXPECT_THAT(r.replacement(), | 1549 EXPECT_THAT(r.replacement(), |
1536 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::sin(x)))); | 1550 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::sin(x)))); |
1537 } | 1551 } |
1538 } | 1552 } |
1539 | 1553 |
1540 // ----------------------------------------------------------------------------- | 1554 // ----------------------------------------------------------------------------- |
| 1555 // Float64Sinh |
| 1556 |
| 1557 TEST_F(MachineOperatorReducerTest, Float64SinhWithConstant) { |
| 1558 TRACED_FOREACH(double, x, kFloat64Values) { |
| 1559 Reduction const r = |
| 1560 Reduce(graph()->NewNode(machine()->Float64Sinh(), Float64Constant(x))); |
| 1561 ASSERT_TRUE(r.Changed()); |
| 1562 EXPECT_THAT( |
| 1563 r.replacement(), |
| 1564 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::sinh(x)))); |
| 1565 } |
| 1566 } |
| 1567 |
| 1568 // ----------------------------------------------------------------------------- |
1541 // Float64Tan | 1569 // Float64Tan |
1542 | 1570 |
1543 TEST_F(MachineOperatorReducerTest, Float64TanWithConstant) { | 1571 TEST_F(MachineOperatorReducerTest, Float64TanWithConstant) { |
1544 TRACED_FOREACH(double, x, kFloat64Values) { | 1572 TRACED_FOREACH(double, x, kFloat64Values) { |
1545 Reduction const r = | 1573 Reduction const r = |
1546 Reduce(graph()->NewNode(machine()->Float64Tan(), Float64Constant(x))); | 1574 Reduce(graph()->NewNode(machine()->Float64Tan(), Float64Constant(x))); |
1547 ASSERT_TRUE(r.Changed()); | 1575 ASSERT_TRUE(r.Changed()); |
1548 EXPECT_THAT(r.replacement(), | 1576 EXPECT_THAT(r.replacement(), |
1549 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::tan(x)))); | 1577 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::tan(x)))); |
1550 } | 1578 } |
1551 } | 1579 } |
1552 | 1580 |
1553 // ----------------------------------------------------------------------------- | 1581 // ----------------------------------------------------------------------------- |
| 1582 // Float64Tanh |
| 1583 |
| 1584 TEST_F(MachineOperatorReducerTest, Float64TanhWithConstant) { |
| 1585 TRACED_FOREACH(double, x, kFloat64Values) { |
| 1586 Reduction const r = |
| 1587 Reduce(graph()->NewNode(machine()->Float64Tanh(), Float64Constant(x))); |
| 1588 ASSERT_TRUE(r.Changed()); |
| 1589 EXPECT_THAT( |
| 1590 r.replacement(), |
| 1591 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::tanh(x)))); |
| 1592 } |
| 1593 } |
| 1594 |
| 1595 // ----------------------------------------------------------------------------- |
1554 // Float64InsertLowWord32 | 1596 // Float64InsertLowWord32 |
1555 | 1597 |
1556 TEST_F(MachineOperatorReducerTest, Float64InsertLowWord32WithConstant) { | 1598 TEST_F(MachineOperatorReducerTest, Float64InsertLowWord32WithConstant) { |
1557 TRACED_FOREACH(double, x, kFloat64Values) { | 1599 TRACED_FOREACH(double, x, kFloat64Values) { |
1558 TRACED_FOREACH(uint32_t, y, kUint32Values) { | 1600 TRACED_FOREACH(uint32_t, y, kUint32Values) { |
1559 Reduction const r = | 1601 Reduction const r = |
1560 Reduce(graph()->NewNode(machine()->Float64InsertLowWord32(), | 1602 Reduce(graph()->NewNode(machine()->Float64InsertLowWord32(), |
1561 Float64Constant(x), Uint32Constant(y))); | 1603 Float64Constant(x), Uint32Constant(y))); |
1562 ASSERT_TRUE(r.Changed()); | 1604 ASSERT_TRUE(r.Changed()); |
1563 EXPECT_THAT( | 1605 EXPECT_THAT( |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 Reduction r = Reduce(node); | 1836 Reduction r = Reduce(node); |
1795 ASSERT_TRUE(r.Changed()); | 1837 ASSERT_TRUE(r.Changed()); |
1796 EXPECT_THAT(r.replacement(), | 1838 EXPECT_THAT(r.replacement(), |
1797 IsStore(rep, base, index, value, effect, control)); | 1839 IsStore(rep, base, index, value, effect, control)); |
1798 } | 1840 } |
1799 } | 1841 } |
1800 | 1842 |
1801 } // namespace compiler | 1843 } // namespace compiler |
1802 } // namespace internal | 1844 } // namespace internal |
1803 } // namespace v8 | 1845 } // namespace v8 |
OLD | NEW |