Commit 70b22162 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[Turbofan][ptr-compr] Add representation changes for and to Compressed* values

Includes both changing from compressed pointers and to compressed pointers.

Also added tests to the representation changer test

B

Cq-Include-Trybots: luci.v8.try:v8_linux64_pointer_compression_rel_ng,v8_linux64_arm64_pointer_compression_rel_ng
Bug: v8:8977
Change-Id: I8a13f6b7ec2208442aa354949173cc9061bce168
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1533866Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60587}
parent fbce172c
......@@ -672,6 +672,12 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kChangeTaggedToTaggedSigned:
result = LowerChangeTaggedToTaggedSigned(node);
break;
case IrOpcode::kChangeCompressedToTaggedSigned:
result = LowerChangeCompressedToTaggedSigned(node);
break;
case IrOpcode::kChangeTaggedToCompressedSigned:
result = LowerChangeTaggedToCompressedSigned(node);
break;
case IrOpcode::kTruncateTaggedToBit:
result = LowerTruncateTaggedToBit(node);
break;
......@@ -796,6 +802,18 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kCheckedTaggedToTaggedPointer:
result = LowerCheckedTaggedToTaggedPointer(node, frame_state);
break;
case IrOpcode::kCheckedCompressedToTaggedSigned:
result = LowerCheckedCompressedToTaggedSigned(node, frame_state);
break;
case IrOpcode::kCheckedCompressedToTaggedPointer:
result = LowerCheckedCompressedToTaggedPointer(node, frame_state);
break;
case IrOpcode::kCheckedTaggedToCompressedSigned:
result = LowerCheckedTaggedToCompressedSigned(node, frame_state);
break;
case IrOpcode::kCheckedTaggedToCompressedPointer:
result = LowerCheckedTaggedToCompressedPointer(node, frame_state);
break;
case IrOpcode::kTruncateTaggedToWord32:
result = LowerTruncateTaggedToWord32(node);
break;
......@@ -1448,6 +1466,50 @@ Node* EffectControlLinearizer::LowerChangeTaggedToTaggedSigned(Node* node) {
return done.PhiAt(0);
}
Node* EffectControlLinearizer::LowerChangeCompressedToTaggedSigned(Node* node) {
Node* value = node->InputAt(0);
auto if_not_smi = __ MakeDeferredLabel();
auto done = __ MakeLabel(MachineRepresentation::kWord32);
Node* check = ObjectIsSmi(value);
__ GotoIfNot(check, &if_not_smi);
__ Goto(&done, __ ChangeCompressedSignedToTaggedSigned(value));
__ Bind(&if_not_smi);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(),
__ ChangeCompressedToTagged(value));
vfalse = __ ChangeFloat64ToInt32(vfalse);
vfalse = ChangeInt32ToSmi(vfalse);
__ Goto(&done, vfalse);
__ Bind(&done);
return done.PhiAt(0);
}
Node* EffectControlLinearizer::LowerChangeTaggedToCompressedSigned(Node* node) {
Node* value = node->InputAt(0);
auto if_not_smi = __ MakeDeferredLabel();
auto done = __ MakeLabel(MachineRepresentation::kWord32);
Node* check = ObjectIsSmi(value);
__ GotoIfNot(check, &if_not_smi);
__ Goto(&done, __ ChangeTaggedSignedToCompressedSigned(value));
__ Bind(&if_not_smi);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(), value);
vfalse = __ ChangeFloat64ToInt32(vfalse);
vfalse = ChangeInt32ToSmi(vfalse);
vfalse = __ ChangeTaggedSignedToCompressedSigned(vfalse);
__ Goto(&done, vfalse);
__ Bind(&done);
return done.PhiAt(0);
}
Node* EffectControlLinearizer::LowerTruncateTaggedToFloat64(Node* node) {
Node* value = node->InputAt(0);
......@@ -2486,6 +2548,52 @@ Node* EffectControlLinearizer::LowerCheckedTaggedToTaggedPointer(
return value;
}
Node* EffectControlLinearizer::LowerCheckedCompressedToTaggedSigned(
Node* node, Node* frame_state) {
Node* value = node->InputAt(0);
const CheckParameters& params = CheckParametersOf(node->op());
Node* check = ObjectIsSmi(value);
__ DeoptimizeIfNot(DeoptimizeReason::kNotASmi, params.feedback(), check,
frame_state);
return __ ChangeCompressedSignedToTaggedSigned(value);
}
Node* EffectControlLinearizer::LowerCheckedCompressedToTaggedPointer(
Node* node, Node* frame_state) {
Node* value = node->InputAt(0);
const CheckParameters& params = CheckParametersOf(node->op());
Node* check = ObjectIsSmi(value);
__ DeoptimizeIf(DeoptimizeReason::kSmi, params.feedback(), check,
frame_state);
return __ ChangeCompressedPointerToTaggedPointer(value);
}
Node* EffectControlLinearizer::LowerCheckedTaggedToCompressedSigned(
Node* node, Node* frame_state) {
Node* value = node->InputAt(0);
const CheckParameters& params = CheckParametersOf(node->op());
Node* check = ObjectIsSmi(value);
__ DeoptimizeIfNot(DeoptimizeReason::kNotASmi, params.feedback(), check,
frame_state);
return __ ChangeTaggedSignedToCompressedSigned(value);
}
Node* EffectControlLinearizer::LowerCheckedTaggedToCompressedPointer(
Node* node, Node* frame_state) {
Node* value = node->InputAt(0);
const CheckParameters& params = CheckParametersOf(node->op());
Node* check = ObjectIsSmi(value);
__ DeoptimizeIf(DeoptimizeReason::kSmi, params.feedback(), check,
frame_state);
return __ ChangeTaggedPointerToCompressedPointer(value);
}
Node* EffectControlLinearizer::LowerTruncateTaggedToWord32(Node* node) {
Node* value = node->InputAt(0);
......
......@@ -62,6 +62,8 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
Node* LowerChangeTaggedToUint32(Node* node);
Node* LowerChangeTaggedToInt64(Node* node);
Node* LowerChangeTaggedToTaggedSigned(Node* node);
Node* LowerChangeCompressedToTaggedSigned(Node* node);
Node* LowerChangeTaggedToCompressedSigned(Node* node);
Node* LowerPoisonIndex(Node* node);
Node* LowerCheckInternalizedString(Node* node, Node* frame_state);
Node* LowerCheckNonEmptyOneByteString(Node* node, Node* frame_state);
......@@ -99,6 +101,10 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
Node* LowerCheckedTaggedToFloat64(Node* node, Node* frame_state);
Node* LowerCheckedTaggedToTaggedSigned(Node* node, Node* frame_state);
Node* LowerCheckedTaggedToTaggedPointer(Node* node, Node* frame_state);
Node* LowerCheckedCompressedToTaggedSigned(Node* node, Node* frame_state);
Node* LowerCheckedCompressedToTaggedPointer(Node* node, Node* frame_state);
Node* LowerCheckedTaggedToCompressedSigned(Node* node, Node* frame_state);
Node* LowerCheckedTaggedToCompressedPointer(Node* node, Node* frame_state);
Node* LowerChangeTaggedToFloat64(Node* node);
void TruncateTaggedPointerToBit(Node* node, GraphAssemblerLabel<1>* done);
Node* LowerTruncateTaggedToBit(Node* node);
......
......@@ -18,30 +18,35 @@ class Graph;
namespace compiler {
#define PURE_ASSEMBLER_MACH_UNOP_LIST(V) \
V(ChangeInt32ToInt64) \
V(ChangeInt32ToFloat64) \
V(ChangeInt64ToFloat64) \
V(ChangeUint32ToFloat64) \
V(ChangeUint32ToUint64) \
V(ChangeFloat64ToInt32) \
V(ChangeFloat64ToInt64) \
V(ChangeFloat64ToUint32) \
V(TruncateInt64ToInt32) \
V(RoundFloat64ToInt32) \
V(TruncateFloat64ToInt64) \
V(TruncateFloat64ToWord32) \
V(Float64ExtractLowWord32) \
V(Float64ExtractHighWord32) \
V(BitcastInt32ToFloat32) \
V(BitcastInt64ToFloat64) \
V(BitcastFloat32ToInt32) \
V(BitcastFloat64ToInt64) \
V(Float64Abs) \
V(Word32ReverseBytes) \
V(Word64ReverseBytes) \
V(Float64SilenceNaN)
#define PURE_ASSEMBLER_MACH_UNOP_LIST(V) \
V(ChangeInt32ToInt64) \
V(ChangeInt32ToFloat64) \
V(ChangeInt64ToFloat64) \
V(ChangeUint32ToFloat64) \
V(ChangeUint32ToUint64) \
V(ChangeFloat64ToInt32) \
V(ChangeFloat64ToInt64) \
V(ChangeFloat64ToUint32) \
V(TruncateInt64ToInt32) \
V(RoundFloat64ToInt32) \
V(TruncateFloat64ToInt64) \
V(TruncateFloat64ToWord32) \
V(Float64ExtractLowWord32) \
V(Float64ExtractHighWord32) \
V(BitcastInt32ToFloat32) \
V(BitcastInt64ToFloat64) \
V(BitcastFloat32ToInt32) \
V(BitcastFloat64ToInt64) \
V(Float64Abs) \
V(Word32ReverseBytes) \
V(Word64ReverseBytes) \
V(Float64SilenceNaN) \
V(ChangeCompressedToTagged) \
V(ChangeTaggedToCompressed) \
V(ChangeTaggedSignedToCompressedSigned) \
V(ChangeCompressedSignedToTaggedSigned) \
V(ChangeTaggedPointerToCompressedPointer) \
V(ChangeCompressedPointerToTaggedPointer)
#define PURE_ASSEMBLER_MACH_BINOP_LIST(V) \
V(WordShl) \
V(WordSar) \
......
......@@ -237,6 +237,8 @@
V(ChangeTaggedToUint32) \
V(ChangeTaggedToFloat64) \
V(ChangeTaggedToTaggedSigned) \
V(ChangeCompressedToTaggedSigned) \
V(ChangeTaggedToCompressedSigned) \
V(ChangeInt31ToTaggedSigned) \
V(ChangeInt32ToTagged) \
V(ChangeInt64ToTagged) \
......@@ -276,7 +278,11 @@
V(CheckedTaggedToFloat64) \
V(CheckedTaggedToInt64) \
V(CheckedTaggedToTaggedSigned) \
V(CheckedTaggedToTaggedPointer)
V(CheckedTaggedToTaggedPointer) \
V(CheckedCompressedToTaggedSigned) \
V(CheckedCompressedToTaggedPointer) \
V(CheckedTaggedToCompressedSigned) \
V(CheckedTaggedToCompressedPointer)
#define SIMPLIFIED_COMPARE_BINOP_LIST(V) \
V(NumberEqual) \
......
......@@ -172,6 +172,10 @@ bool CheckSubsumes(Node const* a, Node const* b) {
case IrOpcode::kCheckedTaggedSignedToInt32:
case IrOpcode::kCheckedTaggedToTaggedPointer:
case IrOpcode::kCheckedTaggedToTaggedSigned:
case IrOpcode::kCheckedCompressedToTaggedPointer:
case IrOpcode::kCheckedCompressedToTaggedSigned:
case IrOpcode::kCheckedTaggedToCompressedPointer:
case IrOpcode::kCheckedTaggedToCompressedSigned:
case IrOpcode::kCheckedUint32Bounds:
case IrOpcode::kCheckedUint32ToInt32:
case IrOpcode::kCheckedUint32ToTaggedSigned:
......
......@@ -176,6 +176,20 @@ Node* RepresentationChanger::GetRepresentationFor(
DCHECK_EQ(TypeCheckKind::kNone, use_info.type_check());
return GetTaggedRepresentationFor(node, output_rep, output_type,
use_info.truncation());
case MachineRepresentation::kCompressedSigned:
DCHECK(use_info.type_check() == TypeCheckKind::kNone ||
use_info.type_check() == TypeCheckKind::kSignedSmall);
return GetCompressedSignedRepresentationFor(node, output_rep, output_type,
use_node, use_info);
case MachineRepresentation::kCompressedPointer:
DCHECK(use_info.type_check() == TypeCheckKind::kNone ||
use_info.type_check() == TypeCheckKind::kHeapObject);
return GetCompressedPointerRepresentationFor(
node, output_rep, output_type, use_node, use_info);
case MachineRepresentation::kCompressed:
DCHECK_EQ(TypeCheckKind::kNone, use_info.type_check());
return GetCompressedRepresentationFor(node, output_rep, output_type,
use_info.truncation());
case MachineRepresentation::kFloat32:
DCHECK_EQ(TypeCheckKind::kNone, use_info.type_check());
return GetFloat32RepresentationFor(node, output_rep, output_type,
......@@ -196,11 +210,6 @@ Node* RepresentationChanger::GetRepresentationFor(
use_info.type_check() == TypeCheckKind::kSigned64);
return GetWord64RepresentationFor(node, output_rep, output_type, use_node,
use_info);
// TODO(solanes): Create the code for the compressed values
case MachineRepresentation::kCompressedSigned:
case MachineRepresentation::kCompressedPointer:
case MachineRepresentation::kCompressed:
UNREACHABLE();
case MachineRepresentation::kSimd128:
case MachineRepresentation::kNone:
return node;
......@@ -344,6 +353,17 @@ Node* RepresentationChanger::GetTaggedSignedRepresentationFor(
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTaggedSigned);
}
} else if (output_rep == MachineRepresentation::kCompressedSigned) {
op = machine()->ChangeCompressedSignedToTaggedSigned();
} else if (output_rep == MachineRepresentation::kCompressed) {
if (use_info.type_check() == TypeCheckKind::kSignedSmall) {
op = simplified()->CheckedCompressedToTaggedSigned(use_info.feedback());
} else if (output_type.Is(Type::SignedSmall())) {
op = simplified()->ChangeCompressedToTaggedSigned();
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTaggedSigned);
}
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTaggedSigned);
......@@ -427,6 +447,16 @@ Node* RepresentationChanger::GetTaggedPointerRepresentationFor(
// TODO(turbofan): Consider adding a Bailout operator that just deopts
// for TaggedSigned output representation.
op = simplified()->CheckedTaggedToTaggedPointer(use_info.feedback());
} else if (output_rep == MachineRepresentation::kCompressedPointer) {
op = machine()->ChangeCompressedPointerToTaggedPointer();
} else if (output_rep == MachineRepresentation::kCompressed &&
use_info.type_check() == TypeCheckKind::kHeapObject) {
if (!output_type.Maybe(Type::SignedSmall())) {
return node;
}
// TODO(turbofan): Consider adding a Bailout operator that just deopts
// for CompressedSigned output representation.
op = simplified()->CheckedCompressedToTaggedPointer(use_info.feedback());
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTaggedPointer);
......@@ -540,6 +570,8 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTagged);
}
} else if (IsAnyCompressed(output_rep)) {
op = machine()->ChangeCompressedToTagged();
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTagged);
......@@ -547,6 +579,86 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
return jsgraph()->graph()->NewNode(op, node);
}
Node* RepresentationChanger::GetCompressedSignedRepresentationFor(
Node* node, MachineRepresentation output_rep, Type output_type,
Node* use_node, UseInfo use_info) {
// Select the correct X -> Compressed operator.
const Operator* op;
if (output_type.Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
return jsgraph()->graph()->NewNode(
jsgraph()->common()->DeadValue(
MachineRepresentation::kCompressedSigned),
node);
} else if (output_rep == MachineRepresentation::kTaggedSigned) {
op = machine()->ChangeTaggedSignedToCompressedSigned();
} else if (output_rep == MachineRepresentation::kTagged) {
if (use_info.type_check() == TypeCheckKind::kSignedSmall) {
op = simplified()->CheckedTaggedToCompressedSigned(use_info.feedback());
} else if (output_type.Is(Type::SignedSmall())) {
op = simplified()->ChangeTaggedToCompressedSigned();
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTaggedSigned);
}
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kCompressedSigned);
}
return InsertConversion(node, op, use_node);
}
Node* RepresentationChanger::GetCompressedPointerRepresentationFor(
Node* node, MachineRepresentation output_rep, Type output_type,
Node* use_node, UseInfo use_info) {
// Select the correct X -> CompressedPointer operator.
Operator const* op;
if (output_type.Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
return jsgraph()->graph()->NewNode(
jsgraph()->common()->DeadValue(
MachineRepresentation::kCompressedPointer),
node);
} else if (output_rep == MachineRepresentation::kTaggedPointer) {
op = machine()->ChangeTaggedPointerToCompressedPointer();
} else if (output_rep == MachineRepresentation::kTagged &&
use_info.type_check() == TypeCheckKind::kHeapObject) {
if (!output_type.Maybe(Type::SignedSmall())) {
return node;
}
// TODO(turbofan): Consider adding a Bailout operator that just deopts
// for TaggedSigned output representation.
op = simplified()->CheckedTaggedToCompressedPointer(use_info.feedback());
return TypeError(node, output_rep, output_type,
MachineRepresentation::kCompressedPointer);
}
return InsertConversion(node, op, use_node);
}
Node* RepresentationChanger::GetCompressedRepresentationFor(
Node* node, MachineRepresentation output_rep, Type output_type,
Truncation truncation) {
if (output_rep == MachineRepresentation::kCompressedSigned ||
output_rep == MachineRepresentation::kCompressedPointer) {
// this is a no-op.
return node;
}
// Select the correct X -> Compressed operator.
const Operator* op;
if (output_type.Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
return jsgraph()->graph()->NewNode(
jsgraph()->common()->DeadValue(MachineRepresentation::kCompressed),
node);
} else if (IsAnyTagged(output_rep)) {
op = machine()->ChangeTaggedToCompressed();
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kCompressed);
}
return jsgraph()->graph()->NewNode(op, node);
}
Node* RepresentationChanger::GetFloat32RepresentationFor(
Node* node, MachineRepresentation output_rep, Type output_type,
Truncation truncation) {
......
......@@ -322,6 +322,17 @@ class V8_EXPORT_PRIVATE RepresentationChanger final {
UseInfo use_info);
Node* GetTaggedRepresentationFor(Node* node, MachineRepresentation output_rep,
Type output_type, Truncation truncation);
Node* GetCompressedSignedRepresentationFor(Node* node,
MachineRepresentation output_rep,
Type output_type, Node* use_node,
UseInfo use_info);
Node* GetCompressedPointerRepresentationFor(Node* node,
MachineRepresentation output_rep,
Type output_type, Node* use_node,
UseInfo use_info);
Node* GetCompressedRepresentationFor(Node* node,
MachineRepresentation output_rep,
Type output_type, Truncation truncation);
Node* GetFloat32RepresentationFor(Node* node,
MachineRepresentation output_rep,
Type output_type, Truncation truncation);
......
This diff is collapsed.
......@@ -653,6 +653,8 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* ChangeTaggedToUint32();
const Operator* ChangeTaggedToFloat64();
const Operator* ChangeTaggedToTaggedSigned();
const Operator* ChangeCompressedToTaggedSigned();
const Operator* ChangeTaggedToCompressedSigned();
const Operator* ChangeInt31ToTaggedSigned();
const Operator* ChangeInt32ToTagged();
const Operator* ChangeInt64ToTagged();
......@@ -713,6 +715,14 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const VectorSlotPair& feedback);
const Operator* CheckedTaggedToTaggedPointer(const VectorSlotPair& feedback);
const Operator* CheckedTaggedToTaggedSigned(const VectorSlotPair& feedback);
const Operator* CheckedCompressedToTaggedPointer(
const VectorSlotPair& feedback);
const Operator* CheckedCompressedToTaggedSigned(
const VectorSlotPair& feedback);
const Operator* CheckedTaggedToCompressedPointer(
const VectorSlotPair& feedback);
const Operator* CheckedTaggedToCompressedSigned(
const VectorSlotPair& feedback);
const Operator* CheckedTruncateTaggedToWord32(CheckTaggedInputMode,
const VectorSlotPair& feedback);
const Operator* CheckedUint32Div();
......
......@@ -1339,7 +1339,9 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
// CheckTypeIs(node, to));
break;
}
case IrOpcode::kChangeTaggedToTaggedSigned:
case IrOpcode::kChangeTaggedToTaggedSigned: // Fall through.
case IrOpcode::kChangeCompressedToTaggedSigned: // Fall through.
case IrOpcode::kChangeTaggedToCompressedSigned:
break;
case IrOpcode::kTruncateTaggedToFloat64: {
// NumberOrUndefined /\ Tagged -> Number /\ UntaggedFloat64
......@@ -1518,6 +1520,10 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
case IrOpcode::kCheckedTaggedToFloat64:
case IrOpcode::kCheckedTaggedToTaggedSigned:
case IrOpcode::kCheckedTaggedToTaggedPointer:
case IrOpcode::kCheckedCompressedToTaggedSigned:
case IrOpcode::kCheckedCompressedToTaggedPointer:
case IrOpcode::kCheckedTaggedToCompressedSigned:
case IrOpcode::kCheckedTaggedToCompressedPointer:
case IrOpcode::kCheckedTruncateTaggedToWord32:
break;
......
......@@ -118,13 +118,13 @@ class RepresentationChangerTester : public HandleAndZoneScope,
}
};
const MachineType kMachineTypes[] = {
MachineType::Float32(), MachineType::Float64(), MachineType::Int8(),
MachineType::Uint8(), MachineType::Int16(), MachineType::Uint16(),
MachineType::Int32(), MachineType::Uint32(), MachineType::Int64(),
MachineType::Uint64(), MachineType::AnyTagged()};
MachineType::Float32(), MachineType::Float64(),
MachineType::Int8(), MachineType::Uint8(),
MachineType::Int16(), MachineType::Uint16(),
MachineType::Int32(), MachineType::Uint32(),
MachineType::Int64(), MachineType::Uint64(),
MachineType::AnyTagged(), MachineType::AnyCompressed()};
TEST(BoolToBit_constant) {
RepresentationChangerTester r;
......@@ -631,6 +631,40 @@ TEST(SignednessInWord32) {
UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair()));
}
TEST(CompressedAndTagged) {
// Simple Tagged to Compressed
CheckChange(IrOpcode::kChangeTaggedToCompressed,
MachineRepresentation::kTagged, Type::Any(),
MachineRepresentation::kCompressed);
CheckChange(IrOpcode::kChangeTaggedPointerToCompressedPointer,
MachineRepresentation::kTaggedPointer, Type::Any(),
MachineRepresentation::kCompressedPointer);
CheckChange(IrOpcode::kChangeTaggedSignedToCompressedSigned,
MachineRepresentation::kTaggedSigned, Type::Any(),
MachineRepresentation::kCompressedSigned);
// Simple Compressed to Tagged
CheckChange(IrOpcode::kChangeCompressedToTagged,
MachineRepresentation::kCompressed, Type::Any(),
MachineRepresentation::kTagged);
CheckChange(IrOpcode::kChangeCompressedPointerToTaggedPointer,
MachineRepresentation::kCompressedPointer, Type::Any(),
MachineRepresentation::kTaggedPointer);
CheckChange(IrOpcode::kChangeCompressedSignedToTaggedSigned,
MachineRepresentation::kCompressedSigned, Type::Any(),
MachineRepresentation::kTaggedSigned);
// Compressed To TaggedSigned
CheckChange(IrOpcode::kChangeCompressedToTaggedSigned,
MachineRepresentation::kCompressed, Type::SignedSmall(),
MachineRepresentation::kTaggedSigned);
// Tagged To CompressedSigned
CheckChange(IrOpcode::kChangeTaggedToCompressedSigned,
MachineRepresentation::kTagged, Type::SignedSmall(),
MachineRepresentation::kCompressedSigned);
}
static void TestMinusZeroCheck(IrOpcode::Value expected, Type from_type) {
RepresentationChangerTester r;
......
......@@ -704,6 +704,114 @@ TEST_F(RedundancyEliminationTest, CheckedTaggedToTaggedSigned) {
}
}
// -----------------------------------------------------------------------------
// CheckedCompressedToTaggedPointer
TEST_F(RedundancyEliminationTest, CheckedCompressedToTaggedPointer) {
TRACED_FOREACH(VectorSlotPair, feedback1, vector_slot_pairs()) {
TRACED_FOREACH(VectorSlotPair, feedback2, vector_slot_pairs()) {
Node* value = Parameter(0);
Node* effect = graph()->start();
Node* control = graph()->start();
Node* check1 = effect = graph()->NewNode(
simplified()->CheckedCompressedToTaggedPointer(feedback1), value,
effect, control);
Reduction r1 = Reduce(check1);
ASSERT_TRUE(r1.Changed());
EXPECT_EQ(r1.replacement(), check1);
Node* check2 = effect = graph()->NewNode(
simplified()->CheckedCompressedToTaggedPointer(feedback2), value,
effect, control);
Reduction r2 = Reduce(check2);
ASSERT_TRUE(r2.Changed());
EXPECT_EQ(r2.replacement(), check1);
}
}
}
// -----------------------------------------------------------------------------
// CheckedCompressedToTaggedSigned
TEST_F(RedundancyEliminationTest, CheckedCompressedToTaggedSigned) {
TRACED_FOREACH(VectorSlotPair, feedback1, vector_slot_pairs()) {
TRACED_FOREACH(VectorSlotPair, feedback2, vector_slot_pairs()) {
Node* value = Parameter(0);
Node* effect = graph()->start();
Node* control = graph()->start();
Node* check1 = effect = graph()->NewNode(
simplified()->CheckedCompressedToTaggedSigned(feedback1), value,
effect, control);
Reduction r1 = Reduce(check1);
ASSERT_TRUE(r1.Changed());
EXPECT_EQ(r1.replacement(), check1);
Node* check2 = effect = graph()->NewNode(
simplified()->CheckedCompressedToTaggedSigned(feedback2), value,
effect, control);
Reduction r2 = Reduce(check2);
ASSERT_TRUE(r2.Changed());
EXPECT_EQ(r2.replacement(), check1);
}
}
}
// -----------------------------------------------------------------------------
// CheckedTaggedToCompressedPointer
TEST_F(RedundancyEliminationTest, CheckedTaggedToCompressedPointer) {
TRACED_FOREACH(VectorSlotPair, feedback1, vector_slot_pairs()) {
TRACED_FOREACH(VectorSlotPair, feedback2, vector_slot_pairs()) {
Node* value = Parameter(0);
Node* effect = graph()->start();
Node* control = graph()->start();
Node* check1 = effect = graph()->NewNode(
simplified()->CheckedTaggedToCompressedPointer(feedback1), value,
effect, control);
Reduction r1 = Reduce(check1);
ASSERT_TRUE(r1.Changed());
EXPECT_EQ(r1.replacement(), check1);
Node* check2 = effect = graph()->NewNode(
simplified()->CheckedTaggedToCompressedPointer(feedback2), value,
effect, control);
Reduction r2 = Reduce(check2);
ASSERT_TRUE(r2.Changed());
EXPECT_EQ(r2.replacement(), check1);
}
}
}
// -----------------------------------------------------------------------------
// CheckedTaggedToCompressedSigned
TEST_F(RedundancyEliminationTest, CheckedTaggedToCompressedSigned) {
TRACED_FOREACH(VectorSlotPair, feedback1, vector_slot_pairs()) {
TRACED_FOREACH(VectorSlotPair, feedback2, vector_slot_pairs()) {
Node* value = Parameter(0);
Node* effect = graph()->start();
Node* control = graph()->start();
Node* check1 = effect = graph()->NewNode(
simplified()->CheckedTaggedToCompressedSigned(feedback1), value,
effect, control);
Reduction r1 = Reduce(check1);
ASSERT_TRUE(r1.Changed());
EXPECT_EQ(r1.replacement(), check1);
Node* check2 = effect = graph()->NewNode(
simplified()->CheckedTaggedToCompressedSigned(feedback2), value,
effect, control);
Reduction r2 = Reduce(check2);
ASSERT_TRUE(r2.Changed());
EXPECT_EQ(r2.replacement(), check1);
}
}
}
// -----------------------------------------------------------------------------
// CheckedTruncateTaggedToWord32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment