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

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

Issue 2116753002: [builtins] Unify most of the remaining Math builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2102223005
Patch Set: Created 4 years, 5 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 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 } 1416 }
1417 { 1417 {
1418 Reduction r = Reduce( 1418 Reduction r = Reduce(
1419 graph()->NewNode(machine()->Float64Mul(), Float64Constant(-1.0), p0)); 1419 graph()->NewNode(machine()->Float64Mul(), Float64Constant(-1.0), p0));
1420 ASSERT_TRUE(r.Changed()); 1420 ASSERT_TRUE(r.Changed());
1421 EXPECT_THAT(r.replacement(), 1421 EXPECT_THAT(r.replacement(),
1422 IsFloat64Sub(IsFloat64Constant(BitEq(-0.0)), p0)); 1422 IsFloat64Sub(IsFloat64Constant(BitEq(-0.0)), p0));
1423 } 1423 }
1424 } 1424 }
1425 1425
1426 // -----------------------------------------------------------------------------
1427 // Float64Acos
1428
1429 TEST_F(MachineOperatorReducerTest, Float64AcosWithConstant) {
1430 TRACED_FOREACH(double, x, kFloat64Values) {
1431 Reduction const r =
1432 Reduce(graph()->NewNode(machine()->Float64Acos(), Float64Constant(x)));
1433 ASSERT_TRUE(r.Changed());
1434 EXPECT_THAT(
1435 r.replacement(),
1436 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::acos(x))));
1437 }
1438 }
1439
1440 // -----------------------------------------------------------------------------
1441 // Float64Acosh
1442
1443 TEST_F(MachineOperatorReducerTest, Float64AcoshWithConstant) {
1444 TRACED_FOREACH(double, x, kFloat64Values) {
1445 Reduction const r =
1446 Reduce(graph()->NewNode(machine()->Float64Acosh(), Float64Constant(x)));
1447 ASSERT_TRUE(r.Changed());
1448 EXPECT_THAT(
1449 r.replacement(),
1450 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::acosh(x))));
1451 }
1452 }
1453
1454 // -----------------------------------------------------------------------------
1455 // Float64Asin
1456
1457 TEST_F(MachineOperatorReducerTest, Float64AsinWithConstant) {
1458 TRACED_FOREACH(double, x, kFloat64Values) {
1459 Reduction const r =
1460 Reduce(graph()->NewNode(machine()->Float64Asin(), Float64Constant(x)));
1461 ASSERT_TRUE(r.Changed());
1462 EXPECT_THAT(
1463 r.replacement(),
1464 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::asin(x))));
1465 }
1466 }
1467
1468 // -----------------------------------------------------------------------------
1469 // Float64Asinh
1470
1471 TEST_F(MachineOperatorReducerTest, Float64AsinhWithConstant) {
1472 TRACED_FOREACH(double, x, kFloat64Values) {
1473 Reduction const r =
1474 Reduce(graph()->NewNode(machine()->Float64Asinh(), Float64Constant(x)));
1475 ASSERT_TRUE(r.Changed());
1476 EXPECT_THAT(
1477 r.replacement(),
1478 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::asinh(x))));
1479 }
1480 }
1426 1481
1427 // ----------------------------------------------------------------------------- 1482 // -----------------------------------------------------------------------------
1428 // Float64Atan 1483 // Float64Atan
1429 1484
1430 TEST_F(MachineOperatorReducerTest, Float64AtanWithConstant) { 1485 TEST_F(MachineOperatorReducerTest, Float64AtanWithConstant) {
1431 TRACED_FOREACH(double, x, kFloat64Values) { 1486 TRACED_FOREACH(double, x, kFloat64Values) {
1432 Reduction const r = 1487 Reduction const r =
1433 Reduce(graph()->NewNode(machine()->Float64Atan(), Float64Constant(x))); 1488 Reduce(graph()->NewNode(machine()->Float64Atan(), Float64Constant(x)));
1434 ASSERT_TRUE(r.Changed()); 1489 ASSERT_TRUE(r.Changed());
1435 EXPECT_THAT( 1490 EXPECT_THAT(
1436 r.replacement(), 1491 r.replacement(),
1437 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::atan(x)))); 1492 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::atan(x))));
1438 } 1493 }
1439 } 1494 }
1440 1495
1441 // ----------------------------------------------------------------------------- 1496 // -----------------------------------------------------------------------------
1497 // Float64Atanh
1498
1499 TEST_F(MachineOperatorReducerTest, Float64AtanhWithConstant) {
1500 TRACED_FOREACH(double, x, kFloat64Values) {
1501 Reduction const r =
1502 Reduce(graph()->NewNode(machine()->Float64Atanh(), Float64Constant(x)));
1503 ASSERT_TRUE(r.Changed());
1504 EXPECT_THAT(
1505 r.replacement(),
1506 IsFloat64Constant(NanSensitiveDoubleEq(base::ieee754::atanh(x))));
1507 }
1508 }
1509
1510 // -----------------------------------------------------------------------------
1442 // Float64Atan2 1511 // Float64Atan2
1443 1512
1444 TEST_F(MachineOperatorReducerTest, Float64Atan2WithConstant) { 1513 TEST_F(MachineOperatorReducerTest, Float64Atan2WithConstant) {
1445 TRACED_FOREACH(double, y, kFloat64Values) { 1514 TRACED_FOREACH(double, y, kFloat64Values) {
1446 TRACED_FOREACH(double, x, kFloat64Values) { 1515 TRACED_FOREACH(double, x, kFloat64Values) {
1447 Reduction const r = Reduce(graph()->NewNode( 1516 Reduction const r = Reduce(graph()->NewNode(
1448 machine()->Float64Atan2(), Float64Constant(y), Float64Constant(x))); 1517 machine()->Float64Atan2(), Float64Constant(y), Float64Constant(x)));
1449 ASSERT_TRUE(r.Changed()); 1518 ASSERT_TRUE(r.Changed());
1450 EXPECT_THAT( 1519 EXPECT_THAT(
1451 r.replacement(), 1520 r.replacement(),
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 Reduction r = Reduce(node); 1905 Reduction r = Reduce(node);
1837 ASSERT_TRUE(r.Changed()); 1906 ASSERT_TRUE(r.Changed());
1838 EXPECT_THAT(r.replacement(), 1907 EXPECT_THAT(r.replacement(),
1839 IsStore(rep, base, index, value, effect, control)); 1908 IsStore(rep, base, index, value, effect, control));
1840 } 1909 }
1841 } 1910 }
1842 1911
1843 } // namespace compiler 1912 } // namespace compiler
1844 } // namespace internal 1913 } // namespace internal
1845 } // namespace v8 1914 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698