Index: test/cctest/compiler/test-simplified-lowering.cc |
diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc |
index da75cc4cc7a4bd039ae1b36d21e2211523dd0931..163fdc8fb731feb488ed490f817d31ddf9d82935 100644 |
--- a/test/cctest/compiler/test-simplified-lowering.cc |
+++ b/test/cctest/compiler/test-simplified-lowering.cc |
@@ -810,6 +810,63 @@ TEST(LowerBooleanNot_tagged_tagged) { |
} |
+TEST(LowerBooleanToNumber_bit_int32) { |
+ // BooleanToNumber(x: kRepBit) used as kMachInt32 |
+ TestingGraph t(Type::Boolean()); |
+ Node* b = t.ExampleWithOutput(kRepBit); |
+ Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); |
+ Node* use = t.Use(cnv, kMachInt32); |
+ t.Return(use); |
+ t.Lower(); |
+ CHECK_EQ(b, use->InputAt(0)); |
+} |
+ |
+ |
+TEST(LowerBooleanToNumber_tagged_int32) { |
+ // BooleanToNumber(x: kRepTagged) used as kMachInt32 |
+ TestingGraph t(Type::Boolean()); |
+ Node* b = t.p0; |
+ Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); |
+ Node* use = t.Use(cnv, kMachInt32); |
+ t.Return(use); |
+ t.Lower(); |
+ CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); |
+ CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); |
+ Node* c = t.jsgraph.TrueConstant(); |
+ CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); |
+} |
+ |
+ |
+TEST(LowerBooleanToNumber_bit_tagged) { |
+ // BooleanToNumber(x: kRepBit) used as kMachAnyTagged |
+ TestingGraph t(Type::Boolean()); |
+ Node* b = t.ExampleWithOutput(kRepBit); |
+ Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); |
+ Node* use = t.Use(cnv, kMachAnyTagged); |
+ t.Return(use); |
+ t.Lower(); |
+ CHECK_EQ(b, use->InputAt(0)->InputAt(0)); |
+ CHECK_EQ(IrOpcode::kChangeInt32ToTagged, use->InputAt(0)->opcode()); |
+} |
+ |
+ |
+TEST(LowerBooleanToNumber_tagged_tagged) { |
+ // BooleanToNumber(x: kRepTagged) used as kMachAnyTagged |
+ TestingGraph t(Type::Boolean()); |
+ Node* b = t.p0; |
+ Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); |
+ Node* use = t.Use(cnv, kMachAnyTagged); |
+ t.Return(use); |
+ t.Lower(); |
+ CHECK_EQ(cnv, use->InputAt(0)->InputAt(0)); |
+ CHECK_EQ(IrOpcode::kChangeInt32ToTagged, use->InputAt(0)->opcode()); |
+ CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); |
+ CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); |
+ Node* c = t.jsgraph.TrueConstant(); |
+ CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); |
+} |
+ |
+ |
static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), |
Type::Number(), Type::Any()}; |