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

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

Issue 649083005: [turbofan] Optimize Int32Mod by power-of-two. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « test/unittests/compiler/graph-unittest.cc ('k') | no next file » | 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 6c46a5bd95874848eedc5a327756170c08b2fba6..9ee74cee0990d2fdab59d4fe3952b6a36bf62c5b 100644
--- a/test/unittests/compiler/machine-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc
@@ -7,6 +7,11 @@
#include "src/compiler/machine-operator-reducer.h"
#include "src/compiler/typer.h"
#include "test/unittests/compiler/graph-unittest.h"
+#include "testing/gmock-support.h"
+
+using testing::AllOf;
+using testing::Capture;
+using testing::CaptureEq;
namespace v8 {
namespace internal {
@@ -564,6 +569,37 @@ TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Shr) {
// -----------------------------------------------------------------------------
+// Int32Mod
+
+
+TEST_F(MachineOperatorReducerTest, Int32ModWithPowerOfTwo) {
+ Node* p0 = Parameter(0);
+ TRACED_FORRANGE(int32_t, x, 1, 30) {
+ int32_t const divisor = 1 << x;
+ Node* node =
+ graph()->NewNode(machine()->Int32Mod(), p0, Int32Constant(divisor));
+ Reduction r = Reduce(node);
+ ASSERT_TRUE(r.Changed());
+
+ Capture<Node*> branch;
+ Node* phi = r.replacement();
+ int32_t const mask = divisor - 1;
+ EXPECT_THAT(
+ phi, IsPhi(kMachInt32,
+ IsInt32Sub(IsInt32Constant(0),
+ IsWord32And(IsInt32Sub(IsInt32Constant(0), p0),
+ IsInt32Constant(mask))),
+ IsWord32And(p0, IsInt32Constant(mask)),
+ IsMerge(IsIfTrue(CaptureEq(&branch)),
+ IsIfFalse(AllOf(
+ CaptureEq(&branch),
+ IsBranch(IsInt32LessThan(p0, IsInt32Constant(0)),
+ graph()->start()))))));
+ }
+}
+
+
+// -----------------------------------------------------------------------------
// Int32AddWithOverflow
« no previous file with comments | « test/unittests/compiler/graph-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698