Commit bef13604 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[ptr-compr] Remove the last of ChangeTaggedToCompressed

The only one remaining was the one in CSA. Once that was removed, we can
simplify the pipeline.

In order to remove it, we have to update the machine graph verifer so
that Word32Equal can accept Tagged values as well.

Bug: v8:7703
Change-Id: Ia3c4d872babc2005be1b402b4614a6039c59dbf3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1987254
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65634}
parent 95aba36b
......@@ -545,12 +545,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
uintptr_t ConstexprWordNot(uintptr_t a) { return ~a; }
TNode<BoolT> TaggedEqual(TNode<AnyTaggedT> a, TNode<AnyTaggedT> b) {
#ifdef V8_COMPRESS_POINTERS
return Word32Equal(ChangeTaggedToCompressed(a),
ChangeTaggedToCompressed(b));
#else
return WordEqual(ReinterpretCast<WordT>(a), ReinterpretCast<WordT>(b));
#endif
if (COMPRESS_POINTERS_BOOL) {
return Word32Equal(ReinterpretCast<Word32T>(a),
ReinterpretCast<Word32T>(b));
} else {
return WordEqual(ReinterpretCast<WordT>(a), ReinterpretCast<WordT>(b));
}
}
TNode<BoolT> TaggedNotEqual(TNode<AnyTaggedT> a, TNode<AnyTaggedT> b) {
......
......@@ -1756,12 +1756,6 @@ void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
Emit(kArm64Mov32, g.DefineAsRegister(node), g.UseRegister(value));
}
void InstructionSelector::VisitChangeTaggedToCompressed(Node* node) {
// The top 32 bits in the 64-bit register will be undefined, and
// must not be used by a dependent node.
EmitIdentity(node);
}
void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
Arm64OperandGenerator g(this);
// The top 32 bits in the 64-bit register will be undefined, and
......
......@@ -1576,8 +1576,6 @@ void InstructionSelector::VisitNode(Node* node) {
return MarkAsWord64(node), VisitChangeInt32ToInt64(node);
case IrOpcode::kChangeUint32ToUint64:
return MarkAsWord64(node), VisitChangeUint32ToUint64(node);
case IrOpcode::kChangeTaggedToCompressed:
return MarkAsCompressed(node), VisitChangeTaggedToCompressed(node);
case IrOpcode::kTruncateFloat64ToFloat32:
return MarkAsFloat32(node), VisitTruncateFloat64ToFloat32(node);
case IrOpcode::kTruncateFloat64ToWord32:
......@@ -2463,10 +2461,6 @@ void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitChangeTaggedToCompressed(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitChangeFloat64ToInt64(Node* node) {
UNIMPLEMENTED();
}
......
......@@ -1361,10 +1361,6 @@ void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
g.TempImmediate(0), g.TempImmediate(32));
}
void InstructionSelector::VisitChangeTaggedToCompressed(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
Mips64OperandGenerator g(this);
Node* value = node->InputAt(0);
......
......@@ -1168,10 +1168,6 @@ void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
VisitRR(this, kPPC_Uint32ToUint64, node);
}
void InstructionSelector::VisitChangeTaggedToCompressed(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitChangeFloat64ToUint64(Node* node) {
VisitRR(this, kPPC_DoubleToUint64, node);
}
......
......@@ -2254,10 +2254,6 @@ bool InstructionSelector::IsTailCallAddressImmediate() { return false; }
int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; }
void InstructionSelector::VisitChangeTaggedToCompressed(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op());
DCHECK(load_rep.representation() == MachineRepresentation::kWord8 ||
......
......@@ -1338,12 +1338,6 @@ void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
Emit(kX64Movl, g.DefineAsRegister(node), g.Use(value));
}
void InstructionSelector::VisitChangeTaggedToCompressed(Node* node) {
// The top 32 bits in the 64-bit register will be undefined, and
// must not be used by a dependent node.
return EmitIdentity(node);
}
namespace {
void VisitRO(InstructionSelector* selector, Node* node,
......
......@@ -305,7 +305,6 @@ TNode<Float64T> Float64Add(TNode<Float64T> a, TNode<Float64T> b);
V(ChangeInt32ToInt64, Int64T, Int32T) \
V(ChangeUint32ToFloat64, Float64T, Word32T) \
V(ChangeUint32ToUint64, Uint64T, Word32T) \
V(ChangeTaggedToCompressed, TaggedT, AnyTaggedT) \
V(BitcastInt32ToFloat32, Float32T, Word32T) \
V(BitcastFloat32ToInt32, Uint32T, Float32T) \
V(RoundFloat64ToInt32, Int32T, Float64T) \
......
......@@ -13,12 +13,6 @@ namespace compiler {
namespace {
// TODO(v8:7703): ChangeTaggedToCompressed case to be removed when the
// TaggedEqual implementation stops using ChangeTaggedToCompressed.
bool IsChangeTaggedToCompressed(Node* const node) {
return node->opcode() == IrOpcode::kChangeTaggedToCompressed;
}
bool IsMachineLoad(Node* const node) {
const IrOpcode::Value opcode = node->opcode();
return opcode == IrOpcode::kLoad || opcode == IrOpcode::kPoisonedLoad ||
......@@ -31,27 +25,10 @@ bool IsTaggedMachineLoad(Node* const node) {
CanBeTaggedPointer(LoadRepresentationOf(node->op()).representation());
}
bool IsCompressedMachineLoad(Node* const node) {
return IsMachineLoad(node) &&
CanBeCompressedPointer(
LoadRepresentationOf(node->op()).representation());
}
bool IsCompressedHeapConstant(Node* const node) {
return node->opcode() == IrOpcode::kCompressedHeapConstant;
}
bool IsHeapConstant(Node* const node) {
return node->opcode() == IrOpcode::kHeapConstant;
}
bool IsCompressedPhi(Node* const node) {
if (node->opcode() == IrOpcode::kPhi) {
return CanBeCompressedPointer(PhiRepresentationOf(node->op()));
}
return false;
}
bool IsTaggedPhi(Node* const node) {
if (node->opcode() == IrOpcode::kPhi) {
return CanBeTaggedPointer(PhiRepresentationOf(node->op()));
......@@ -60,13 +37,7 @@ bool IsTaggedPhi(Node* const node) {
}
bool CanBeCompressed(Node* const node) {
return IsHeapConstant(node) || IsTaggedMachineLoad(node) ||
IsTaggedPhi(node) || IsChangeTaggedToCompressed(node);
}
bool IsCompressed(Node* const node) {
return IsCompressedHeapConstant(node) || IsCompressedMachineLoad(node) ||
IsCompressedPhi(node);
return IsHeapConstant(node) || IsTaggedMachineLoad(node) || IsTaggedPhi(node);
}
} // anonymous namespace
......@@ -94,9 +65,6 @@ void DecompressionOptimizer::MarkNodeInputs(Node* node) {
// Mark the value inputs.
switch (node->opcode()) {
// UNOPS.
// TODO(v8:7703): ChangeTaggedToCompressed case to be removed when the
// TaggedEqual implementation stops using ChangeTaggedToCompressed.
case IrOpcode::kChangeTaggedToCompressed:
case IrOpcode::kTruncateInt64ToInt32:
DCHECK_EQ(node->op()->ValueInputCount(), 1);
MaybeMarkAndQueueForRevisit(node->InputAt(0),
......@@ -246,21 +214,6 @@ void DecompressionOptimizer::ChangeLoad(Node* const node) {
}
}
void DecompressionOptimizer::TryRemoveChangeTaggedToCompressed(
Node* const node) {
DCHECK(IsChangeTaggedToCompressed(node));
Node* input = node->InputAt(0);
// We can safely eliminate a ChangeTaggedToCompressed node if its input is
// going to be changing to compressed in this same Reducer.
// Due to the ordering of the nodes to be changed, we might change the
// ChangeTaggedToCompressed's input before the ChangeTaggedToCompressed node
// itself changes. Then, we need to check for this possibility too.
if (IsOnly32BitsObserved(input) &&
(IsCompressed(input) || CanBeCompressed(input))) {
NodeProperties::ReplaceUses(node, input);
}
}
void DecompressionOptimizer::ChangeNodes() {
for (Node* const node : compressed_candidate_nodes_) {
// compressed_candidate_nodes_ contains all the nodes that once had the
......@@ -271,9 +224,6 @@ void DecompressionOptimizer::ChangeNodes() {
if (IsEverythingObserved(node)) continue;
switch (node->opcode()) {
case IrOpcode::kChangeTaggedToCompressed:
TryRemoveChangeTaggedToCompressed(node);
break;
case IrOpcode::kHeapConstant:
ChangeHeapConstant(node);
break;
......
......@@ -67,10 +67,6 @@ class V8_EXPORT_PRIVATE DecompressionOptimizer final {
// Change node's load into a compressed one.
void ChangeLoad(Node* const node);
// Remove a ChangeTaggedToCompressed if its input is going to become a
// compressed node.
void TryRemoveChangeTaggedToCompressed(Node* const node);
// Go through the already marked nodes and changed the operation for the nodes
// that can use compressed outputs.
void ChangeNodes();
......
......@@ -208,10 +208,6 @@ class MachineRepresentationInferrer {
case IrOpcode::kTaggedPoisonOnSpeculation:
representation_vector_[node->id()] = MachineRepresentation::kTagged;
break;
case IrOpcode::kChangeTaggedToCompressed:
representation_vector_[node->id()] =
MachineRepresentation::kCompressed;
break;
case IrOpcode::kWord32PoisonOnSpeculation:
representation_vector_[node->id()] = MachineRepresentation::kWord32;
break;
......@@ -375,9 +371,6 @@ class MachineRepresentationChecker {
CHECK_EQ(MachineRepresentation::kTagged,
inferrer_->GetRepresentation(node->InputAt(0)));
break;
case IrOpcode::kChangeTaggedToCompressed:
CheckValueInputIsCompressedOrTagged(node, 0);
break;
case IrOpcode::kRoundInt64ToFloat64:
case IrOpcode::kRoundUint64ToFloat64:
case IrOpcode::kRoundInt64ToFloat32:
......@@ -473,8 +466,13 @@ class MachineRepresentationChecker {
node, 1, inferrer_->GetRepresentation(node->InputAt(0)));
}
} else {
CheckValueIsCompressedOrInt32(node, 0);
CheckValueIsCompressedOrInt32(node, 1);
if (COMPRESS_POINTERS_BOOL) {
CheckValueInputIsCompressedOrTaggedOrInt32(node, 0);
CheckValueInputIsCompressedOrTaggedOrInt32(node, 1);
} else {
CheckValueIsTaggedOrInt32(node, 0);
CheckValueIsTaggedOrInt32(node, 1);
}
}
break;
......@@ -778,6 +776,32 @@ class MachineRepresentationChecker {
FATAL("%s", str.str().c_str());
}
void CheckValueInputIsCompressedOrTaggedOrInt32(Node const* node, int index) {
Node const* input = node->InputAt(index);
switch (inferrer_->GetRepresentation(input)) {
case MachineRepresentation::kCompressed:
case MachineRepresentation::kCompressedPointer:
return;
case MachineRepresentation::kTagged:
case MachineRepresentation::kTaggedPointer:
case MachineRepresentation::kTaggedSigned:
return;
case MachineRepresentation::kBit:
case MachineRepresentation::kWord8:
case MachineRepresentation::kWord16:
case MachineRepresentation::kWord32:
return;
default:
break;
}
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< " uses node #" << input->id() << ":" << *input->op()
<< " which doesn't have a compressed, tagged, or int32 representation.";
PrintDebugHelp(str, node);
FATAL("%s", str.str().c_str());
}
void CheckValueInputIsTaggedOrPointer(Node const* node, int index) {
Node const* input = node->InputAt(index);
switch (inferrer_->GetRepresentation(input)) {
......@@ -839,7 +863,7 @@ class MachineRepresentationChecker {
FATAL("%s", str.str().c_str());
}
void CheckValueIsCompressedOrInt32(Node const* node, int index) {
void CheckValueIsTaggedOrInt32(Node const* node, int index) {
Node const* input = node->InputAt(index);
switch (inferrer_->GetRepresentation(input)) {
case MachineRepresentation::kBit:
......@@ -847,8 +871,8 @@ class MachineRepresentationChecker {
case MachineRepresentation::kWord16:
case MachineRepresentation::kWord32:
return;
case MachineRepresentation::kCompressed:
case MachineRepresentation::kCompressedPointer:
case MachineRepresentation::kTagged:
case MachineRepresentation::kTaggedPointer:
return;
default:
break;
......@@ -856,7 +880,7 @@ class MachineRepresentationChecker {
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< " uses node #" << input->id() << ":" << *input->op()
<< " which doesn't have a compressed or int32-compatible "
<< " which doesn't have a tagged or int32-compatible "
"representation.";
PrintDebugHelp(str, node);
FATAL("%s", str.str().c_str());
......
......@@ -238,7 +238,6 @@ MachineType AtomicOpType(Operator const* op) {
V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \
V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \
V(ChangeTaggedToCompressed, Operator::kNoProperties, 1, 0, 1) \
V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1) \
V(BitcastFloat32ToInt32, Operator::kNoProperties, 1, 0, 1) \
......
......@@ -413,7 +413,6 @@ class V8_EXPORT_PRIVATE MachineOperatorBuilder final
const Operator* ChangeInt64ToFloat64();
const Operator* ChangeUint32ToFloat64();
const Operator* ChangeUint32ToUint64();
const Operator* ChangeTaggedToCompressed();
// These operators truncate or round numbers, both changing the representation
// of the number and mapping multiple input values onto the same output value.
......
......@@ -24,7 +24,6 @@ bool CanAllocate(const Node* node) {
case IrOpcode::kAbortCSAAssert:
case IrOpcode::kBitcastTaggedToWord:
case IrOpcode::kBitcastWordToTagged:
case IrOpcode::kChangeTaggedToCompressed:
case IrOpcode::kComment:
case IrOpcode::kDebugBreak:
case IrOpcode::kDeoptimizeIf:
......
......@@ -698,7 +698,6 @@
V(ChangeInt64ToFloat64) \
V(ChangeUint32ToFloat64) \
V(ChangeUint32ToUint64) \
V(ChangeTaggedToCompressed) \
V(TruncateFloat64ToFloat32) \
V(TruncateInt64ToInt32) \
V(RoundFloat64ToInt32) \
......
......@@ -739,9 +739,6 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
Node* ChangeUint32ToUint64(Node* a) {
return AddNode(machine()->ChangeUint32ToUint64(), a);
}
Node* ChangeTaggedToCompressed(Node* a) {
return AddNode(machine()->ChangeTaggedToCompressed(), a);
}
Node* TruncateFloat64ToFloat32(Node* a) {
return AddNode(machine()->TruncateFloat64ToFloat32(), a);
}
......
......@@ -1825,7 +1825,6 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
case IrOpcode::kBitcastWord32ToWord64:
case IrOpcode::kChangeInt32ToInt64:
case IrOpcode::kChangeUint32ToUint64:
case IrOpcode::kChangeTaggedToCompressed:
case IrOpcode::kChangeInt32ToFloat64:
case IrOpcode::kChangeInt64ToFloat64:
case IrOpcode::kChangeUint32ToFloat64:
......
......@@ -115,23 +115,15 @@ TEST_F(DecompressionOptimizerTest, Word32EqualTwoDecompresses) {
// Create the graph.
Node* load_1 = graph()->NewNode(machine()->Load(types[i]), object, index,
effect, control);
Node* change_to_tagged_1 =
graph()->NewNode(machine()->ChangeTaggedToCompressed(), load_1);
Node* load_2 = graph()->NewNode(machine()->Load(types[j]), object, index,
effect, control);
Node* change_to_tagged_2 =
graph()->NewNode(machine()->ChangeTaggedToCompressed(), load_2);
Node* equal = graph()->NewNode(machine()->Word32Equal(),
change_to_tagged_1, change_to_tagged_2);
Node* equal = graph()->NewNode(machine()->Word32Equal(), load_1, load_2);
graph()->SetEnd(equal);
// Change the nodes, and test the change.
Reduce();
EXPECT_EQ(LoadMachRep(load_1), CompressedMachRep(types[i]));
EXPECT_EQ(LoadMachRep(load_2), CompressedMachRep(types[j]));
// Test that we eliminate the ChangeTaggedToCompressed nodes.
EXPECT_EQ(equal->InputAt(0), load_1);
EXPECT_EQ(equal->InputAt(1), load_2);
}
}
}
......@@ -149,20 +141,15 @@ TEST_F(DecompressionOptimizerTest, Word32EqualDecompressAndConstant) {
// Create the graph.
Node* load = graph()->NewNode(machine()->Load(types[i]), object, index,
effect, control);
Node* change_to_tagged =
graph()->NewNode(machine()->ChangeTaggedToCompressed(), load);
Node* constant =
graph()->NewNode(common()->HeapConstant(heap_constants[j]));
Node* equal = graph()->NewNode(machine()->Word32Equal(), change_to_tagged,
constant);
Node* equal = graph()->NewNode(machine()->Word32Equal(), load, constant);
graph()->SetEnd(equal);
// Change the nodes, and test the change.
Reduce();
EXPECT_EQ(LoadMachRep(load), CompressedMachRep(types[i]));
EXPECT_EQ(constant->opcode(), IrOpcode::kCompressedHeapConstant);
// Test that we eliminate the ChangeTaggedToCompressed node.
EXPECT_EQ(equal->InputAt(0), load);
}
}
}
......
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