[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/+/1693007
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62645}
This commit is contained in:
Santiago Aboy Solanes 2019-07-09 16:41:18 +01:00 committed by Commit Bot
parent 14bfcf7ca3
commit 58a6447814
7 changed files with 29 additions and 3 deletions

View File

@ -51,6 +51,7 @@ class EffectControlLinearizer {
bool TryWireInStateEffect(Node* node, Node* frame_state, Node** effect, bool TryWireInStateEffect(Node* node, Node* frame_state, Node** effect,
Node** control); Node** control);
Node* LowerChangeBitToTagged(Node* node); Node* LowerChangeBitToTagged(Node* node);
Node* LowerChangeInt31ToCompressedSigned(Node* node);
Node* LowerChangeInt31ToTaggedSigned(Node* node); Node* LowerChangeInt31ToTaggedSigned(Node* node);
Node* LowerChangeInt32ToTagged(Node* node); Node* LowerChangeInt32ToTagged(Node* node);
Node* LowerChangeInt64ToTagged(Node* node); Node* LowerChangeInt64ToTagged(Node* node);
@ -221,6 +222,7 @@ class EffectControlLinearizer {
Node* LowerStringComparison(Callable const& callable, Node* node); Node* LowerStringComparison(Callable const& callable, Node* node);
Node* IsElementsKindGreaterThan(Node* kind, ElementsKind reference_kind); Node* IsElementsKindGreaterThan(Node* kind, ElementsKind reference_kind);
Node* ChangeInt32ToCompressedSmi(Node* value);
Node* ChangeInt32ToSmi(Node* value); Node* ChangeInt32ToSmi(Node* value);
Node* ChangeInt32ToIntPtr(Node* value); Node* ChangeInt32ToIntPtr(Node* value);
Node* ChangeInt64ToSmi(Node* value); Node* ChangeInt64ToSmi(Node* value);
@ -835,6 +837,9 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kChangeBitToTagged: case IrOpcode::kChangeBitToTagged:
result = LowerChangeBitToTagged(node); result = LowerChangeBitToTagged(node);
break; break;
case IrOpcode::kChangeInt31ToCompressedSigned:
result = LowerChangeInt31ToCompressedSigned(node);
break;
case IrOpcode::kChangeInt31ToTaggedSigned: case IrOpcode::kChangeInt31ToTaggedSigned:
result = LowerChangeInt31ToTaggedSigned(node); result = LowerChangeInt31ToTaggedSigned(node);
break; break;
@ -1386,6 +1391,11 @@ Node* EffectControlLinearizer::LowerChangeBitToTagged(Node* node) {
return done.PhiAt(0); return done.PhiAt(0);
} }
Node* EffectControlLinearizer::LowerChangeInt31ToCompressedSigned(Node* node) {
Node* value = node->InputAt(0);
return ChangeInt32ToCompressedSmi(value);
}
Node* EffectControlLinearizer::LowerChangeInt31ToTaggedSigned(Node* node) { Node* EffectControlLinearizer::LowerChangeInt31ToTaggedSigned(Node* node) {
Node* value = node->InputAt(0); Node* value = node->InputAt(0);
return ChangeInt32ToSmi(value); return ChangeInt32ToSmi(value);
@ -4420,6 +4430,11 @@ Node* EffectControlLinearizer::ChangeIntPtrToInt32(Node* value) {
return value; return value;
} }
Node* EffectControlLinearizer::ChangeInt32ToCompressedSmi(Node* value) {
CHECK(machine()->Is64() && SmiValuesAre31Bits());
return __ Word32Shl(value, SmiShiftBitsConstant());
}
Node* EffectControlLinearizer::ChangeInt32ToSmi(Node* value) { Node* EffectControlLinearizer::ChangeInt32ToSmi(Node* value) {
// Do shift on 32bit values if Smis are stored in the lower word. // Do shift on 32bit values if Smis are stored in the lower word.
if (machine()->Is64() && SmiValuesAre31Bits()) { if (machine()->Is64() && SmiValuesAre31Bits()) {

View File

@ -242,6 +242,7 @@
V(ChangeTaggedToTaggedSigned) \ V(ChangeTaggedToTaggedSigned) \
V(ChangeCompressedToTaggedSigned) \ V(ChangeCompressedToTaggedSigned) \
V(ChangeTaggedToCompressedSigned) \ V(ChangeTaggedToCompressedSigned) \
V(ChangeInt31ToCompressedSigned) \
V(ChangeInt31ToTaggedSigned) \ V(ChangeInt31ToTaggedSigned) \
V(ChangeInt32ToTagged) \ V(ChangeInt32ToTagged) \
V(ChangeInt64ToTagged) \ V(ChangeInt64ToTagged) \

View File

@ -634,9 +634,13 @@ Node* RepresentationChanger::GetCompressedSignedRepresentationFor(
use_node, use_info); use_node, use_info);
op = machine()->ChangeTaggedSignedToCompressedSigned(); op = machine()->ChangeTaggedSignedToCompressedSigned();
} else if (IsWord(output_rep)) { } else if (IsWord(output_rep)) {
node = GetTaggedSignedRepresentationFor(node, output_rep, output_type, if (output_type.Is(Type::Signed31())) {
use_node, use_info); op = simplified()->ChangeInt31ToCompressedSigned();
op = machine()->ChangeTaggedSignedToCompressedSigned(); } else {
node = GetTaggedSignedRepresentationFor(node, output_rep, output_type,
use_node, use_info);
op = machine()->ChangeTaggedSignedToCompressedSigned();
}
} else if (output_rep == MachineRepresentation::kWord64) { } else if (output_rep == MachineRepresentation::kWord64) {
node = GetTaggedSignedRepresentationFor(node, output_rep, output_type, node = GetTaggedSignedRepresentationFor(node, output_rep, output_type,
use_node, use_info); use_node, use_info);

View File

@ -731,6 +731,7 @@ bool operator==(CheckMinusZeroParameters const& lhs,
V(ChangeCompressedToTaggedSigned, Operator::kNoProperties, 1, 0) \ V(ChangeCompressedToTaggedSigned, Operator::kNoProperties, 1, 0) \
V(ChangeTaggedToCompressedSigned, Operator::kNoProperties, 1, 0) \ V(ChangeTaggedToCompressedSigned, Operator::kNoProperties, 1, 0) \
V(ChangeFloat64ToTaggedPointer, Operator::kNoProperties, 1, 0) \ V(ChangeFloat64ToTaggedPointer, Operator::kNoProperties, 1, 0) \
V(ChangeInt31ToCompressedSigned, Operator::kNoProperties, 1, 0) \
V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \ V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0) \
V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \ V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0) \
V(ChangeInt64ToTagged, Operator::kNoProperties, 1, 0) \ V(ChangeInt64ToTagged, Operator::kNoProperties, 1, 0) \

View File

@ -705,6 +705,7 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* ChangeTaggedToTaggedSigned(); const Operator* ChangeTaggedToTaggedSigned();
const Operator* ChangeCompressedToTaggedSigned(); const Operator* ChangeCompressedToTaggedSigned();
const Operator* ChangeTaggedToCompressedSigned(); const Operator* ChangeTaggedToCompressedSigned();
const Operator* ChangeInt31ToCompressedSigned();
const Operator* ChangeInt31ToTaggedSigned(); const Operator* ChangeInt31ToTaggedSigned();
const Operator* ChangeInt32ToTagged(); const Operator* ChangeInt32ToTagged();
const Operator* ChangeInt64ToTagged(); const Operator* ChangeInt64ToTagged();

View File

@ -1375,6 +1375,7 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
// CheckTypeIs(node, to)); // CheckTypeIs(node, to));
break; break;
} }
case IrOpcode::kChangeInt31ToCompressedSigned:
case IrOpcode::kChangeInt31ToTaggedSigned: { case IrOpcode::kChangeInt31ToTaggedSigned: {
// Signed31 /\ UntaggedInt32 -> Signed31 /\ Tagged // Signed31 /\ UntaggedInt32 -> Signed31 /\ Tagged
// TODO(neis): Activate once ChangeRepresentation works in typer. // TODO(neis): Activate once ChangeRepresentation works in typer.

View File

@ -522,6 +522,9 @@ TEST(SingleChanges) {
CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit, CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit,
Type::Boolean(), MachineRepresentation::kTagged); Type::Boolean(), MachineRepresentation::kTagged);
CheckChange(IrOpcode::kChangeInt31ToCompressedSigned,
MachineRepresentation::kWord32, Type::Signed31(),
MachineRepresentation::kCompressedSigned);
CheckChange(IrOpcode::kChangeInt31ToTaggedSigned, CheckChange(IrOpcode::kChangeInt31ToTaggedSigned,
MachineRepresentation::kWord32, Type::Signed31(), MachineRepresentation::kWord32, Type::Signed31(),
MachineRepresentation::kTagged); MachineRepresentation::kTagged);