Commit 1ceb9aec authored by Miran.Karic's avatar Miran.Karic Committed by Commit bot

MIPS: Fix Neg_s and Neg_d for loongson and r1

For arch variants loongson and r1 neg instruction does not change the
sign for NaN-like operands, the same as r2 neg. This fix adjusts macro
assembler Neg_s and Neg_d arch variant logic so the correct code would
be generated for loongson and r1.

BUG=

Review-Url: https://codereview.chromium.org/2287333002
Cr-Commit-Position: refs/heads/master@{#39007}
parent 708f80d2
......@@ -1915,7 +1915,12 @@ void MacroAssembler::Ins(Register rt,
}
void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
if (IsMipsArchVariant(kMips32r2)) {
if (IsMipsArchVariant(kMips32r6)) {
// r6 neg_s changes the sign for NaN-like operands as well.
neg_s(fd, fs);
} else {
DCHECK(IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r1) ||
IsMipsArchVariant(kLoongson));
Label is_nan, done;
Register scratch1 = t8;
Register scratch2 = t9;
......@@ -1932,14 +1937,16 @@ void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
Or(scratch2, scratch2, scratch1);
mtc1(scratch2, fd);
bind(&done);
} else {
// r6 neg_s changes the sign for NaN-like operands as well.
neg_s(fd, fs);
}
}
void MacroAssembler::Neg_d(FPURegister fd, FPURegister fs) {
if (IsMipsArchVariant(kMips32r2)) {
if (IsMipsArchVariant(kMips32r6)) {
// r6 neg_d changes the sign for NaN-like operands as well.
neg_d(fd, fs);
} else {
DCHECK(IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r1) ||
IsMipsArchVariant(kLoongson));
Label is_nan, done;
Register scratch1 = t8;
Register scratch2 = t9;
......@@ -1956,9 +1963,6 @@ void MacroAssembler::Neg_d(FPURegister fd, FPURegister fs) {
Or(scratch2, scratch2, scratch1);
Mthc1(scratch2, fd);
bind(&done);
} else {
// r6 neg_d changes the sign for NaN-like operands as well.
neg_d(fd, fs);
}
}
......
......@@ -1960,7 +1960,11 @@ void MacroAssembler::Ins(Register rt,
}
void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
if (kArchVariant == kMips64r2) {
if (kArchVariant == kMips64r6) {
// r6 neg_s changes the sign for NaN-like operands as well.
neg_s(fd, fs);
} else {
DCHECK(kArchVariant == kMips64r2);
Label is_nan, done;
Register scratch1 = t8;
Register scratch2 = t9;
......@@ -1977,14 +1981,15 @@ void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) {
Or(scratch2, scratch2, scratch1);
mtc1(scratch2, fd);
bind(&done);
} else {
// r6 neg_s changes the sign for NaN-like operands as well.
neg_s(fd, fs);
}
}
void MacroAssembler::Neg_d(FPURegister fd, FPURegister fs) {
if (kArchVariant == kMips64r2) {
if (kArchVariant == kMips64r6) {
// r6 neg_d changes the sign for NaN-like operands as well.
neg_d(fd, fs);
} else {
DCHECK(kArchVariant == kMips64r2);
Label is_nan, done;
Register scratch1 = t8;
Register scratch2 = t9;
......@@ -2001,9 +2006,6 @@ void MacroAssembler::Neg_d(FPURegister fd, FPURegister fs) {
Or(scratch2, scratch2, scratch1);
dmtc1(scratch2, fd);
bind(&done);
} else {
// 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