summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcmvbkbc <jcmvbkbc@138bc75d-0d04-0410-961f-82ee72b054a4>2018-01-23 21:47:51 +0000
committerjcmvbkbc <jcmvbkbc@138bc75d-0d04-0410-961f-82ee72b054a4>2018-01-23 21:47:51 +0000
commit598768d5c31e9fc9a39a7530782068d4bdcb0891 (patch)
treefa41073b67ba497b372cfcc9a13d5215bac0a9b6
parent4d28913a860579d645b24591fb300b4d8dd3cd55 (diff)
libgcc: xtensa: fix NaN return from add/sub/mul/div helpers
libgcc/ 2018-01-23 Max Filippov <jcmvbkbc@gmail.com> Backport from mainline 2018-01-23 Max Filippov <jcmvbkbc@gmail.com> * config/xtensa/ieee754-df.S (__addsf3, __subsf3, __mulsf3) (__divsf3): Make NaN return value quiet. * config/xtensa/ieee754-sf.S (__adddf3, __subdf3, __muldf3) (__divdf3): Make NaN return value quiet. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257003 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libgcc/ChangeLog10
-rw-r--r--libgcc/config/xtensa/ieee754-df.S54
-rw-r--r--libgcc/config/xtensa/ieee754-sf.S51
3 files changed, 84 insertions, 31 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 86fd102d3207..f5f77159aaa7 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,13 @@
+2018-01-23 Max Filippov <jcmvbkbc@gmail.com>
+
+ Backport from mainline
+ 2018-01-23 Max Filippov <jcmvbkbc@gmail.com>
+
+ * config/xtensa/ieee754-df.S (__addsf3, __subsf3, __mulsf3)
+ (__divsf3): Make NaN return value quiet.
+ * config/xtensa/ieee754-sf.S (__adddf3, __subdf3, __muldf3)
+ (__divdf3): Make NaN return value quiet.
+
2018-01-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
Backport from mainline
diff --git a/libgcc/config/xtensa/ieee754-df.S b/libgcc/config/xtensa/ieee754-df.S
index bdd27e52b101..8493dc0372f9 100644
--- a/libgcc/config/xtensa/ieee754-df.S
+++ b/libgcc/config/xtensa/ieee754-df.S
@@ -64,17 +64,26 @@ __adddf3_aux:
.Ladd_xnan_or_inf:
/* If y is neither Infinity nor NaN, return x. */
- bnall yh, a6, 1f
+ bnall yh, a6, .Ladd_return_nan_or_inf
/* If x is a NaN, return it. Otherwise, return y. */
slli a7, xh, 12
or a7, a7, xl
- beqz a7, .Ladd_ynan_or_inf
-1: leaf_return
+ bnez a7, .Ladd_return_nan
.Ladd_ynan_or_inf:
/* Return y. */
mov xh, yh
mov xl, yl
+
+.Ladd_return_nan_or_inf:
+ slli a7, xh, 12
+ or a7, a7, xl
+ bnez a7, .Ladd_return_nan
+ leaf_return
+
+.Ladd_return_nan:
+ movi a4, 0x80000 /* make it a quiet NaN */
+ or xh, xh, a4
leaf_return
.Ladd_opposite_signs:
@@ -319,17 +328,24 @@ __subdf3_aux:
.Lsub_xnan_or_inf:
/* If y is neither Infinity nor NaN, return x. */
- bnall yh, a6, 1f
+ bnall yh, a6, .Lsub_return_nan_or_inf
+
+.Lsub_return_nan:
/* Both x and y are either NaN or Inf, so the result is NaN. */
movi a4, 0x80000 /* make it a quiet NaN */
or xh, xh, a4
-1: leaf_return
+ leaf_return
.Lsub_ynan_or_inf:
/* Negate y and return it. */
slli a7, a6, 11
xor xh, yh, a7
mov xl, yl
+
+.Lsub_return_nan_or_inf:
+ slli a7, xh, 12
+ or a7, a7, xl
+ bnez a7, .Lsub_return_nan
leaf_return
.Lsub_opposite_signs:
@@ -692,10 +708,7 @@ __muldf3_aux:
/* If y is zero, return NaN. */
bnez yl, 1f
slli a8, yh, 1
- bnez a8, 1f
- movi a4, 0x80000 /* make it a quiet NaN */
- or xh, xh, a4
- j .Lmul_done
+ beqz a8, .Lmul_return_nan
1:
/* If y is NaN, return y. */
bnall yh, a6, .Lmul_returnx
@@ -708,6 +721,9 @@ __muldf3_aux:
mov xl, yl
.Lmul_returnx:
+ slli a8, xh, 12
+ or a8, a8, xl
+ bnez a8, .Lmul_return_nan
/* Set the sign bit and return. */
extui a7, a7, 31, 1
slli xh, xh, 1
@@ -720,8 +736,11 @@ __muldf3_aux:
bnez xl, .Lmul_returny
slli a8, xh, 1
bnez a8, .Lmul_returny
- movi a7, 0x80000 /* make it a quiet NaN */
- or xh, yh, a7
+ mov xh, yh
+
+.Lmul_return_nan:
+ movi a4, 0x80000 /* make it a quiet NaN */
+ or xh, xh, a4
j .Lmul_done
.align 4
@@ -1370,10 +1389,11 @@ __divdf3_aux:
slli a7, a7, 31
xor xh, xh, a7
/* If y is NaN or Inf, return NaN. */
- bnall yh, a6, 1f
- movi a4, 0x80000 /* make it a quiet NaN */
- or xh, xh, a4
-1: leaf_return
+ ball yh, a6, .Ldiv_return_nan
+ slli a8, xh, 12
+ or a8, a8, xl
+ bnez a8, .Ldiv_return_nan
+ leaf_return
.Ldiv_ynan_or_inf:
/* If y is Infinity, return zero. */
@@ -1383,6 +1403,10 @@ __divdf3_aux:
/* y is NaN; return it. */
mov xh, yh
mov xl, yl
+
+.Ldiv_return_nan:
+ movi a4, 0x80000 /* make it a quiet NaN */
+ or xh, xh, a4
leaf_return
.Ldiv_highequal1:
diff --git a/libgcc/config/xtensa/ieee754-sf.S b/libgcc/config/xtensa/ieee754-sf.S
index a61aba94b51a..1db8e01b9cc3 100644
--- a/libgcc/config/xtensa/ieee754-sf.S
+++ b/libgcc/config/xtensa/ieee754-sf.S
@@ -64,15 +64,23 @@ __addsf3_aux:
.Ladd_xnan_or_inf:
/* If y is neither Infinity nor NaN, return x. */
- bnall a3, a6, 1f
+ bnall a3, a6, .Ladd_return_nan_or_inf
/* If x is a NaN, return it. Otherwise, return y. */
slli a7, a2, 9
- beqz a7, .Ladd_ynan_or_inf
-1: leaf_return
+ bnez a7, .Ladd_return_nan
.Ladd_ynan_or_inf:
/* Return y. */
mov a2, a3
+
+.Ladd_return_nan_or_inf:
+ slli a7, a2, 9
+ bnez a7, .Ladd_return_nan
+ leaf_return
+
+.Ladd_return_nan:
+ movi a6, 0x400000 /* make it a quiet NaN */
+ or a2, a2, a6
leaf_return
.Ladd_opposite_signs:
@@ -265,16 +273,22 @@ __subsf3_aux:
.Lsub_xnan_or_inf:
/* If y is neither Infinity nor NaN, return x. */
- bnall a3, a6, 1f
+ bnall a3, a6, .Lsub_return_nan_or_inf
/* Both x and y are either NaN or Inf, so the result is NaN. */
+
+.Lsub_return_nan:
movi a4, 0x400000 /* make it a quiet NaN */
or a2, a2, a4
-1: leaf_return
+ leaf_return
.Lsub_ynan_or_inf:
/* Negate y and return it. */
slli a7, a6, 8
xor a2, a3, a7
+
+.Lsub_return_nan_or_inf:
+ slli a7, a2, 9
+ bnez a7, .Lsub_return_nan
leaf_return
.Lsub_opposite_signs:
@@ -537,11 +551,7 @@ __mulsf3_aux:
.Lmul_xnan_or_inf:
/* If y is zero, return NaN. */
slli a8, a3, 1
- bnez a8, 1f
- movi a4, 0x400000 /* make it a quiet NaN */
- or a2, a2, a4
- j .Lmul_done
-1:
+ beqz a8, .Lmul_return_nan
/* If y is NaN, return y. */
bnall a3, a6, .Lmul_returnx
slli a8, a3, 9
@@ -551,6 +561,8 @@ __mulsf3_aux:
mov a2, a3
.Lmul_returnx:
+ slli a8, a2, 9
+ bnez a8, .Lmul_return_nan
/* Set the sign bit and return. */
extui a7, a7, 31, 1
slli a2, a2, 1
@@ -562,8 +574,11 @@ __mulsf3_aux:
/* If x is zero, return NaN. */
slli a8, a2, 1
bnez a8, .Lmul_returny
- movi a7, 0x400000 /* make it a quiet NaN */
- or a2, a3, a7
+ mov a2, a3
+
+.Lmul_return_nan:
+ movi a4, 0x400000 /* make it a quiet NaN */
+ or a2, a2, a4
j .Lmul_done
.align 4
@@ -995,10 +1010,10 @@ __divsf3_aux:
slli a7, a7, 31
xor a2, a2, a7
/* If y is NaN or Inf, return NaN. */
- bnall a3, a6, 1f
- movi a4, 0x400000 /* make it a quiet NaN */
- or a2, a2, a4
-1: leaf_return
+ ball a3, a6, .Ldiv_return_nan
+ slli a7, a2, 9
+ bnez a7, .Ldiv_return_nan
+ leaf_return
.Ldiv_ynan_or_inf:
/* If y is Infinity, return zero. */
@@ -1006,6 +1021,10 @@ __divsf3_aux:
beqz a8, .Ldiv_return_zero
/* y is NaN; return it. */
mov a2, a3
+
+.Ldiv_return_nan:
+ movi a4, 0x400000 /* make it a quiet NaN */
+ or a2, a2, a4
leaf_return
.align 4