[turbofan][x64][ptr-compr] Use root register for kHeapConstant equality

VisitWord32EqualImpl was checking for inputs of type
kCompressedHeapConstant, but it can also sometimes have inputs of type
kHeapConstant. In either case, we can check for whether to do a load
from the roots array. This improves Octane score by about 3% (or about
1.5% if --no-opt is specified).

Bug: v8:8948
Change-Id: Iab6c0b1dacd96c74e4cfb54c772aa92e5baf00ff
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2213081
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67981}
This commit is contained in:
Seth Brenith 2020-05-26 08:56:05 -07:00 committed by Commit Bot
parent 2bf94b8699
commit 02acf4a005

View File

@ -1898,16 +1898,33 @@ void VisitWord32EqualImpl(InstructionSelector* selector, Node* node,
X64OperandGenerator g(selector);
const RootsTable& roots_table = selector->isolate()->roots_table();
RootIndex root_index;
Node* left = nullptr;
Handle<HeapObject> right;
// HeapConstants and CompressedHeapConstants can be treated the same when
// using them as an input to a 32-bit comparison. Check whether either is
// present.
{
CompressedHeapObjectBinopMatcher m(node);
if (m.right().HasValue() &&
roots_table.IsRootHandle(m.right().Value(), &root_index)) {
if (m.right().HasValue()) {
left = m.left().node();
right = m.right().Value();
} else {
HeapObjectBinopMatcher m2(node);
if (m2.right().HasValue()) {
left = m2.left().node();
right = m2.right().Value();
}
}
}
if (!right.is_null() && roots_table.IsRootHandle(right, &root_index)) {
DCHECK_NE(left, nullptr);
InstructionCode opcode =
kX64Cmp32 | AddressingModeField::encode(kMode_Root);
return VisitCompare(
selector, opcode,
g.TempImmediate(
TurboAssemblerBase::RootRegisterOffsetForRootIndex(root_index)),
g.UseRegister(m.left().node()), cont);
g.UseRegister(left), cont);
}
}
VisitWordCompare(selector, node, kX64Cmp32, cont);