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

Unified Diff: test/unittests/compiler/js-intrinsic-lowering-unittest.cc

Issue 1048063002: Added %_Likely/%_Unlikely intrinsics (special cases of GCC's __builin_expect). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed feedback. Win fix. Created 5 years, 9 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/runtime/runtime-internal.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/js-intrinsic-lowering-unittest.cc
diff --git a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc
index 8adbc54ac2d9c530ae3c018cc99a014b46815dba..582d78ad3d42e307d2d16079c2117ccf01def6d7 100644
--- a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc
+++ b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "src/compiler/access-builder.h"
+#include "src/compiler/diamond.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-intrinsic-lowering.h"
#include "src/compiler/js-operator.h"
@@ -10,6 +11,7 @@
#include "test/unittests/compiler/node-test-utils.h"
#include "testing/gmock-support.h"
+
using testing::_;
using testing::AllOf;
using testing::BitEq;
@@ -243,6 +245,30 @@ TEST_F(JSIntrinsicLoweringTest, InlineJSValueGetValue) {
// -----------------------------------------------------------------------------
+// %_Likely
+
+TEST_F(JSIntrinsicLoweringTest, Likely) {
+ Node* const input = Parameter(0);
+ Node* const context = Parameter(1);
+ Node* const effect = graph()->start();
+ Node* const control = graph()->start();
+ Node* const likely =
+ graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineLikely, 1),
+ input, context, effect, control);
+ Node* const to_boolean =
+ graph()->NewNode(javascript()->ToBoolean(), likely, context);
+ Diamond d(graph(), common(), to_boolean);
+ graph()->SetEnd(graph()->NewNode(common()->End(), d.merge));
+
+ ASSERT_EQ(BranchHint::kNone, BranchHintOf(d.branch->op()));
+ Reduction const r = Reduce(likely);
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), input);
+ ASSERT_EQ(BranchHint::kTrue, BranchHintOf(d.branch->op()));
+}
+
+
+// -----------------------------------------------------------------------------
// %_MathFloor
@@ -313,6 +339,30 @@ TEST_F(JSIntrinsicLoweringTest, InlineMathClz32) {
// -----------------------------------------------------------------------------
+// %_Unlikely
+
+TEST_F(JSIntrinsicLoweringTest, Unlikely) {
+ Node* const input = Parameter(0);
+ Node* const context = Parameter(1);
+ Node* const effect = graph()->start();
+ Node* const control = graph()->start();
+ Node* const unlikely =
+ graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineUnlikely, 1),
+ input, context, effect, control);
+ Node* const to_boolean =
+ graph()->NewNode(javascript()->ToBoolean(), unlikely, context);
+ Diamond d(graph(), common(), to_boolean);
+ graph()->SetEnd(graph()->NewNode(common()->End(), d.merge));
+
+ ASSERT_EQ(BranchHint::kNone, BranchHintOf(d.branch->op()));
+ Reduction const r = Reduce(unlikely);
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), input);
+ ASSERT_EQ(BranchHint::kFalse, BranchHintOf(d.branch->op()));
+}
+
+
+// -----------------------------------------------------------------------------
// %_ValueOf
« no previous file with comments | « src/runtime/runtime-internal.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698