| 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/base/bits.h" | 5 #include "src/base/bits.h" |
| 6 #include "src/base/division-by-constant.h" | 6 #include "src/base/division-by-constant.h" |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/machine-operator-reducer.h" | 8 #include "src/compiler/machine-operator-reducer.h" |
| 9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
| 10 #include "src/conversions-inl.h" | 10 #include "src/conversions-inl.h" |
| (...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 Node* const p1 = Parameter(1); | 1447 Node* const p1 = Parameter(1); |
| 1448 Reduction const r = Reduce(graph()->NewNode( | 1448 Reduction const r = Reduce(graph()->NewNode( |
| 1449 machine()->Float64Equal(), | 1449 machine()->Float64Equal(), |
| 1450 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), | 1450 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), |
| 1451 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p1))); | 1451 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p1))); |
| 1452 ASSERT_TRUE(r.Changed()); | 1452 ASSERT_TRUE(r.Changed()); |
| 1453 EXPECT_THAT(r.replacement(), IsFloat32Equal(p0, p1)); | 1453 EXPECT_THAT(r.replacement(), IsFloat32Equal(p0, p1)); |
| 1454 } | 1454 } |
| 1455 | 1455 |
| 1456 | 1456 |
| 1457 TEST_F(MachineOperatorReducerTest, Float64EqualWithFloat32Constant) { |
| 1458 Node* const p0 = Parameter(0); |
| 1459 TRACED_FOREACH(float, x, kFloat32Values) { |
| 1460 Reduction r = Reduce(graph()->NewNode( |
| 1461 machine()->Float64Equal(), |
| 1462 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), |
| 1463 Float64Constant(x))); |
| 1464 ASSERT_TRUE(r.Changed()); |
| 1465 EXPECT_THAT(r.replacement(), IsFloat32Equal(p0, IsFloat32Constant(x))); |
| 1466 } |
| 1467 } |
| 1468 |
| 1469 |
| 1457 // ----------------------------------------------------------------------------- | 1470 // ----------------------------------------------------------------------------- |
| 1458 // Float64LessThan | 1471 // Float64LessThan |
| 1459 | 1472 |
| 1460 | 1473 |
| 1461 TEST_F(MachineOperatorReducerTest, Float64LessThanWithFloat32Conversions) { | 1474 TEST_F(MachineOperatorReducerTest, Float64LessThanWithFloat32Conversions) { |
| 1462 Node* const p0 = Parameter(0); | 1475 Node* const p0 = Parameter(0); |
| 1463 Node* const p1 = Parameter(1); | 1476 Node* const p1 = Parameter(1); |
| 1464 Reduction const r = Reduce(graph()->NewNode( | 1477 Reduction const r = Reduce(graph()->NewNode( |
| 1465 machine()->Float64LessThan(), | 1478 machine()->Float64LessThan(), |
| 1466 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), | 1479 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), |
| 1467 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p1))); | 1480 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p1))); |
| 1468 ASSERT_TRUE(r.Changed()); | 1481 ASSERT_TRUE(r.Changed()); |
| 1469 EXPECT_THAT(r.replacement(), IsFloat32LessThan(p0, p1)); | 1482 EXPECT_THAT(r.replacement(), IsFloat32LessThan(p0, p1)); |
| 1470 } | 1483 } |
| 1471 | 1484 |
| 1472 | 1485 |
| 1486 TEST_F(MachineOperatorReducerTest, Float64LessThanWithFloat32Constant) { |
| 1487 Node* const p0 = Parameter(0); |
| 1488 { |
| 1489 TRACED_FOREACH(float, x, kFloat32Values) { |
| 1490 Reduction r = Reduce(graph()->NewNode( |
| 1491 machine()->Float64LessThan(), |
| 1492 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), |
| 1493 Float64Constant(x))); |
| 1494 ASSERT_TRUE(r.Changed()); |
| 1495 EXPECT_THAT(r.replacement(), IsFloat32LessThan(p0, IsFloat32Constant(x))); |
| 1496 } |
| 1497 } |
| 1498 { |
| 1499 TRACED_FOREACH(float, x, kFloat32Values) { |
| 1500 Reduction r = Reduce(graph()->NewNode( |
| 1501 machine()->Float64LessThan(), Float64Constant(x), |
| 1502 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0))); |
| 1503 ASSERT_TRUE(r.Changed()); |
| 1504 EXPECT_THAT(r.replacement(), IsFloat32LessThan(IsFloat32Constant(x), p0)); |
| 1505 } |
| 1506 } |
| 1507 } |
| 1508 |
| 1509 |
| 1473 // ----------------------------------------------------------------------------- | 1510 // ----------------------------------------------------------------------------- |
| 1474 // Float64LessThanOrEqual | 1511 // Float64LessThanOrEqual |
| 1475 | 1512 |
| 1476 | 1513 |
| 1477 TEST_F(MachineOperatorReducerTest, | 1514 TEST_F(MachineOperatorReducerTest, |
| 1478 Float64LessThanOrEqualWithFloat32Conversions) { | 1515 Float64LessThanOrEqualWithFloat32Conversions) { |
| 1479 Node* const p0 = Parameter(0); | 1516 Node* const p0 = Parameter(0); |
| 1480 Node* const p1 = Parameter(1); | 1517 Node* const p1 = Parameter(1); |
| 1481 Reduction const r = Reduce(graph()->NewNode( | 1518 Reduction const r = Reduce(graph()->NewNode( |
| 1482 machine()->Float64LessThanOrEqual(), | 1519 machine()->Float64LessThanOrEqual(), |
| 1483 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), | 1520 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), |
| 1484 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p1))); | 1521 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p1))); |
| 1485 ASSERT_TRUE(r.Changed()); | 1522 ASSERT_TRUE(r.Changed()); |
| 1486 EXPECT_THAT(r.replacement(), IsFloat32LessThanOrEqual(p0, p1)); | 1523 EXPECT_THAT(r.replacement(), IsFloat32LessThanOrEqual(p0, p1)); |
| 1487 } | 1524 } |
| 1488 | 1525 |
| 1489 | 1526 |
| 1527 TEST_F(MachineOperatorReducerTest, Float64LessThanOrEqualWithFloat32Constant) { |
| 1528 Node* const p0 = Parameter(0); |
| 1529 { |
| 1530 TRACED_FOREACH(float, x, kFloat32Values) { |
| 1531 Reduction r = Reduce(graph()->NewNode( |
| 1532 machine()->Float64LessThanOrEqual(), |
| 1533 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0), |
| 1534 Float64Constant(x))); |
| 1535 ASSERT_TRUE(r.Changed()); |
| 1536 EXPECT_THAT(r.replacement(), |
| 1537 IsFloat32LessThanOrEqual(p0, IsFloat32Constant(x))); |
| 1538 } |
| 1539 } |
| 1540 { |
| 1541 TRACED_FOREACH(float, x, kFloat32Values) { |
| 1542 Reduction r = Reduce(graph()->NewNode( |
| 1543 machine()->Float64LessThanOrEqual(), Float64Constant(x), |
| 1544 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), p0))); |
| 1545 ASSERT_TRUE(r.Changed()); |
| 1546 EXPECT_THAT(r.replacement(), |
| 1547 IsFloat32LessThanOrEqual(IsFloat32Constant(x), p0)); |
| 1548 } |
| 1549 } |
| 1550 } |
| 1551 |
| 1552 |
| 1490 // ----------------------------------------------------------------------------- | 1553 // ----------------------------------------------------------------------------- |
| 1491 // Store | 1554 // Store |
| 1492 | 1555 |
| 1493 | 1556 |
| 1494 TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) { | 1557 TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) { |
| 1495 const StoreRepresentation rep(kMachUint8, kNoWriteBarrier); | 1558 const StoreRepresentation rep(kMachUint8, kNoWriteBarrier); |
| 1496 Node* const base = Parameter(0); | 1559 Node* const base = Parameter(0); |
| 1497 Node* const index = Parameter(1); | 1560 Node* const index = Parameter(1); |
| 1498 Node* const value = Parameter(2); | 1561 Node* const value = Parameter(2); |
| 1499 Node* const effect = graph()->start(); | 1562 Node* const effect = graph()->start(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 Reduction r = Reduce(node); | 1641 Reduction r = Reduce(node); |
| 1579 ASSERT_TRUE(r.Changed()); | 1642 ASSERT_TRUE(r.Changed()); |
| 1580 EXPECT_THAT(r.replacement(), | 1643 EXPECT_THAT(r.replacement(), |
| 1581 IsStore(rep, base, index, value, effect, control)); | 1644 IsStore(rep, base, index, value, effect, control)); |
| 1582 } | 1645 } |
| 1583 } | 1646 } |
| 1584 | 1647 |
| 1585 } // namespace compiler | 1648 } // namespace compiler |
| 1586 } // namespace internal | 1649 } // namespace internal |
| 1587 } // namespace v8 | 1650 } // namespace v8 |
| OLD | NEW |