Commit 94ae207b authored by Georg Schmid's avatar Georg Schmid Committed by Commit Bot

[ptr-compr] Revisit transformed Phis in Decompression Elimination

Currently, decompression elimination may reduce phis by pushing decompressions in the value inputs of the phi "down" and replacing it by a single decompression following the phi node. Because of the way that the replacement is currently done, other reducers in the same phase will not generally get a chance to revisit the modified phi.

In the specific case of v8:9335 this blocked an additional optimization in CommonOperatorReducer from being applied, causing the overall load elimination test to fail.

This CL fixes the replacement behavior in decompression elimination to also allow for revisitations of the modified phi node.

Bug: v8:9335 v8:9336
Change-Id: I3ca5686dacb41a525160b08456905ba77cf28b39

Cq-Include-Trybots: luci.v8.try:v8_linux64_pointer_compression_rel_ng
Cq-Include-Trybots: luci.v8.try:v8_linux64_arm64_pointer_compression_rel_ng
Change-Id: I3ca5686dacb41a525160b08456905ba77cf28b39
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1648238Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Georg Schmid <gsps@google.com>
Cr-Commit-Position: refs/heads/master@{#62054}
parent f3462466
......@@ -131,7 +131,10 @@ Reduction DecompressionElimination::ReducePhi(Node* node) {
// Add a decompress after the Phi. To do this, we need to replace the Phi with
// "Phi <- Decompress".
return Replace(graph()->NewNode(op, node));
Node* decompress = graph()->NewNode(op, node);
ReplaceWithValue(node, decompress);
decompress->ReplaceInput(0, node);
return Changed(node);
}
Reduction DecompressionElimination::ReduceTypedStateValues(Node* node) {
......
......@@ -702,6 +702,7 @@ class MachineRepresentationChecker {
case IrOpcode::kThrow:
case IrOpcode::kTypedStateValues:
case IrOpcode::kFrameState:
case IrOpcode::kStaticAssert:
break;
default:
if (node->op()->ValueInputCount() != 0) {
......
......@@ -3,11 +3,14 @@
// found in the LICENSE file.
#include "src/compiler/decompression-elimination.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/simplified-operator.h"
#include "test/unittests/compiler/graph-reducer-unittest.h"
#include "test/unittests/compiler/graph-unittest.h"
#include "test/unittests/compiler/node-test-utils.h"
#include "testing/gmock-support.h"
using testing::_;
using testing::StrictMock;
namespace v8 {
......@@ -24,12 +27,29 @@ class DecompressionEliminationTest : public GraphTest {
~DecompressionEliminationTest() override = default;
protected:
Reduction Reduce(Node* node) {
StrictMock<MockAdvancedReducerEditor> editor;
DecompressionElimination decompression_elimination(&editor, graph(),
Reduction Reduce(StrictMock<MockAdvancedReducerEditor>* editor, Node* node) {
DecompressionElimination decompression_elimination(editor, graph(),
machine(), common());
return decompression_elimination.Reduce(node);
}
Reduction Reduce(Node* node) {
StrictMock<MockAdvancedReducerEditor> editor;
return Reduce(&editor, node);
}
Node* GetUniqueValueUse(Node* node) {
Node* value_use = nullptr;
for (Edge edge : node->use_edges()) {
if (NodeProperties::IsValueEdge(edge)) {
if (value_use) {
return nullptr;
} else {
value_use = edge.from();
}
}
}
// Return the value use of node after the reduction, if there is exactly one
return value_use;
}
MachineOperatorBuilder* machine() { return &machine_; }
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
......@@ -422,9 +442,13 @@ TEST_F(DecompressionEliminationTest, PhiOneDecompress) {
change_to_tagged, control);
// Reduce
Reduction r = Reduce(phi);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, ReplaceWithValue(phi, _, _, _));
Reduction r = Reduce(&editor, phi);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(opcodes[i], r.replacement()->opcode());
Node* decompress = GetUniqueValueUse(phi);
EXPECT_NE(nullptr, decompress);
EXPECT_EQ(opcodes[i], decompress->opcode());
}
}
......@@ -483,9 +507,13 @@ TEST_F(DecompressionEliminationTest, PhiThreeDecompressSameRepresentation) {
change_to_tagged1, change_to_tagged2, change_to_tagged3, control);
// Reduce
Reduction r = Reduce(phi);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, ReplaceWithValue(phi, _, _, _));
Reduction r = Reduce(&editor, phi);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(opcodes[i], r.replacement()->opcode());
Node* decompress = GetUniqueValueUse(phi);
EXPECT_NE(nullptr, decompress);
EXPECT_EQ(opcodes[i], decompress->opcode());
}
}
......@@ -540,9 +568,13 @@ TEST_F(DecompressionEliminationTest, PhiThreeDecompressOneAnyRepresentation) {
change_to_tagged1, change_to_tagged2, change_to_tagged3, control);
// Reduce
Reduction r = Reduce(phi);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, ReplaceWithValue(phi, _, _, _));
Reduction r = Reduce(&editor, phi);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(IrOpcode::kChangeCompressedToTagged, r.replacement()->opcode());
Node* decompress = GetUniqueValueUse(phi);
EXPECT_NE(nullptr, decompress);
EXPECT_EQ(IrOpcode::kChangeCompressedToTagged, decompress->opcode());
}
}
......@@ -641,9 +673,13 @@ TEST_F(DecompressionEliminationTest, PhiTwoDecompressesOneSignedOnePointer) {
change_to_tagged1, change_to_tagged2, control);
// Reduce
Reduction r = Reduce(phi);
StrictMock<MockAdvancedReducerEditor> editor;
EXPECT_CALL(editor, ReplaceWithValue(phi, _, _, _));
Reduction r = Reduce(&editor, phi);
ASSERT_TRUE(r.Changed());
EXPECT_EQ(IrOpcode::kChangeCompressedToTagged, r.replacement()->opcode());
Node* decompress = GetUniqueValueUse(phi);
EXPECT_NE(nullptr, decompress);
EXPECT_EQ(IrOpcode::kChangeCompressedToTagged, decompress->opcode());
}
// -----------------------------------------------------------------------------
......
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