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