Commit e66547b7 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[x64] Avoid movl into register for cmpl

Avoid materializing a compressed value into a register if that value is
only used for a compare afterward. Instead, emit it directly as an
immediate on the cml. We can only do this for the Cmp(Register,...)
overload, not Cmp(Operand,...), since the latter already has the lhs as
a complex operand.

Change-Id: I99f192c9919e401164d31d2e2e1c3a0c21a6aaf0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3762577
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81721}
parent df2fc072
......@@ -1656,11 +1656,24 @@ void TurboAssembler::Move(XMMRegister dst, uint64_t high, uint64_t low) {
void MacroAssembler::Cmp(Register dst, Handle<Object> source) {
if (source->IsSmi()) {
Cmp(dst, Smi::cast(*source));
} else {
Move(kScratchRegister, Handle<HeapObject>::cast(source),
COMPRESS_POINTERS_BOOL ? RelocInfo::COMPRESSED_EMBEDDED_OBJECT
: RelocInfo::FULL_EMBEDDED_OBJECT);
} else if (root_array_available_ && options().isolate_independent_code) {
// TODO(jgruber,v8:8887): Also consider a root-relative load when generating
// non-isolate-independent code. In many cases it might be cheaper than
// embedding the relocatable value.
// TODO(v8:9706): Fix-it! This load will always uncompress the value
// even when we are loading a compressed embedded object.
IndirectLoadConstant(kScratchRegister, Handle<HeapObject>::cast(source));
cmp_tagged(dst, kScratchRegister);
} else if (COMPRESS_POINTERS_BOOL) {
EmbeddedObjectIndex index =
AddEmbeddedObject(Handle<HeapObject>::cast(source));
DCHECK(is_uint32(index));
cmpl(dst, Immediate(static_cast<int>(index),
RelocInfo::COMPRESSED_EMBEDDED_OBJECT));
} else {
movq(kScratchRegister,
Immediate64(source.address(), RelocInfo::FULL_EMBEDDED_OBJECT));
cmpq(dst, kScratchRegister);
}
}
......
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