Commit cbf56ee5 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[csa] Make CSA::TaggedEqual use WordEqual

Similar to https://crrev.com/c/1781047, WordEqual already does the right
truncation in the instruction selector.

Bug: v8:8948
Change-Id: I92e74bafab6a467aeca1570494e9044f9cf18c46
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1781049
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63504}
parent 611d84ee
......@@ -470,32 +470,16 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<BoolT> TaggedEqual(TNode<UnionT<Object, MaybeObject>> a,
TNode<UnionT<Object, MaybeObject>> b) {
// We use very sketchy looking ReinterpretCasts here to avoid adding bit
// casts (which mess with GVN since they introduce themselves into the
// effect chain). It happens to be safe here, but don't try this at home!
if (kTaggedSize == kInt64Size) {
return WordEqual(ReinterpretCast<WordT>(a), ReinterpretCast<WordT>(b));
} else {
DCHECK_EQ(kTaggedSize, kInt32Size);
// These casts will also truncate under pointer compression.
return Word32Equal(ReinterpretCast<Word32T>(a),
ReinterpretCast<Word32T>(b));
}
// In pointer-compressed architectures, the instruction selector will narrow
// this comparison to a 32-bit one.
return WordEqual(ReinterpretCast<WordT>(a), ReinterpretCast<WordT>(b));
}
TNode<BoolT> TaggedNotEqual(TNode<UnionT<Object, MaybeObject>> a,
TNode<UnionT<Object, MaybeObject>> b) {
// We use very sketchy looking ReinterpretCasts here to avoid adding bit
// casts (which mess with GVN since they introduce themselves into the
// effect chain). It happens to be safe here, but don't try this at home!
if (kTaggedSize == kInt64Size) {
return WordNotEqual(ReinterpretCast<WordT>(a), ReinterpretCast<WordT>(b));
} else {
DCHECK_EQ(kTaggedSize, kInt32Size);
// These casts will also truncate under pointer compression.
return Word32NotEqual(ReinterpretCast<Word32T>(a),
ReinterpretCast<Word32T>(b));
}
// In pointer-compressed architectures, the instruction selector will narrow
// this comparison to a 32-bit one.
return WordNotEqual(ReinterpretCast<WordT>(a), ReinterpretCast<WordT>(b));
}
TNode<Object> NoContextConstant();
......
......@@ -462,13 +462,8 @@ class MachineRepresentationChecker {
break;
case IrOpcode::kWord64Equal:
if (Is64()) {
if (COMPRESS_POINTERS_BOOL) {
CheckValueInputForInt64Op(node, 0);
CheckValueInputForInt64Op(node, 1);
} else {
CheckValueInputIsTaggedOrPointer(node, 0);
CheckValueInputIsTaggedOrPointer(node, 1);
}
CheckValueInputIsTaggedOrPointer(node, 0);
CheckValueInputIsTaggedOrPointer(node, 1);
if (!is_stub_) {
CheckValueInputRepresentationIs(
node, 1, inferrer_->GetRepresentation(node->InputAt(0)));
......@@ -520,15 +515,8 @@ class MachineRepresentationChecker {
node, 1, inferrer_->GetRepresentation(node->InputAt(0)));
}
} else {
if (COMPRESS_POINTERS_BOOL) {
// We explicitly allow 64-bit tagged values into Word32Equal,
// for truncating tagged pointer comparison.
CheckValueIsCompressedOrTaggedOrInt32(node, 0);
CheckValueIsCompressedOrTaggedOrInt32(node, 0);
} else {
CheckValueIsCompressedOrInt32(node, 0);
CheckValueIsCompressedOrInt32(node, 1);
}
CheckValueIsCompressedOrInt32(node, 0);
CheckValueIsCompressedOrInt32(node, 1);
}
break;
......@@ -896,34 +884,6 @@ class MachineRepresentationChecker {
FATAL("%s", str.str().c_str());
}
void CheckValueIsCompressedOrTaggedOrInt32(Node const* node, int index) {
Node const* input = node->InputAt(index);
switch (inferrer_->GetRepresentation(input)) {
case MachineRepresentation::kBit:
case MachineRepresentation::kWord8:
case MachineRepresentation::kWord16:
case MachineRepresentation::kWord32:
return;
case MachineRepresentation::kTagged:
case MachineRepresentation::kTaggedPointer:
case MachineRepresentation::kTaggedSigned:
return;
case MachineRepresentation::kCompressed:
case MachineRepresentation::kCompressedSigned:
case MachineRepresentation::kCompressedPointer:
return;
default:
break;
}
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< " uses node #" << input->id() << ":" << *input->op()
<< " which doesn't have a compressed, tagged, or int32-compatible "
"representation.";
PrintDebugHelp(str, node);
FATAL("%s", str.str().c_str());
}
void CheckValueInputForInt64Op(Node const* node, int index) {
Node const* input = node->InputAt(index);
MachineRepresentation input_representation =
......
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