Skip to content

Commit b120a05

Browse files
committedNov 14, 2023
8319406: x86: Shorter movptr(reg, imm) for 32-bit immediates
Reviewed-by: qamai, kvn
1 parent 7df73a2 commit b120a05

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed
 

‎src/hotspot/cpu/x86/assembler_x86.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -13450,17 +13450,6 @@ void Assembler::movsbq(Register dst, Register src) {
1345013450
emit_int24(0x0F, (unsigned char)0xBE, (0xC0 | encode));
1345113451
}
1345213452

13453-
void Assembler::movslq(Register dst, int32_t imm32) {
13454-
// dbx shows movslq(rcx, 3) as movq $0x0000000049000000,(%rbx)
13455-
// and movslq(r8, 3); as movl $0x0000000048000000,(%rbx)
13456-
// as a result we shouldn't use until tested at runtime...
13457-
ShouldNotReachHere();
13458-
InstructionMark im(this);
13459-
int encode = prefixq_and_encode(dst->encoding());
13460-
emit_int8(0xC7 | encode);
13461-
emit_int32(imm32);
13462-
}
13463-
1346413453
void Assembler::movslq(Address dst, int32_t imm32) {
1346513454
assert(is_simm32(imm32), "lost bits");
1346613455
InstructionMark im(this);

‎src/hotspot/cpu/x86/assembler_x86.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,6 @@ class Assembler : public AbstractAssembler {
16561656

16571657
// Move signed 32bit immediate to 64bit extending sign
16581658
void movslq(Address dst, int32_t imm64);
1659-
void movslq(Register dst, int32_t imm64);
16601659

16611660
void movslq(Register dst, Address src);
16621661
void movslq(Register dst, Register src);

‎src/hotspot/cpu/x86/macroAssembler_x86.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,12 @@ void MacroAssembler::call(AddressLiteral entry, Register rscratch) {
13391339

13401340
void MacroAssembler::ic_call(address entry, jint method_index) {
13411341
RelocationHolder rh = virtual_call_Relocation::spec(pc(), method_index);
1342+
#ifdef _LP64
1343+
// Needs full 64-bit immediate for later patching.
1344+
mov64(rax, (intptr_t)Universe::non_oop_word());
1345+
#else
13421346
movptr(rax, (intptr_t)Universe::non_oop_word());
1347+
#endif
13431348
call(AddressLiteral(entry, rh));
13441349
}
13451350

@@ -2562,7 +2567,15 @@ void MacroAssembler::movptr(Register dst, Address src) {
25622567

25632568
// src should NEVER be a real pointer. Use AddressLiteral for true pointers
25642569
void MacroAssembler::movptr(Register dst, intptr_t src) {
2565-
LP64_ONLY(mov64(dst, src)) NOT_LP64(movl(dst, src));
2570+
#ifdef _LP64
2571+
if (is_simm32(src)) {
2572+
movq(dst, checked_cast<int32_t>(src));
2573+
} else {
2574+
mov64(dst, src);
2575+
}
2576+
#else
2577+
movl(dst, src);
2578+
#endif
25662579
}
25672580

25682581
void MacroAssembler::movptr(Address dst, Register src) {

0 commit comments

Comments
 (0)
Please sign in to comment.