Index: src/compiler/machine-operator-reducer-unittest.cc |
diff --git a/src/compiler/machine-operator-reducer-unittest.cc b/src/compiler/machine-operator-reducer-unittest.cc |
index 6b27b12670432e4f9a75ae358166d7a3637d4ab7..cad5112978a732d14ea15473040d1b3f06dbb518 100644 |
--- a/src/compiler/machine-operator-reducer-unittest.cc |
+++ b/src/compiler/machine-operator-reducer-unittest.cc |
@@ -46,6 +46,29 @@ class MachineOperatorReducerTestWithParam |
namespace { |
+static const float kFloat32Values[] = { |
+ -V8_INFINITY, -2.70497e+38f, -1.4698e+37f, -1.22813e+35f, -1.20555e+35f, |
+ -1.34584e+34f, -1.0079e+32f, -6.49364e+26f, -3.06077e+25f, -1.46821e+25f, |
+ -1.17658e+23f, -1.9617e+22f, -2.7357e+20f, -1.48708e+13f, -1.89633e+12f, |
+ -4.66622e+11f, -2.22581e+11f, -1.45381e+10f, -1.3956e+09f, -1.32951e+09f, |
+ -1.30721e+09f, -1.19756e+09f, -9.26822e+08f, -6.35647e+08f, -4.00037e+08f, |
+ -1.81227e+08f, -5.09256e+07f, -964300.0f, -192446.0f, -28455.0f, |
+ -27194.0f, -26401.0f, -20575.0f, -17069.0f, -9167.0f, |
+ -960.178f, -113.0f, -62.0f, -15.0f, -7.0f, |
+ -0.0256635f, -4.60374e-07f, -3.63759e-10f, -4.30175e-14f, -5.27385e-15f, |
+ -1.48084e-15f, -1.05755e-19f, -3.2995e-21f, -1.67354e-23f, -1.11885e-23f, |
+ -1.78506e-30f, -5.07594e-31f, -3.65799e-31f, -1.43718e-34f, -1.27126e-38f, |
+ -0.0f, 0.0f, 1.17549e-38f, 1.56657e-37f, 4.08512e-29f, |
+ 3.31357e-28f, 6.25073e-22f, 4.1723e-13f, 1.44343e-09f, 5.27004e-08f, |
+ 9.48298e-08f, 5.57888e-07f, 4.89988e-05f, 0.244326f, 12.4895f, |
+ 19.0f, 47.0f, 106.0f, 538.324f, 564.536f, |
+ 819.124f, 7048.0f, 12611.0f, 19878.0f, 20309.0f, |
+ 797056.0f, 1.77219e+09f, 1.51116e+11f, 4.18193e+13f, 3.59167e+16f, |
+ 3.38211e+19f, 2.67488e+20f, 1.78831e+21f, 9.20914e+21f, 8.35654e+23f, |
+ 1.4495e+24f, 5.94015e+25f, 4.43608e+30f, 2.44502e+33f, 2.61152e+33f, |
+ 1.38178e+37f, 1.71306e+37f, 3.31899e+38f, 3.40282e+38f, V8_INFINITY}; |
+ |
+ |
static const double kFloat64Values[] = { |
-V8_INFINITY, -4.23878e+275, -5.82632e+265, -6.60355e+220, -6.26172e+212, |
-2.56222e+211, -4.82408e+201, -1.84106e+157, -1.63662e+127, -1.55772e+100, |
@@ -206,6 +229,20 @@ INSTANTIATE_TEST_CASE_P(MachineOperatorReducerTest, |
// ----------------------------------------------------------------------------- |
+// ChangeFloat64ToFloat32 |
+ |
+ |
+TEST_F(MachineOperatorReducerTest, ChangeFloat64ToFloat32WithConstant) { |
+ TRACED_FOREACH(float, x, kFloat32Values) { |
+ Reduction reduction = Reduce(graph()->NewNode( |
+ machine()->ChangeFloat32ToFloat64(), Float32Constant(x))); |
+ ASSERT_TRUE(reduction.Changed()); |
+ EXPECT_THAT(reduction.replacement(), IsFloat64Constant(x)); |
+ } |
+} |
+ |
+ |
+// ----------------------------------------------------------------------------- |
// ChangeFloat64ToInt32 |
@@ -315,6 +352,31 @@ TEST_F(MachineOperatorReducerTest, ChangeUint32ToUint64WithConstant) { |
// ----------------------------------------------------------------------------- |
+// TruncateFloat64ToFloat32 |
+ |
+ |
+TEST_F(MachineOperatorReducerTest, |
+ TruncateFloat64ToFloat32WithChangeFloat32ToFloat64) { |
+ Node* value = Parameter(0); |
+ Reduction reduction = Reduce(graph()->NewNode( |
+ machine()->TruncateFloat64ToFloat32(), |
+ graph()->NewNode(machine()->ChangeFloat32ToFloat64(), value))); |
+ ASSERT_TRUE(reduction.Changed()); |
+ EXPECT_EQ(value, reduction.replacement()); |
+} |
+ |
+ |
+TEST_F(MachineOperatorReducerTest, TruncateFloat64ToFloat32WithConstant) { |
+ TRACED_FOREACH(double, x, kFloat64Values) { |
+ Reduction reduction = Reduce(graph()->NewNode( |
+ machine()->TruncateFloat64ToFloat32(), Float64Constant(x))); |
+ ASSERT_TRUE(reduction.Changed()); |
+ EXPECT_THAT(reduction.replacement(), IsFloat32Constant(DoubleToFloat32(x))); |
+ } |
+} |
+ |
+ |
+// ----------------------------------------------------------------------------- |
// TruncateFloat64ToInt32 |