瀏覽代碼

MIPS: Fix abs.[sd] and neg.[sd] emulation for NaN operands

This patch ensures that the sign bit is always updated for NaN operands.

Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Nigel Stephens 15 年之前
父節點
當前提交
cea2be4443
共有 2 個文件被更改,包括 7 次插入17 次删除
  1. 4 9
      arch/mips/math-emu/dp_simple.c
  2. 3 8
      arch/mips/math-emu/sp_simple.c

+ 4 - 9
arch/mips/math-emu/dp_simple.c

@@ -62,8 +62,6 @@ ieee754dp ieee754dp_neg(ieee754dp x)
 		return ieee754dp_nanxcpt(y, "neg");
 		return ieee754dp_nanxcpt(y, "neg");
 	}
 	}
 
 
-	if (ieee754dp_isnan(x))	/* but not infinity */
-		return ieee754dp_nanxcpt(x, "neg", x);
 	return x;
 	return x;
 }
 }
 
 
@@ -76,15 +74,12 @@ ieee754dp ieee754dp_abs(ieee754dp x)
 	CLEARCX;
 	CLEARCX;
 	FLUSHXDP;
 	FLUSHXDP;
 
 
+	/* Clear sign ALWAYS, irrespective of NaN */
+	DPSIGN(x) = 0;
+
 	if (xc == IEEE754_CLASS_SNAN) {
 	if (xc == IEEE754_CLASS_SNAN) {
-		SETCX(IEEE754_INVALID_OPERATION);
-		return ieee754dp_nanxcpt(ieee754dp_indef(), "neg");
+		return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
 	}
 	}
 
 
-	if (ieee754dp_isnan(x))	/* but not infinity */
-		return ieee754dp_nanxcpt(x, "abs", x);
-
-	/* quick fix up */
-	DPSIGN(x) = 0;
 	return x;
 	return x;
 }
 }

+ 3 - 8
arch/mips/math-emu/sp_simple.c

@@ -62,8 +62,6 @@ ieee754sp ieee754sp_neg(ieee754sp x)
 		return ieee754sp_nanxcpt(y, "neg");
 		return ieee754sp_nanxcpt(y, "neg");
 	}
 	}
 
 
-	if (ieee754sp_isnan(x))	/* but not infinity */
-		return ieee754sp_nanxcpt(x, "neg", x);
 	return x;
 	return x;
 }
 }
 
 
@@ -76,15 +74,12 @@ ieee754sp ieee754sp_abs(ieee754sp x)
 	CLEARCX;
 	CLEARCX;
 	FLUSHXSP;
 	FLUSHXSP;
 
 
+	/* Clear sign ALWAYS, irrespective of NaN */
+	SPSIGN(x) = 0;
+
 	if (xc == IEEE754_CLASS_SNAN) {
 	if (xc == IEEE754_CLASS_SNAN) {
-		SETCX(IEEE754_INVALID_OPERATION);
 		return ieee754sp_nanxcpt(ieee754sp_indef(), "abs");
 		return ieee754sp_nanxcpt(ieee754sp_indef(), "abs");
 	}
 	}
 
 
-	if (ieee754sp_isnan(x))	/* but not infinity */
-		return ieee754sp_nanxcpt(x, "abs", x);
-
-	/* quick fix up */
-	SPSIGN(x) = 0;
 	return x;
 	return x;
 }
 }