Commit 0f872428 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[ptr-compr] Add Word32And case for DecompressionOptimizer

Smi checks get lowered to Word32And, so they are important to consider
in the reducer.

Bug: v8:7703
Change-Id: Ie6e2403db84f83808edcc1e44ecb60ecd72ae34d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1876053
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64638}
parent 2b9c0b3c
......@@ -58,10 +58,12 @@ void DecompressionOptimizer::MarkNodeInputs(Node* node) {
// TODO(v8:7703): 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),
State::kOnly32BitsObserved); // value
break;
case IrOpcode::kWord32And:
case IrOpcode::kWord32Equal:
DCHECK_EQ(node->op()->ValueInputCount(), 2);
MaybeMarkAndQueueForRevisit(node->InputAt(0),
......@@ -69,8 +71,8 @@ void DecompressionOptimizer::MarkNodeInputs(Node* node) {
MaybeMarkAndQueueForRevisit(node->InputAt(1),
State::kOnly32BitsObserved); // value_1
break;
case IrOpcode::kStore: // Fall through.
case IrOpcode::kProtectedStore: // Fall through.
case IrOpcode::kStore:
case IrOpcode::kProtectedStore:
case IrOpcode::kUnalignedStore:
DCHECK_EQ(node->op()->ValueInputCount(), 3);
MaybeMarkAndQueueForRevisit(node->InputAt(0),
......
......@@ -4588,9 +4588,6 @@ Node* EffectControlLinearizer::ChangeSmiToInt64(Node* value) {
}
Node* EffectControlLinearizer::ObjectIsSmi(Node* value) {
if (machine()->Is64()) {
value = __ TruncateInt64ToInt32(value);
}
return __ Word32Equal(__ Word32And(value, __ Int32Constant(kSmiTagMask)),
__ Int32Constant(kSmiTag));
}
......
......@@ -89,7 +89,7 @@ TEST_F(DecompressionOptimizerTest, DirectLoadStore) {
}
// -----------------------------------------------------------------------------
// Word32Equal.
// Word32 Operations.
TEST_F(DecompressionOptimizerTest, Word32EqualTwoDecompresses) {
// Skip test if decompression elimination is enabled.
......@@ -126,7 +126,7 @@ TEST_F(DecompressionOptimizerTest, Word32EqualTwoDecompresses) {
}
}
TEST_F(DecompressionOptimizerTest, Word32DecompressAndConstant) {
TEST_F(DecompressionOptimizerTest, Word32EqualDecompressAndConstant) {
// Skip test if decompression elimination is enabled.
if (FLAG_turbo_decompression_elimination) {
return;
......@@ -175,6 +175,35 @@ TEST_F(DecompressionOptimizerTest, Word32DecompressAndConstant) {
}
}
TEST_F(DecompressionOptimizerTest, Word32AndSmiCheck) {
// Skip test if decompression elimination is enabled.
if (FLAG_turbo_decompression_elimination) {
return;
}
// 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 (size_t i = 0; i < arraysize(types); ++i) {
// Create the graph.
Node* load = graph()->NewNode(machine()->Load(types[i]), object, index,
effect, control);
Node* smi_tag_mask = graph()->NewNode(common()->Int32Constant(kSmiTagMask));
Node* word32_and =
graph()->NewNode(machine()->Word32And(), load, smi_tag_mask);
Node* smi_tag = graph()->NewNode(common()->Int32Constant(kSmiTag));
graph()->SetEnd(
graph()->NewNode(machine()->Word32Equal(), word32_and, smi_tag));
// Change the nodes, and test the change.
Reduce();
EXPECT_EQ(LoadMachRep(load), CompressedMachRep(types[i]));
}
}
} // namespace compiler
} // namespace internal
} // namespace v8
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