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 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 Reduction r = Reduce(node); | 1642 Reduction r = Reduce(node); |
1643 ASSERT_TRUE(r.Changed()); | 1643 ASSERT_TRUE(r.Changed()); |
1644 EXPECT_THAT(r.replacement(), | 1644 EXPECT_THAT(r.replacement(), |
1645 IsStore(rep, base, index, value, effect, control)); | 1645 IsStore(rep, base, index, value, effect, control)); |
1646 } | 1646 } |
1647 } | 1647 } |
1648 | 1648 |
1649 | 1649 |
1650 TEST_F(MachineOperatorReducerTest, RoundPlusTruncate) { | 1650 TEST_F(MachineOperatorReducerTest, RoundPlusTruncate) { |
1651 Node* p0 = Parameter(0); | 1651 Node* p0 = Parameter(0); |
1652 | |
1653 Type* p0_range = Type::Range(0x0, 0xFFFFFF8000001ULL, graph()->zone()); | |
1654 NodeProperties::SetType( | |
1655 p0, Type::Intersect(p0_range, Type::Number(), graph()->zone())); | |
1656 | |
1657 Node* t0 = graph()->NewNode(machine()->RoundInt64ToFloat64(), p0); | 1652 Node* t0 = graph()->NewNode(machine()->RoundInt64ToFloat64(), p0); |
1658 Node* t1 = graph()->NewNode( | 1653 Node* t1 = graph()->NewNode( |
1659 machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript), t0); | 1654 machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript), t0); |
1660 | 1655 |
1661 Reduction r = Reduce(t1); | 1656 Reduction r = Reduce(t1); |
1662 ASSERT_TRUE(r.Changed()); | 1657 ASSERT_TRUE(r.Changed()); |
1663 EXPECT_THAT(r.replacement(), IsTruncateInt64ToInt32(p0)); | 1658 EXPECT_THAT(r.replacement(), p0); |
1664 } | |
1665 | |
1666 | |
1667 TEST_F(MachineOperatorReducerTest, OverflowingRoundPlusTruncate) { | |
1668 Node* p0 = Parameter(0); | |
1669 | |
1670 Type* p0_range = Type::Range(0x0, 0x10000000000000ULL, graph()->zone()); | |
1671 NodeProperties::SetType( | |
1672 p0, Type::Intersect(p0_range, Type::Number(), graph()->zone())); | |
1673 | |
1674 Node* t0 = graph()->NewNode(machine()->RoundInt64ToFloat64(), p0); | |
1675 Node* t1 = graph()->NewNode( | |
1676 machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript), t0); | |
1677 | |
1678 Reduction r = Reduce(t1); | |
1679 ASSERT_TRUE(!r.Changed()); | |
1680 } | 1659 } |
1681 | 1660 |
1682 } // namespace compiler | 1661 } // namespace compiler |
1683 } // namespace internal | 1662 } // namespace internal |
1684 } // namespace v8 | 1663 } // namespace v8 |
OLD | NEW |