Index: test/unittests/compiler/change-lowering-unittest.cc |
diff --git a/test/unittests/compiler/change-lowering-unittest.cc b/test/unittests/compiler/change-lowering-unittest.cc |
index 50119ece2d54efef51f92aff4294302891f30f7d..5cfb8fdc41960c689b0ec329d4c0a6f27ff251a0 100644 |
--- a/test/unittests/compiler/change-lowering-unittest.cc |
+++ b/test/unittests/compiler/change-lowering-unittest.cc |
@@ -23,45 +23,15 @@ namespace v8 { |
namespace internal { |
namespace compiler { |
-class ChangeLoweringTest : public GraphTest { |
+class ChangeLoweringTest : public TypedGraphTest { |
public: |
ChangeLoweringTest() : simplified_(zone()) {} |
- ~ChangeLoweringTest() OVERRIDE {} |
virtual MachineType WordRepresentation() const = 0; |
protected: |
- int HeapNumberValueOffset() const { |
- STATIC_ASSERT(HeapNumber::kValueOffset % kApiPointerSize == 0); |
- return (HeapNumber::kValueOffset / kApiPointerSize) * PointerSize() - |
- kHeapObjectTag; |
- } |
bool Is32() const { return WordRepresentation() == kRepWord32; } |
- int PointerSize() const { |
- switch (WordRepresentation()) { |
- case kRepWord32: |
- return 4; |
- case kRepWord64: |
- return 8; |
- default: |
- break; |
- } |
- UNREACHABLE(); |
- return 0; |
- } |
- int SmiMaxValue() const { return -(SmiMinValue() + 1); } |
- int SmiMinValue() const { |
- return static_cast<int>(0xffffffffu << (SmiValueSize() - 1)); |
- } |
- int SmiShiftAmount() const { return kSmiTagSize + SmiShiftSize(); } |
- int SmiShiftSize() const { |
- return Is32() ? SmiTagging<4>::SmiShiftSize() |
- : SmiTagging<8>::SmiShiftSize(); |
- } |
- int SmiValueSize() const { |
- return Is32() ? SmiTagging<4>::SmiValueSize() |
- : SmiTagging<8>::SmiValueSize(); |
- } |
+ bool Is64() const { return WordRepresentation() == kRepWord64; } |
Reduction Reduce(Node* node) { |
MachineOperatorBuilder machine(zone(), WordRepresentation()); |
@@ -80,15 +50,33 @@ class ChangeLoweringTest : public GraphTest { |
IsNumberConstant(BitEq(0.0)), effect_matcher, |
control_matcher); |
} |
+ Matcher<Node*> IsChangeInt32ToSmi(const Matcher<Node*>& value_matcher) { |
+ return Is64() ? IsWord64Shl(IsChangeInt32ToInt64(value_matcher), |
+ IsSmiShiftBitsConstant()) |
+ : IsWord32Shl(value_matcher, IsSmiShiftBitsConstant()); |
+ } |
+ Matcher<Node*> IsChangeSmiToInt32(const Matcher<Node*>& value_matcher) { |
+ return Is64() ? IsTruncateInt64ToInt32( |
+ IsWord64Sar(value_matcher, IsSmiShiftBitsConstant())) |
+ : IsWord32Sar(value_matcher, IsSmiShiftBitsConstant()); |
+ } |
+ Matcher<Node*> IsChangeUint32ToSmi(const Matcher<Node*>& value_matcher) { |
+ return Is64() ? IsWord64Shl(IsChangeUint32ToUint64(value_matcher), |
+ IsSmiShiftBitsConstant()) |
+ : IsWord32Shl(value_matcher, IsSmiShiftBitsConstant()); |
+ } |
Matcher<Node*> IsLoadHeapNumber(const Matcher<Node*>& value_matcher, |
const Matcher<Node*>& control_matcher) { |
return IsLoad(kMachFloat64, value_matcher, |
- IsIntPtrConstant(HeapNumberValueOffset()), graph()->start(), |
- control_matcher); |
+ IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), |
+ graph()->start(), control_matcher); |
} |
Matcher<Node*> IsIntPtrConstant(int value) { |
return Is32() ? IsInt32Constant(value) : IsInt64Constant(value); |
} |
+ Matcher<Node*> IsSmiShiftBitsConstant() { |
+ return IsIntPtrConstant(kSmiShiftSize + kSmiTagSize); |
+ } |
Matcher<Node*> IsWordEqual(const Matcher<Node*>& lhs_matcher, |
const Matcher<Node*>& rhs_matcher) { |
return Is32() ? IsWord32Equal(lhs_matcher, rhs_matcher) |
@@ -115,51 +103,95 @@ class ChangeLoweringCommonTest |
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeBitToBool(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- EXPECT_THAT(reduction.replacement(), |
- IsSelect(static_cast<MachineType>(kTypeBool | kRepTagged), val, |
- IsTrueConstant(), IsFalseConstant())); |
+ Node* value = Parameter(Type::Boolean()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeBitToBool(), value)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsSelect(kMachAnyTagged, value, IsTrueConstant(), |
+ IsFalseConstant())); |
} |
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBoolToBit) { |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeBoolToBit(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- EXPECT_THAT(reduction.replacement(), IsWordEqual(val, IsTrueConstant())); |
+ Node* value = Parameter(Type::Number()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), value)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsWordEqual(value, IsTrueConstant())); |
} |
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeFloat64ToTagged) { |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeFloat64ToTagged(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* finish = reduction.replacement(); |
+ Node* value = Parameter(Type::Number()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeFloat64ToTagged(), value)); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> heap_number; |
EXPECT_THAT( |
- finish, |
+ r.replacement(), |
IsFinish( |
AllOf(CaptureEq(&heap_number), |
- IsAllocateHeapNumber(IsValueEffect(val), graph()->start())), |
+ IsAllocateHeapNumber(IsValueEffect(value), graph()->start())), |
IsStore(StoreRepresentation(kMachFloat64, kNoWriteBarrier), |
CaptureEq(&heap_number), |
- IsIntPtrConstant(HeapNumberValueOffset()), val, |
- CaptureEq(&heap_number), graph()->start()))); |
+ IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), |
+ value, CaptureEq(&heap_number), graph()->start()))); |
+} |
+ |
+ |
+TARGET_TEST_P(ChangeLoweringCommonTest, ChangeInt32ToTaggedWithSignedSmall) { |
+ Node* value = Parameter(Type::SignedSmall()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeInt32ToTagged(), value)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value)); |
} |
-TARGET_TEST_P(ChangeLoweringCommonTest, StringAdd) { |
- Node* node = |
- graph()->NewNode(simplified()->StringAdd(), Parameter(0), Parameter(1)); |
- Reduction reduction = Reduce(node); |
- EXPECT_FALSE(reduction.Changed()); |
+TARGET_TEST_P(ChangeLoweringCommonTest, ChangeUint32ToTaggedWithUnsignedSmall) { |
+ Node* value = Parameter(Type::UnsignedSmall()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), value)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsChangeUint32ToSmi(value)); |
+} |
+ |
+ |
+TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToInt32WithTaggedSigned) { |
+ Node* value = Parameter(Type::TaggedSigned()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeTaggedToInt32(), value)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsChangeSmiToInt32(value)); |
+} |
+ |
+ |
+TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToInt32WithTaggedPointer) { |
+ Node* value = Parameter(Type::TaggedPointer()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeTaggedToInt32(), value)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsChangeFloat64ToInt32( |
+ IsLoadHeapNumber(value, graph()->start()))); |
+} |
+ |
+ |
+TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToUint32WithTaggedSigned) { |
+ Node* value = Parameter(Type::TaggedSigned()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeTaggedToUint32(), value)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsChangeSmiToInt32(value)); |
+} |
+ |
+ |
+TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToUint32WithTaggedPointer) { |
+ Node* value = Parameter(Type::TaggedPointer()); |
+ Reduction r = |
+ Reduce(graph()->NewNode(simplified()->ChangeTaggedToUint32(), value)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsChangeFloat64ToUint32( |
+ IsLoadHeapNumber(value, graph()->start()))); |
} |
@@ -179,26 +211,24 @@ class ChangeLowering32Test : public ChangeLoweringTest { |
TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); |
- NodeProperties::SetBounds(val, Bounds(Type::None(), Type::Integral32())); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Integral32()); |
+ Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> add, branch, heap_number, if_true; |
EXPECT_THAT( |
- phi, |
+ r.replacement(), |
IsPhi(kMachAnyTagged, |
IsFinish(AllOf(CaptureEq(&heap_number), |
IsAllocateHeapNumber(_, CaptureEq(&if_true))), |
IsStore(StoreRepresentation(kMachFloat64, kNoWriteBarrier), |
CaptureEq(&heap_number), |
- IsIntPtrConstant(HeapNumberValueOffset()), |
- IsChangeInt32ToFloat64(val), |
+ IsIntPtrConstant(HeapNumber::kValueOffset - |
+ kHeapObjectTag), |
+ IsChangeInt32ToFloat64(value), |
CaptureEq(&heap_number), CaptureEq(&if_true))), |
- IsProjection( |
- 0, AllOf(CaptureEq(&add), IsInt32AddWithOverflow(val, val))), |
+ IsProjection(0, AllOf(CaptureEq(&add), |
+ IsInt32AddWithOverflow(value, value))), |
IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
IsIfFalse(AllOf(CaptureEq(&branch), |
IsBranch(IsProjection(1, CaptureEq(&add)), |
@@ -206,43 +236,27 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { |
} |
-TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTaggedSmall) { |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); |
- NodeProperties::SetBounds(val, Bounds(Type::None(), Type::SignedSmall())); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* change = reduction.replacement(); |
- Capture<Node*> add, branch, heap_number, if_true; |
- EXPECT_THAT(change, IsWord32Shl(val, IsInt32Constant(SmiShiftAmount()))); |
-} |
- |
- |
TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Number()); |
+ Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> branch, if_true; |
EXPECT_THAT( |
- phi, |
- IsPhi( |
- kMachFloat64, IsLoadHeapNumber(val, CaptureEq(&if_true)), |
- IsChangeInt32ToFloat64( |
- IsWord32Sar(val, IsInt32Constant(SmiShiftAmount()))), |
- IsMerge( |
- AllOf(CaptureEq(&if_true), |
- IsIfTrue(AllOf( |
- CaptureEq(&branch), |
- IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), |
- graph()->start())))), |
- IsIfFalse(CaptureEq(&branch))))); |
+ r.replacement(), |
+ IsPhi(kMachFloat64, IsLoadHeapNumber(value, CaptureEq(&if_true)), |
+ IsChangeInt32ToFloat64(IsWord32Sar( |
+ value, IsInt32Constant(kSmiTagSize + kSmiShiftSize))), |
+ IsMerge(AllOf(CaptureEq(&if_true), |
+ IsIfTrue(AllOf( |
+ CaptureEq(&branch), |
+ IsBranch(IsWord32And( |
+ value, IsInt32Constant(kSmiTagMask)), |
+ graph()->start())))), |
+ IsIfFalse(CaptureEq(&branch))))); |
} |
@@ -250,23 +264,22 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToInt32) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Signed32()); |
+ Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> branch, if_true; |
EXPECT_THAT( |
- phi, |
- IsPhi(kMachInt32, |
- IsChangeFloat64ToInt32(IsLoadHeapNumber(val, CaptureEq(&if_true))), |
- IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), |
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
- IsIfFalse(AllOf( |
- CaptureEq(&branch), |
- IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), |
- graph()->start())))))); |
+ r.replacement(), |
+ IsPhi( |
+ kMachInt32, |
+ IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))), |
+ IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), |
+ IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
+ IsIfFalse(AllOf( |
+ CaptureEq(&branch), |
+ IsBranch(IsWord32And(value, IsInt32Constant(kSmiTagMask)), |
+ graph()->start())))))); |
} |
@@ -274,23 +287,22 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Unsigned32()); |
+ Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> branch, if_true; |
EXPECT_THAT( |
- phi, |
- IsPhi(kMachUint32, |
- IsChangeFloat64ToUint32(IsLoadHeapNumber(val, CaptureEq(&if_true))), |
- IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), |
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
- IsIfFalse(AllOf( |
- CaptureEq(&branch), |
- IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), |
- graph()->start())))))); |
+ r.replacement(), |
+ IsPhi( |
+ kMachUint32, |
+ IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))), |
+ IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), |
+ IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
+ IsIfFalse(AllOf( |
+ CaptureEq(&branch), |
+ IsBranch(IsWord32And(value, IsInt32Constant(kSmiTagMask)), |
+ graph()->start())))))); |
} |
@@ -298,30 +310,30 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Number()); |
+ Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> branch, heap_number, if_false; |
EXPECT_THAT( |
- phi, |
+ r.replacement(), |
IsPhi( |
- kMachAnyTagged, IsWord32Shl(val, IsInt32Constant(SmiShiftAmount())), |
+ kMachAnyTagged, |
+ IsWord32Shl(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), |
IsFinish(AllOf(CaptureEq(&heap_number), |
IsAllocateHeapNumber(_, CaptureEq(&if_false))), |
IsStore(StoreRepresentation(kMachFloat64, kNoWriteBarrier), |
CaptureEq(&heap_number), |
- IsInt32Constant(HeapNumberValueOffset()), |
- IsChangeUint32ToFloat64(val), |
+ IsInt32Constant(HeapNumber::kValueOffset - |
+ kHeapObjectTag), |
+ IsChangeUint32ToFloat64(value), |
CaptureEq(&heap_number), CaptureEq(&if_false))), |
- IsMerge( |
- IsIfTrue(AllOf(CaptureEq(&branch), |
- IsBranch(IsUint32LessThanOrEqual( |
- val, IsInt32Constant(SmiMaxValue())), |
- graph()->start()))), |
- AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
+ IsMerge(IsIfTrue(AllOf( |
+ CaptureEq(&branch), |
+ IsBranch(IsUint32LessThanOrEqual( |
+ value, IsInt32Constant(Smi::kMaxValue)), |
+ graph()->start()))), |
+ AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
} |
@@ -337,14 +349,11 @@ class ChangeLowering64Test : public ChangeLoweringTest { |
TARGET_TEST_F(ChangeLowering64Test, ChangeInt32ToTagged) { |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- EXPECT_THAT(reduction.replacement(), |
- IsWord64Shl(IsChangeInt32ToInt64(val), |
- IsInt64Constant(SmiShiftAmount()))); |
+ Node* value = Parameter(Type::Signed32()); |
+ Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value)); |
} |
@@ -352,26 +361,23 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Number()); |
+ Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> branch, if_true; |
EXPECT_THAT( |
- phi, |
- IsPhi( |
- kMachFloat64, IsLoadHeapNumber(val, CaptureEq(&if_true)), |
- IsChangeInt32ToFloat64(IsTruncateInt64ToInt32( |
- IsWord64Sar(val, IsInt64Constant(SmiShiftAmount())))), |
- IsMerge( |
- AllOf(CaptureEq(&if_true), |
- IsIfTrue(AllOf( |
- CaptureEq(&branch), |
- IsBranch(IsWord64And(val, IsInt64Constant(kSmiTagMask)), |
- graph()->start())))), |
- IsIfFalse(CaptureEq(&branch))))); |
+ r.replacement(), |
+ IsPhi(kMachFloat64, IsLoadHeapNumber(value, CaptureEq(&if_true)), |
+ IsChangeInt32ToFloat64(IsTruncateInt64ToInt32(IsWord64Sar( |
+ value, IsInt64Constant(kSmiTagSize + kSmiShiftSize)))), |
+ IsMerge(AllOf(CaptureEq(&if_true), |
+ IsIfTrue(AllOf( |
+ CaptureEq(&branch), |
+ IsBranch(IsWord64And( |
+ value, IsInt64Constant(kSmiTagMask)), |
+ graph()->start())))), |
+ IsIfFalse(CaptureEq(&branch))))); |
} |
@@ -379,24 +385,23 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToInt32) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Signed32()); |
+ Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> branch, if_true; |
EXPECT_THAT( |
- phi, |
- IsPhi(kMachInt32, |
- IsChangeFloat64ToInt32(IsLoadHeapNumber(val, CaptureEq(&if_true))), |
- IsTruncateInt64ToInt32( |
- IsWord64Sar(val, IsInt64Constant(SmiShiftAmount()))), |
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
- IsIfFalse(AllOf( |
- CaptureEq(&branch), |
- IsBranch(IsWord64And(val, IsInt64Constant(kSmiTagMask)), |
- graph()->start())))))); |
+ r.replacement(), |
+ IsPhi( |
+ kMachInt32, |
+ IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))), |
+ IsTruncateInt64ToInt32( |
+ IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))), |
+ IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
+ IsIfFalse(AllOf( |
+ CaptureEq(&branch), |
+ IsBranch(IsWord64And(value, IsInt64Constant(kSmiTagMask)), |
+ graph()->start())))))); |
} |
@@ -404,24 +409,23 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Unsigned32()); |
+ Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> branch, if_true; |
EXPECT_THAT( |
- phi, |
- IsPhi(kMachUint32, |
- IsChangeFloat64ToUint32(IsLoadHeapNumber(val, CaptureEq(&if_true))), |
- IsTruncateInt64ToInt32( |
- IsWord64Sar(val, IsInt64Constant(SmiShiftAmount()))), |
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
- IsIfFalse(AllOf( |
- CaptureEq(&branch), |
- IsBranch(IsWord64And(val, IsInt64Constant(kSmiTagMask)), |
- graph()->start())))))); |
+ r.replacement(), |
+ IsPhi( |
+ kMachUint32, |
+ IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))), |
+ IsTruncateInt64ToInt32( |
+ IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))), |
+ IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
+ IsIfFalse(AllOf( |
+ CaptureEq(&branch), |
+ IsBranch(IsWord64And(value, IsInt64Constant(kSmiTagMask)), |
+ graph()->start())))))); |
} |
@@ -429,31 +433,31 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeUint32ToTagged) { |
STATIC_ASSERT(kSmiTag == 0); |
STATIC_ASSERT(kSmiTagSize == 1); |
- Node* val = Parameter(0); |
- Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), val); |
- Reduction reduction = Reduce(node); |
- ASSERT_TRUE(reduction.Changed()); |
- |
- Node* phi = reduction.replacement(); |
+ Node* value = Parameter(Type::Number()); |
+ Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), value); |
+ Reduction r = Reduce(node); |
+ ASSERT_TRUE(r.Changed()); |
Capture<Node*> branch, heap_number, if_false; |
EXPECT_THAT( |
- phi, |
+ r.replacement(), |
IsPhi( |
- kMachAnyTagged, IsWord64Shl(IsChangeUint32ToUint64(val), |
- IsInt64Constant(SmiShiftAmount())), |
+ kMachAnyTagged, |
+ IsWord64Shl(IsChangeUint32ToUint64(value), |
+ IsInt64Constant(kSmiTagSize + kSmiShiftSize)), |
IsFinish(AllOf(CaptureEq(&heap_number), |
IsAllocateHeapNumber(_, CaptureEq(&if_false))), |
IsStore(StoreRepresentation(kMachFloat64, kNoWriteBarrier), |
CaptureEq(&heap_number), |
- IsInt64Constant(HeapNumberValueOffset()), |
- IsChangeUint32ToFloat64(val), |
+ IsInt64Constant(HeapNumber::kValueOffset - |
+ kHeapObjectTag), |
+ IsChangeUint32ToFloat64(value), |
CaptureEq(&heap_number), CaptureEq(&if_false))), |
- IsMerge( |
- IsIfTrue(AllOf(CaptureEq(&branch), |
- IsBranch(IsUint32LessThanOrEqual( |
- val, IsInt32Constant(SmiMaxValue())), |
- graph()->start()))), |
- AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
+ IsMerge(IsIfTrue(AllOf( |
+ CaptureEq(&branch), |
+ IsBranch(IsUint32LessThanOrEqual( |
+ value, IsInt32Constant(Smi::kMaxValue)), |
+ graph()->start()))), |
+ AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
} |
} // namespace compiler |