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 |