Commit a875615c authored by haoyuintel's avatar haoyuintel Committed by V8 LUCI CQ

[x64] Fix instruction selection for mov reg, Smi and TestMoveSmi

This CL fixed cmpq in TestMoveSmi by using cmp_tagged and further
optimizes Move(Register, Smi) for 31-bit negative Smi.

To move a Smi of -1 to register, the disassembly before the commit is as:
48c7c0feffffff    REX.W movq rax, 0xfffffffe

The disassembly after the commit is as:
b8feffffff        movl rax, 0xfffffffe

Bug: v8:12696
Change-Id: I6fafeec7959491ba8b084acf797c58910c2928fa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3514654Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Haoyu Zhang <haoyu.zhang@intel.com>
Cr-Commit-Position: refs/heads/main@{#79475}
parent 0250c874
...@@ -1463,8 +1463,8 @@ void TurboAssembler::Move(Register dst, Smi source) { ...@@ -1463,8 +1463,8 @@ void TurboAssembler::Move(Register dst, Smi source) {
} else if (SmiValuesAre32Bits()) { } else if (SmiValuesAre32Bits()) {
Move(dst, source.ptr(), RelocInfo::NO_INFO); Move(dst, source.ptr(), RelocInfo::NO_INFO);
} else { } else {
intptr_t svalue = static_cast<intptr_t>(source.ptr()); uint32_t uvalue = static_cast<uint32_t>(source.ptr());
Move(dst, svalue); Move(dst, uvalue);
} }
} }
......
...@@ -102,7 +102,7 @@ static void TestMoveSmi(MacroAssembler* masm, Label* exit, int id, Smi value) { ...@@ -102,7 +102,7 @@ static void TestMoveSmi(MacroAssembler* masm, Label* exit, int id, Smi value) {
__ movl(rax, Immediate(id)); __ movl(rax, Immediate(id));
__ Move(rcx, value); __ Move(rcx, value);
__ Move(rdx, static_cast<intptr_t>(value.ptr())); __ Move(rdx, static_cast<intptr_t>(value.ptr()));
__ cmpq(rcx, rdx); __ cmp_tagged(rcx, rdx);
__ j(not_equal, exit); __ j(not_equal, exit);
} }
......
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