Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/unittests/compiler/machine-operator-reducer-unittest.cc

Issue 2347573002: [turbofan] Reduce some Float64 division to multiplication (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 TEST_F(MachineOperatorReducerTest, Float32SubMinusZeroMinusX) { 1580 TEST_F(MachineOperatorReducerTest, Float32SubMinusZeroMinusX) {
1581 Node* const p0 = Parameter(0); 1581 Node* const p0 = Parameter(0);
1582 { 1582 {
1583 Reduction r = Reduce( 1583 Reduction r = Reduce(
1584 graph()->NewNode(machine()->Float32Sub(), Float32Constant(-0.0), p0)); 1584 graph()->NewNode(machine()->Float32Sub(), Float32Constant(-0.0), p0));
1585 ASSERT_TRUE(r.Changed()); 1585 ASSERT_TRUE(r.Changed());
1586 EXPECT_THAT(r.replacement(), IsFloat32Neg(p0)); 1586 EXPECT_THAT(r.replacement(), IsFloat32Neg(p0));
1587 } 1587 }
1588 } 1588 }
1589 1589
1590 TEST_F(MachineOperatorReducerTest, Float64MulWithTwo) {
1591 Node* const p0 = Parameter(0);
1592 {
1593 Reduction r = Reduce(
1594 graph()->NewNode(machine()->Float64Mul(), Float64Constant(2.0), p0));
1595 ASSERT_TRUE(r.Changed());
1596 EXPECT_THAT(r.replacement(), IsFloat64Add(p0, p0));
1597 }
1598 {
1599 Reduction r = Reduce(
1600 graph()->NewNode(machine()->Float64Mul(), p0, Float64Constant(2.0)));
1601 ASSERT_TRUE(r.Changed());
1602 EXPECT_THAT(r.replacement(), IsFloat64Add(p0, p0));
1603 }
1604 }
1605
1606 // -----------------------------------------------------------------------------
1607 // Float64Div
1608
1609 TEST_F(MachineOperatorReducerTest, Float64DivWithMinusOne) {
1610 Node* const p0 = Parameter(0);
1611 {
1612 Reduction r = Reduce(
1613 graph()->NewNode(machine()->Float64Div(), p0, Float64Constant(-1.0)));
1614 ASSERT_TRUE(r.Changed());
1615 EXPECT_THAT(r.replacement(), IsFloat64Neg(p0));
1616 }
1617 }
1618
1619 TEST_F(MachineOperatorReducerTest, Float64DivWithPowerOfTwo) {
1620 Node* const p0 = Parameter(0);
1621 TRACED_FORRANGE(uint64_t, exponent, 1, 0x7fe) {
1622 Double divisor = Double(exponent << Double::kPhysicalSignificandSize);
1623 if (divisor.value() == 1.0) continue; // Skip x / 1.0 => x.
1624 Reduction r = Reduce(graph()->NewNode(machine()->Float64Div(), p0,
1625 Float64Constant(divisor.value())));
1626 ASSERT_TRUE(r.Changed());
1627 EXPECT_THAT(r.replacement(),
1628 IsFloat64Mul(p0, IsFloat64Constant(1.0 / divisor.value())));
1629 }
1630 }
1631
1590 // ----------------------------------------------------------------------------- 1632 // -----------------------------------------------------------------------------
1591 // Float64Acos 1633 // Float64Acos
1592 1634
1593 TEST_F(MachineOperatorReducerTest, Float64AcosWithConstant) { 1635 TEST_F(MachineOperatorReducerTest, Float64AcosWithConstant) {
1594 TRACED_FOREACH(double, x, kFloat64Values) { 1636 TRACED_FOREACH(double, x, kFloat64Values) {
1595 Reduction const r = 1637 Reduction const r =
1596 Reduce(graph()->NewNode(machine()->Float64Acos(), Float64Constant(x))); 1638 Reduce(graph()->NewNode(machine()->Float64Acos(), Float64Constant(x)));
1597 ASSERT_TRUE(r.Changed()); 1639 ASSERT_TRUE(r.Changed());
1598 EXPECT_THAT( 1640 EXPECT_THAT(
1599 r.replacement(), 1641 r.replacement(),
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 Reduction r = Reduce(node); 2142 Reduction r = Reduce(node);
2101 ASSERT_TRUE(r.Changed()); 2143 ASSERT_TRUE(r.Changed());
2102 EXPECT_THAT(r.replacement(), 2144 EXPECT_THAT(r.replacement(),
2103 IsStore(rep, base, index, value, effect, control)); 2145 IsStore(rep, base, index, value, effect, control));
2104 } 2146 }
2105 } 2147 }
2106 2148
2107 } // namespace compiler 2149 } // namespace compiler
2108 } // namespace internal 2150 } // namespace internal
2109 } // namespace v8 2151 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698