Bug 875419 - Fold ImmWord values which fit in 32-bit immediate fields. r=sstangl

This commit is contained in:
Dan Gohman 2013-06-04 20:52:21 -04:00
Родитель 941646f2ae
Коммит 4f601ff93d
1 изменённых файлов: 18 добавлений и 6 удалений

Просмотреть файл

@ -387,8 +387,12 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
cmpq(lhs, ScratchReg);
}
void cmpPtr(const Operand &lhs, const ImmWord rhs) {
mov(rhs, ScratchReg);
cmpq(lhs, ScratchReg);
if ((intptr_t)rhs.value <= INT32_MAX && (intptr_t)rhs.value >= INT32_MIN) {
cmpq(lhs, Imm32((int32_t)rhs.value));
} else {
mov(rhs, ScratchReg);
cmpq(lhs, ScratchReg);
}
}
void cmpPtr(const Address &lhs, const ImmGCPtr rhs) {
cmpPtr(Operand(lhs), rhs);
@ -443,8 +447,12 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
}
void addPtr(ImmWord imm, const Register &dest) {
JS_ASSERT(dest != ScratchReg);
mov(imm, ScratchReg);
addq(ScratchReg, dest);
if ((intptr_t)imm.value <= INT32_MAX && (intptr_t)imm.value >= INT32_MIN) {
addq(Imm32((int32_t)imm.value), dest);
} else {
mov(imm, ScratchReg);
addq(ScratchReg, dest);
}
}
void addPtr(const Address &src, const Register &dest) {
addq(Operand(src), dest);
@ -554,8 +562,12 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
shlq(Imm32(1), dest);
}
void storePtr(ImmWord imm, const Address &address) {
mov(imm, ScratchReg);
movq(ScratchReg, Operand(address));
if ((intptr_t)imm.value <= INT32_MAX && (intptr_t)imm.value >= INT32_MIN) {
mov(Imm32((int32_t)imm.value), Operand(address));
} else {
mov(imm, ScratchReg);
movq(ScratchReg, Operand(address));
}
}
void storePtr(ImmGCPtr imm, const Address &address) {
movq(imm, ScratchReg);