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

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

Issue 2347573002: [turbofan] Reduce some Float64 division to multiplication (Closed)
Patch Set: Move power of two tests to matcher 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/node-matchers.h ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/machine-operator-reducer-unittest.cc
diff --git a/test/unittests/compiler/machine-operator-reducer-unittest.cc b/test/unittests/compiler/machine-operator-reducer-unittest.cc
index 127ddf355718cf677ce26f9a9630fc65fa39e63c..7d71d30c5a709ed76121d6f2db01fc58006a1bbf 100644
--- a/test/unittests/compiler/machine-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc
@@ -1587,6 +1587,48 @@ TEST_F(MachineOperatorReducerTest, Float32SubMinusZeroMinusX) {
}
}
+TEST_F(MachineOperatorReducerTest, Float64MulWithTwo) {
+ Node* const p0 = Parameter(0);
+ {
+ Reduction r = Reduce(
+ graph()->NewNode(machine()->Float64Mul(), Float64Constant(2.0), p0));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsFloat64Add(p0, p0));
+ }
+ {
+ Reduction r = Reduce(
+ graph()->NewNode(machine()->Float64Mul(), p0, Float64Constant(2.0)));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsFloat64Add(p0, p0));
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Float64Div
+
+TEST_F(MachineOperatorReducerTest, Float64DivWithMinusOne) {
+ Node* const p0 = Parameter(0);
+ {
+ Reduction r = Reduce(
+ graph()->NewNode(machine()->Float64Div(), p0, Float64Constant(-1.0)));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsFloat64Neg(p0));
+ }
+}
+
+TEST_F(MachineOperatorReducerTest, Float64DivWithPowerOfTwo) {
+ Node* const p0 = Parameter(0);
+ TRACED_FORRANGE(uint64_t, exponent, 1, 0x7fe) {
+ Double divisor = Double(exponent << Double::kPhysicalSignificandSize);
+ if (divisor.value() == 1.0) continue; // Skip x / 1.0 => x.
+ Reduction r = Reduce(graph()->NewNode(machine()->Float64Div(), p0,
+ Float64Constant(divisor.value())));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(),
+ IsFloat64Mul(p0, IsFloat64Constant(1.0 / divisor.value())));
+ }
+}
+
// -----------------------------------------------------------------------------
// Float64Acos
« no previous file with comments | « src/compiler/node-matchers.h ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698