Commit e6459674 authored by dusan.milosavljevic's avatar dusan.milosavljevic Committed by Commit bot

MIPS64: Improve loading constants for double and integer values.

This CL reduces the size of generated code for snapshot by 1.6%.

TEST=
BUG=

Review URL: https://codereview.chromium.org/1039283002

Cr-Commit-Position: refs/heads/master@{#27514}
parent eda9a88f
...@@ -1260,13 +1260,43 @@ void MacroAssembler::li(Register rd, Operand j, LiFlags mode) { ...@@ -1260,13 +1260,43 @@ void MacroAssembler::li(Register rd, Operand j, LiFlags mode) {
lui(rd, (j.imm64_ >> kLuiShift) & kImm16Mask); lui(rd, (j.imm64_ >> kLuiShift) & kImm16Mask);
ori(rd, rd, (j.imm64_ & kImm16Mask)); ori(rd, rd, (j.imm64_ & kImm16Mask));
} }
} else {
if (is_int48(j.imm64_)) {
if ((j.imm64_ >> 32) & kImm16Mask) {
lui(rd, (j.imm64_ >> 32) & kImm16Mask);
if ((j.imm64_ >> 16) & kImm16Mask) {
ori(rd, rd, (j.imm64_ >> 16) & kImm16Mask);
}
} else {
ori(rd, zero_reg, (j.imm64_ >> 16) & kImm16Mask);
}
dsll(rd, rd, 16);
if (j.imm64_ & kImm16Mask) {
ori(rd, rd, j.imm64_ & kImm16Mask);
}
} else { } else {
lui(rd, (j.imm64_ >> 48) & kImm16Mask); lui(rd, (j.imm64_ >> 48) & kImm16Mask);
if ((j.imm64_ >> 32) & kImm16Mask) {
ori(rd, rd, (j.imm64_ >> 32) & kImm16Mask); ori(rd, rd, (j.imm64_ >> 32) & kImm16Mask);
}
if ((j.imm64_ >> 16) & kImm16Mask) {
dsll(rd, rd, 16); dsll(rd, rd, 16);
ori(rd, rd, (j.imm64_ >> 16) & kImm16Mask); ori(rd, rd, (j.imm64_ >> 16) & kImm16Mask);
if (j.imm64_ & kImm16Mask) {
dsll(rd, rd, 16); dsll(rd, rd, 16);
ori(rd, rd, j.imm64_ & kImm16Mask); ori(rd, rd, j.imm64_ & kImm16Mask);
} else {
dsll(rd, rd, 16);
}
} else {
if (j.imm64_ & kImm16Mask) {
dsll32(rd, rd, 0);
ori(rd, rd, j.imm64_ & kImm16Mask);
} else {
dsll32(rd, rd, 0);
}
}
}
} }
} else if (MustUseReg(j.rmode_)) { } else if (MustUseReg(j.rmode_)) {
RecordRelocInfo(j.rmode_, j.imm64_); RecordRelocInfo(j.rmode_, j.imm64_);
...@@ -1748,16 +1778,34 @@ void MacroAssembler::Move(FPURegister dst, double imm) { ...@@ -1748,16 +1778,34 @@ void MacroAssembler::Move(FPURegister dst, double imm) {
// Move the low part of the double into the lower bits of the corresponding // Move the low part of the double into the lower bits of the corresponding
// FPU register. // FPU register.
if (lo != 0) { if (lo != 0) {
li(at, Operand(lo)); if (!(lo & kImm16Mask)) {
lui(at, (lo >> kLuiShift) & kImm16Mask);
mtc1(at, dst);
} else if (!(lo & kHiMask)) {
ori(at, zero_reg, lo & kImm16Mask);
mtc1(at, dst); mtc1(at, dst);
} else {
lui(at, (lo >> kLuiShift) & kImm16Mask);
ori(at, at, lo & kImm16Mask);
mtc1(at, dst);
}
} else { } else {
mtc1(zero_reg, dst); mtc1(zero_reg, dst);
} }
// Move the high part of the double into the high bits of the corresponding // Move the high part of the double into the high bits of the corresponding
// FPU register. // FPU register.
if (hi != 0) { if (hi != 0) {
li(at, Operand(hi)); if (!(hi & kImm16Mask)) {
lui(at, (hi >> kLuiShift) & kImm16Mask);
mthc1(at, dst);
} else if (!(hi & kHiMask)) {
ori(at, zero_reg, hi & kImm16Mask);
mthc1(at, dst); mthc1(at, dst);
} else {
lui(at, (hi >> kLuiShift) & kImm16Mask);
ori(at, at, hi & kImm16Mask);
mthc1(at, dst);
}
} else { } else {
mthc1(zero_reg, dst); mthc1(zero_reg, dst);
} }
......
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