Commit 58a64478 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[ptr-compr][turbofan] Specialize Word32 -> CompressedSigned conversion

Reverse specialization of https://chromium-review.googlesource.com/c/v8/v8/+/1684075.
Again, it skips over Tagged to save some instructions.

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
Bug: v8:7703
Change-Id: I7fc50e0d8eebfef7a1ba02ce3d687ff808f30680
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1693007Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62645}
parent 14bfcf7c
......@@ -51,6 +51,7 @@ class EffectControlLinearizer {
bool TryWireInStateEffect(Node* node, Node* frame_state, Node** effect,
Node** control);
Node* LowerChangeBitToTagged(Node* node);
Node* LowerChangeInt31ToCompressedSigned(Node* node);
Node* LowerChangeInt31ToTaggedSigned(Node* node);
Node* LowerChangeInt32ToTagged(Node* node);
Node* LowerChangeInt64ToTagged(Node* node);
......@@ -221,6 +222,7 @@ class EffectControlLinearizer {
Node* LowerStringComparison(Callable const& callable, Node* node);
Node* IsElementsKindGreaterThan(Node* kind, ElementsKind reference_kind);
Node* ChangeInt32ToCompressedSmi(Node* value);
Node* ChangeInt32ToSmi(Node* value);
Node* ChangeInt32ToIntPtr(Node* value);
Node* ChangeInt64ToSmi(Node* value);
......@@ -835,6 +837,9 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kChangeBitToTagged:
result = LowerChangeBitToTagged(node);
break;
case IrOpcode::kChangeInt31ToCompressedSigned:
result = LowerChangeInt31ToCompressedSigned(node);
break;
case IrOpcode::kChangeInt31ToTaggedSigned:
result = LowerChangeInt31ToTaggedSigned(node);
break;
......@@ -1386,6 +1391,11 @@ Node* EffectControlLinearizer::LowerChangeBitToTagged(Node* node) {
return done.PhiAt(0);
}
Node* EffectControlLinearizer::LowerChangeInt31ToCompressedSigned(Node* node) {
Node* value = node->InputAt(0);
return ChangeInt32ToCompressedSmi(value);
}
Node* EffectControlLinearizer::LowerChangeInt31ToTaggedSigned(Node* node) {
Node* value = node->InputAt(0);
return ChangeInt32ToSmi(value);
......@@ -4420,6 +4430,11 @@ Node* EffectControlLinearizer::ChangeIntPtrToInt32(Node* value) {
return value;
}
Node* EffectControlLinearizer::ChangeInt32ToCompressedSmi(Node* value) {
CHECK(machine()->Is64() && SmiValuesAre31Bits());
return __ Word32Shl(value, SmiShiftBitsConstant());
}
Node* EffectControlLinearizer::ChangeInt32ToSmi(Node* value) {
// Do shift on 32bit values if Smis are stored in the lower word.
if (machine()->Is64() && SmiValuesAre31Bits()) {
......
......@@ -242,6 +242,7 @@
V(ChangeTaggedToTaggedSigned) \
V(ChangeCompressedToTaggedSigned) \
V(ChangeTaggedToCompressedSigned) \
V(ChangeInt31ToCompressedSigned) \
V(ChangeInt31ToTaggedSigned) \
V(ChangeInt32ToTagged) \
V(ChangeInt64ToTagged) \
......
......@@ -634,9 +634,13 @@ Node* RepresentationChanger::GetCompressedSignedRepresentationFor(
use_node, use_info);
op = machine()->ChangeTaggedSignedToCompressedSigned();
} else if (IsWord(output_rep)) {
node = GetTaggedSignedRepresentationFor(node, output_rep, output_type,
use_node, use_info);
op = machine()->ChangeTaggedSignedToCompressedSigned();
if (output_type.Is(Type::Signed31())) {
op = simplified()->ChangeInt31ToCompressedSigned();
} else {
node = GetTaggedSignedRepresentationFor(node, output_rep, output_type,
use_node, use_info);
op = machine()->ChangeTaggedSignedToCompressedSigned();
}
} else if (output_rep == MachineRepresentation::kWord64) {
node = GetTaggedSignedRepresentationFor(node, output_rep, output_type,
use_node, use_info);
......
......@@ -731,6 +731,7 @@ bool operator==(CheckMinusZeroParameters const& lhs,
V(ChangeCompressedToTaggedSigned, Operator::kNoProperties, 1, 0) \
V(ChangeTaggedToCompressedSigned, Operator::kNoProperties, 1, 0) \
V(ChangeFloat64ToTaggedPointer, Operator::kNoProperties, 1, 0) \
V(ChangeInt31ToCompressedSigned, Operator::kNoProperties, 1, 0) \
V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \
V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \
V(ChangeInt64ToTagged, Operator::kNoProperties, 1, 0) \
......
......@@ -705,6 +705,7 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* ChangeTaggedToTaggedSigned();
const Operator* ChangeCompressedToTaggedSigned();
const Operator* ChangeTaggedToCompressedSigned();
const Operator* ChangeInt31ToCompressedSigned();
const Operator* ChangeInt31ToTaggedSigned();
const Operator* ChangeInt32ToTagged();
const Operator* ChangeInt64ToTagged();
......
......@@ -1375,6 +1375,7 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
// CheckTypeIs(node, to));
break;
}
case IrOpcode::kChangeInt31ToCompressedSigned:
case IrOpcode::kChangeInt31ToTaggedSigned: {
// Signed31 /\ UntaggedInt32 -> Signed31 /\ Tagged
// TODO(neis): Activate once ChangeRepresentation works in typer.
......
......@@ -522,6 +522,9 @@ TEST(SingleChanges) {
CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit,
Type::Boolean(), MachineRepresentation::kTagged);
CheckChange(IrOpcode::kChangeInt31ToCompressedSigned,
MachineRepresentation::kWord32, Type::Signed31(),
MachineRepresentation::kCompressedSigned);
CheckChange(IrOpcode::kChangeInt31ToTaggedSigned,
MachineRepresentation::kWord32, Type::Signed31(),
MachineRepresentation::kTagged);
......
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