Fixup asin and acos errors for LoongArch

(cherry picked from commit d7774929145fcc559a76bc1b1a294711385602e2)
This commit is contained in:
Xing Li 2023-02-02 19:49:48 +08:00 committed by openeuler-sync-bot
parent d9dce02ed8
commit 9cd31027a4
3 changed files with 69 additions and 7 deletions

View File

@ -66,7 +66,7 @@
############################################################################## ##############################################################################
Name: glibc Name: glibc
Version: 2.34 Version: 2.34
Release: 107 Release: 108
Summary: The GNU libc libraries Summary: The GNU libc libraries
License: %{all_license} License: %{all_license}
URL: http://www.gnu.org/software/glibc/ URL: http://www.gnu.org/software/glibc/
@ -278,6 +278,7 @@ Patch9027: 3_6-LoongArch-Optimize-string-function-memset.patch
Patch9028: 4_6-LoongArch-Optimize-string-functions-strcmp-strncmp.patch Patch9028: 4_6-LoongArch-Optimize-string-functions-strcmp-strncmp.patch
Patch9029: 5_6-LoongArch-Optimize-string-function-strcpy.patch Patch9029: 5_6-LoongArch-Optimize-string-function-strcpy.patch
Patch9030: 6_6-LoongArch-Optimize-string-functions-strlen-strnlen.patch Patch9030: 6_6-LoongArch-Optimize-string-functions-strlen-strnlen.patch
Patch9031: math-Fix-asin-and-acos-invalid-exception-with-old-gc.patch
%endif %endif
Provides: ldconfig rtld(GNU_HASH) bundled(gnulib) Provides: ldconfig rtld(GNU_HASH) bundled(gnulib)
@ -1444,6 +1445,9 @@ fi
%endif %endif
%changelog %changelog
* Thu Feb 2 2023 lixing <lixing@loongson.cn> - 2.34-108
- Fixup asin and acos errors for LoongArch.
* Tue Jan 31 2023 lixing <lixing@loongson.cn> - 2.34-107 * Tue Jan 31 2023 lixing <lixing@loongson.cn> - 2.34-107
- Fixup testsuite_whitelist for LoongArch. - Fixup testsuite_whitelist for LoongArch.

View File

@ -0,0 +1,64 @@
From 672f05a903f2b3ef7144c8c92efdff5e766a0dba Mon Sep 17 00:00:00 2001
From: XingLi <lixing@loongson.cn>
Date: Thu, 2 Feb 2023 18:49:01 +0800
Subject: [PATCH] math: Fix asin and acos invalid exception with old gcc
This works around a gcc issue where it const folded inf/inf into nan,
preventing the invalid exception to be signalled.
(x-x)/(x-x) is more robust against optimizations and works for all
out of bounds values including x==nan.
The gcc issue https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95115
should be fixed on release branches starting from gcc-10, but it is
better to change the code in case glibc is built with older gcc.
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
upstream commit 7363a9a9a097c455a7ddb9386b4c6f7bdf91065f
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
---
sysdeps/ieee754/dbl-64/e_asin.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/sysdeps/ieee754/dbl-64/e_asin.c b/sysdeps/ieee754/dbl-64/e_asin.c
index 4473ae5d..b03a0a94 100644
--- a/sysdeps/ieee754/dbl-64/e_asin.c
+++ b/sysdeps/ieee754/dbl-64/e_asin.c
@@ -165,15 +165,8 @@ __ieee754_asin(double x){
/*---------------------------- |x|>=1 -------------------------------*/
else if (k==0x3ff00000 && u.i[LOW_HALF]==0) return (m>0)?hp0.x:-hp0.x;
else
- if (k>0x7ff00000 || (k == 0x7ff00000 && u.i[LOW_HALF] != 0)) return x + x;
- else {
- u.i[HIGH_HALF]=0x7ff00000;
- v.i[HIGH_HALF]=0x7ff00000;
- u.i[LOW_HALF]=0;
- v.i[LOW_HALF]=0;
- return u.x/v.x; /* NaN */
- }
-}
+ return (x - x) / (x - x);
+ }
#ifndef __ieee754_asin
libm_alias_finite (__ieee754_asin, __asin)
#endif
@@ -334,14 +327,7 @@ __ieee754_acos(double x)
else
if (k==0x3ff00000 && u.i[LOW_HALF]==0) return (m>0)?0:2.0*hp0.x;
else
- if (k>0x7ff00000 || (k == 0x7ff00000 && u.i[LOW_HALF] != 0)) return x + x;
- else {
- u.i[HIGH_HALF]=0x7ff00000;
- v.i[HIGH_HALF]=0x7ff00000;
- u.i[LOW_HALF]=0;
- v.i[LOW_HALF]=0;
- return u.x/v.x;
- }
+ return (x - x) / (x - x);
}
#ifndef __ieee754_acos
libm_alias_finite (__ieee754_acos, __acos)
--
2.33.0

View File

@ -131,11 +131,5 @@ misc/tst-rseq
# These testcase fails as left problems. # These testcase fails as left problems.
elf/tst-ifunc-fault-bindnow:loongarch64 elf/tst-ifunc-fault-bindnow:loongarch64
elf/tst-ifunc-fault-lazy:loongarch64 elf/tst-ifunc-fault-lazy:loongarch64
math/test-double-acos:loongarch64
math/test-double-asin:loongarch64
math/test-float32x-acos:loongarch64
math/test-float32x-asin:loongarch64
math/test-float64-acos:loongarch64
math/test-float64-asin:loongarch64
locale/tst-localedef-path-norm:loongarch64 locale/tst-localedef-path-norm:loongarch64
misc/tst-glibcsyscalls:loongarch64 misc/tst-glibcsyscalls:loongarch64