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

[ptr-compr] Consider node ordering for RemoveChangeTaggedToCompressed

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.

Bug: v8:7703
Change-Id: I2b453211dc264b509f2ea7c0cf891be50f404009
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1942607
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65248}
parent ca5b0ec2
......@@ -31,10 +31,27 @@ 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()));
......@@ -47,6 +64,11 @@ bool CanBeCompressed(Node* const node) {
IsTaggedPhi(node) || IsChangeTaggedToCompressed(node);
}
bool IsCompressed(Node* const node) {
return IsCompressedHeapConstant(node) || IsCompressedMachineLoad(node) ||
IsCompressedPhi(node);
}
} // anonymous namespace
DecompressionOptimizer::DecompressionOptimizer(Zone* zone, Graph* graph,
......@@ -229,7 +251,11 @@ void DecompressionOptimizer::RemoveChangeTaggedToCompressed(Node* const 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.
if (IsOnly32BitsObserved(input) && CanBeCompressed(input)) {
// 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);
}
}
......
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