Commit c37f6f02 authored by Miran.Karic's avatar Miran.Karic Committed by Commit bot

MIPS: Use neg instruction in r6

Floating point negate instructions are still present in release 6, only
one format of neg is removed, NEG.PS. Others formats can be used and in
r6 they also change the sign of NaN-like operands as well. This makes r6
generated code simpler for Neg_d and Neg_s macroassembler functions.

BUG=

Review-Url: https://codereview.chromium.org/2285703002
Cr-Commit-Position: refs/heads/master@{#38943}
parent 2059fb0b
......@@ -3442,7 +3442,9 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
// Math.sqrt(-Infinity) == NaN
Label done;
__ Move(temp, static_cast<double>(-V8_INFINITY));
// Set up Infinity.
__ Neg_d(result, temp);
// result is overwritten if the branch is not taken.
__ BranchF(&done, NULL, eq, temp, input);
// Add +0 to convert -0 to +0.
......
......@@ -3649,7 +3649,9 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
// Math.sqrt(-Infinity) == NaN
Label done;
__ Move(temp, static_cast<double>(-V8_INFINITY));
// Set up Infinity.
__ Neg_d(result, temp);
// result is overwritten if the branch is not taken.
__ BranchF(&done, NULL, eq, temp, input);
// Add +0 to convert -0 to +0.
......
......@@ -1915,8 +1915,6 @@ void MacroAssembler::Ins(Register rt,
}
void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
Register scratch1 = t8;
Register scratch2 = t9;
if (IsMipsArchVariant(kMips32r2)) {
Label is_nan, done;
Register scratch1 = t8;
......@@ -1926,7 +1924,6 @@ void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
// For NaN input, neg_s will return the same NaN value,
// while the sign has to be changed separately.
neg_s(fd, fs); // In delay slot.
bind(&is_nan);
mfc1(scratch1, fs);
And(scratch2, scratch1, Operand(~kBinary32SignMask));
......@@ -1936,26 +1933,21 @@ void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
mtc1(scratch2, fd);
bind(&done);
} else {
mfc1(scratch1, fs);
And(scratch2, scratch1, Operand(~kBinary32SignMask));
And(scratch1, scratch1, Operand(kBinary32SignMask));
Xor(scratch1, scratch1, Operand(kBinary32SignMask));
Or(scratch2, scratch2, scratch1);
mtc1(scratch2, fd);
// r6 neg_s changes the sign for NaN-like operands as well.
neg_s(fd, fs);
}
}
void MacroAssembler::Neg_d(FPURegister fd, FPURegister fs) {
Register scratch1 = t8;
Register scratch2 = t9;
if (IsMipsArchVariant(kMips32r2)) {
Label is_nan, done;
Register scratch1 = t8;
Register scratch2 = t9;
BranchF64(nullptr, &is_nan, eq, fs, fs);
Branch(USE_DELAY_SLOT, &done);
// For NaN input, neg_d will return the same NaN value,
// while the sign has to be changed separately.
neg_d(fd, fs); // In delay slot.
bind(&is_nan);
Mfhc1(scratch1, fs);
And(scratch2, scratch1, Operand(~HeapNumber::kSignMask));
......@@ -1965,13 +1957,8 @@ void MacroAssembler::Neg_d(FPURegister fd, FPURegister fs) {
Mthc1(scratch2, fd);
bind(&done);
} else {
Move_d(fd, fs);
Mfhc1(scratch1, fs);
And(scratch2, scratch1, Operand(~HeapNumber::kSignMask));
And(scratch1, scratch1, Operand(HeapNumber::kSignMask));
Xor(scratch1, scratch1, Operand(HeapNumber::kSignMask));
Or(scratch2, scratch2, scratch1);
Mthc1(scratch2, fd);
// r6 neg_d changes the sign for NaN-like operands as well.
neg_d(fd, fs);
}
}
......
......@@ -1960,10 +1960,10 @@ void MacroAssembler::Ins(Register rt,
}
void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
Register scratch1 = t8;
Register scratch2 = t9;
if (kArchVariant == kMips64r2) {
Label is_nan, done;
Register scratch1 = t8;
Register scratch2 = t9;
BranchF32(nullptr, &is_nan, eq, fs, fs);
Branch(USE_DELAY_SLOT, &done);
// For NaN input, neg_s will return the same NaN value,
......@@ -1978,20 +1978,16 @@ void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
mtc1(scratch2, fd);
bind(&done);
} else {
mfc1(scratch1, fs);
And(scratch2, scratch1, Operand(~kBinary32SignMask));
And(scratch1, scratch1, Operand(kBinary32SignMask));
Xor(scratch1, scratch1, Operand(kBinary32SignMask));
Or(scratch2, scratch2, scratch1);
mtc1(scratch2, fd);
// r6 neg_s changes the sign for NaN-like operands as well.
neg_s(fd, fs);
}
}
void MacroAssembler::Neg_d(FPURegister fd, FPURegister fs) {
Register scratch1 = t8;
Register scratch2 = t9;
if (kArchVariant == kMips64r2) {
Label is_nan, done;
Register scratch1 = t8;
Register scratch2 = t9;
BranchF64(nullptr, &is_nan, eq, fs, fs);
Branch(USE_DELAY_SLOT, &done);
// For NaN input, neg_d will return the same NaN value,
......@@ -2006,12 +2002,8 @@ void MacroAssembler::Neg_d(FPURegister fd, FPURegister fs) {
dmtc1(scratch2, fd);
bind(&done);
} else {
dmfc1(scratch1, fs);
And(scratch2, scratch1, Operand(~Double::kSignMask));
And(scratch1, scratch1, Operand(Double::kSignMask));
Xor(scratch1, scratch1, Operand(Double::kSignMask));
Or(scratch2, scratch2, scratch1);
dmtc1(scratch2, fd);
// r6 neg_d changes the sign for NaN-like operands as well.
neg_d(fd, fs);
}
}
......
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