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

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

Issue 2333663002: [turbofan] Do constant folding for Float64Pow. (Closed)
Patch Set: Make sure to have exponent 0/-0 properly. 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
« no previous file with comments | « src/wasm/wasm-external-refs.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 Reduction const r = 1765 Reduction const r =
1766 Reduce(graph()->NewNode(machine()->Float64Log1p(), Float64Constant(x))); 1766 Reduce(graph()->NewNode(machine()->Float64Log1p(), Float64Constant(x)));
1767 ASSERT_TRUE(r.Changed()); 1767 ASSERT_TRUE(r.Changed());
1768 EXPECT_THAT( 1768 EXPECT_THAT(
1769 r.replacement(), 1769 r.replacement(),
1770 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::log1p(x)))); 1770 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::log1p(x))));
1771 } 1771 }
1772 } 1772 }
1773 1773
1774 // ----------------------------------------------------------------------------- 1774 // -----------------------------------------------------------------------------
1775 // Float64Pow
1776
1777 TEST_F(MachineOperatorReducerTest, Float64PowWithConstant) {
1778 TRACED_FOREACH(double, x, kFloat64Values) {
1779 TRACED_FOREACH(double, y, kFloat64Values) {
1780 Reduction const r = Reduce(graph()->NewNode(
1781 machine()->Float64Pow(), Float64Constant(x), Float64Constant(y)));
1782 ASSERT_TRUE(r.Changed());
1783 EXPECT_THAT(r.replacement(),
1784 IsFloat64Constant(NanSensitiveDoubleEq(Pow(x, y))));
1785 }
1786 }
1787 }
1788
1789 TEST_F(MachineOperatorReducerTest, Float64PowWithZeroExponent) {
1790 Node* const p0 = Parameter(0);
1791 {
1792 Reduction const r = Reduce(
1793 graph()->NewNode(machine()->Float64Pow(), p0, Float64Constant(-0.0)));
1794 ASSERT_TRUE(r.Changed());
1795 EXPECT_THAT(r.replacement(), IsFloat64Constant(1.0));
1796 }
1797 {
1798 Reduction const r = Reduce(
1799 graph()->NewNode(machine()->Float64Pow(), p0, Float64Constant(0.0)));
1800 ASSERT_TRUE(r.Changed());
1801 EXPECT_THAT(r.replacement(), IsFloat64Constant(1.0));
1802 }
1803 }
1804
1805 // -----------------------------------------------------------------------------
1775 // Float64Sin 1806 // Float64Sin
1776 1807
1777 TEST_F(MachineOperatorReducerTest, Float64SinWithConstant) { 1808 TEST_F(MachineOperatorReducerTest, Float64SinWithConstant) {
1778 TRACED_FOREACH(double, x, kFloat64Values) { 1809 TRACED_FOREACH(double, x, kFloat64Values) {
1779 Reduction const r = 1810 Reduction const r =
1780 Reduce(graph()->NewNode(machine()->Float64Sin(), Float64Constant(x))); 1811 Reduce(graph()->NewNode(machine()->Float64Sin(), Float64Constant(x)));
1781 ASSERT_TRUE(r.Changed()); 1812 ASSERT_TRUE(r.Changed());
1782 EXPECT_THAT(r.replacement(), 1813 EXPECT_THAT(r.replacement(),
1783 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::sin(x)))); 1814 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::sin(x))));
1784 } 1815 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 Reduction r = Reduce(node); 2100 Reduction r = Reduce(node);
2070 ASSERT_TRUE(r.Changed()); 2101 ASSERT_TRUE(r.Changed());
2071 EXPECT_THAT(r.replacement(), 2102 EXPECT_THAT(r.replacement(),
2072 IsStore(rep, base, index, value, effect, control)); 2103 IsStore(rep, base, index, value, effect, control));
2073 } 2104 }
2074 } 2105 }
2075 2106
2076 } // namespace compiler 2107 } // namespace compiler
2077 } // namespace internal 2108 } // namespace internal
2078 } // namespace v8 2109 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-external-refs.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698