[ptr-compr] Added BitcastTaggedToWord* to DecompressionOptimizer

We were missing some possible load compressions due to not having these
bitcasts as cases.

Bug: v8:7703
Change-Id: I866196c4fd09d313d3a461cb7f8f80bc92278e13
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1989830
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65647}
This commit is contained in:
Santiago Aboy Solanes 2020-01-08 14:43:10 +00:00 committed by Commit Bot
parent 6e2e31e5fb
commit 904eaecbc6
3 changed files with 87 additions and 1 deletions

View File

@ -65,6 +65,13 @@ void DecompressionOptimizer::MarkNodeInputs(Node* node) {
// Mark the value inputs.
switch (node->opcode()) {
// UNOPS.
case IrOpcode::kBitcastTaggedToWord:
case IrOpcode::kBitcastTaggedToWordForTagAndSmiBits:
// Replicate the bitcast's state for its input.
DCHECK_EQ(node->op()->ValueInputCount(), 1);
MaybeMarkAndQueueForRevisit(node->InputAt(0),
states_.Get(node)); // value
break;
case IrOpcode::kTruncateInt64ToInt32:
DCHECK_EQ(node->op()->ValueInputCount(), 1);
MaybeMarkAndQueueForRevisit(node->InputAt(0),

View File

@ -393,6 +393,12 @@ class MachineRepresentationChecker {
break;
case IrOpcode::kBitcastTaggedToWord:
case IrOpcode::kBitcastTaggedToWordForTagAndSmiBits:
if (COMPRESS_POINTERS_BOOL) {
CheckValueInputIsCompressedOrTagged(node, 0);
} else {
CheckValueInputIsTagged(node, 0);
}
break;
case IrOpcode::kTaggedPoisonOnSpeculation:
CheckValueInputIsTagged(node, 0);
break;
@ -617,11 +623,19 @@ class MachineRepresentationChecker {
switch (inferrer_->GetRepresentation(node)) {
case MachineRepresentation::kTagged:
case MachineRepresentation::kTaggedPointer:
case MachineRepresentation::kTaggedSigned:
for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
CheckValueInputIsTagged(node, i);
}
break;
case MachineRepresentation::kTaggedSigned:
for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
if (COMPRESS_POINTERS_BOOL) {
CheckValueInputIsCompressedOrTagged(node, i);
} else {
CheckValueInputIsTagged(node, i);
}
}
break;
case MachineRepresentation::kCompressed:
case MachineRepresentation::kCompressedPointer:
for (int i = 0; i < node->op()->ValueInputCount(); ++i) {

View File

@ -424,6 +424,71 @@ TEST_F(DecompressionOptimizerTest, Int32LessThanOrEqualFromSpeculative) {
EXPECT_EQ(LoadMachRep(load), CompressedMachRep(MachineType::AnyTagged()));
}
// -----------------------------------------------------------------------------
// Bitcast cases.
TEST_F(DecompressionOptimizerTest, BitcastTaggedToWord) {
// Define variables.
Node* const control = graph()->start();
Node* object = Parameter(Type::Any(), 0);
Node* effect = graph()->start();
Node* index = Parameter(Type::UnsignedSmall(), 1);
// Test for both AnyTagged and TaggedPointer, for both loads.
for (size_t i = 0; i < arraysize(types); ++i) {
for (size_t j = 0; j < arraysize(types); ++j) {
// Create the graph.
Node* load_1 = graph()->NewNode(machine()->Load(types[i]), object, index,
effect, control);
Node* bitcast_1 = graph()->NewNode(machine()->BitcastTaggedToWord(),
load_1, effect, control);
Node* load_2 = graph()->NewNode(machine()->Load(types[j]), object, index,
effect, control);
Node* bitcast_2 = graph()->NewNode(machine()->BitcastTaggedToWord(),
load_2, effect, control);
Node* equal =
graph()->NewNode(machine()->Word32Equal(), bitcast_1, bitcast_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_F(DecompressionOptimizerTest, BitcastTaggedToWordForTagAndSmiBits) {
// Define variables.
Node* const control = graph()->start();
Node* object = Parameter(Type::Any(), 0);
Node* effect = graph()->start();
Node* index = Parameter(Type::UnsignedSmall(), 1);
// Test for both AnyTagged and TaggedPointer, for both loads.
for (size_t i = 0; i < arraysize(types); ++i) {
for (size_t j = 0; j < arraysize(types); ++j) {
// Create the graph.
Node* load_1 = graph()->NewNode(machine()->Load(types[i]), object, index,
effect, control);
Node* bitcast_1 = graph()->NewNode(
machine()->BitcastTaggedToWordForTagAndSmiBits(), load_1);
Node* load_2 = graph()->NewNode(machine()->Load(types[j]), object, index,
effect, control);
Node* bitcast_2 = graph()->NewNode(
machine()->BitcastTaggedToWordForTagAndSmiBits(), load_2);
Node* equal =
graph()->NewNode(machine()->Word32Equal(), bitcast_1, bitcast_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]));
}
}
}
} // namespace compiler
} // namespace internal
} // namespace v8