From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id BFA9F385E013 for ; Thu, 26 Mar 2020 09:09:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BFA9F385E013 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02Q94Rvg086439 for ; Thu, 26 Mar 2020 05:09:04 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywf3hcpdj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 26 Mar 2020 05:09:03 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Mar 2020 09:09:01 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 26 Mar 2020 09:08:59 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02Q97u3e46465476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 Mar 2020 09:07:57 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30AD511C04A for ; Thu, 26 Mar 2020 09:08:59 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0853411C052 for ; Thu, 26 Mar 2020 09:08:59 +0000 (GMT) Received: from oc4452167425.ibm.com (unknown [9.145.46.2]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Thu, 26 Mar 2020 09:08:58 +0000 (GMT) Subject: Re: [PATCH 3/4] Use libc_fe* macros in ldbl-128/e_expl.c. To: libc-alpha@sourceware.org References: <20200325100628.883397-1-stli@linux.ibm.com> <20200325100628.883397-3-stli@linux.ibm.com> <58bf789b-e9ca-a72a-b796-a3425da448d5@linux.ibm.com> <06bc5510-8a7e-ec79-227a-a155755bad47@linaro.org> <03b8556b-6c01-09e3-4d8d-c49519f64d42@linaro.org> From: Stefan Liebler Date: Thu, 26 Mar 2020 10:08:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <03b8556b-6c01-09e3-4d8d-c49519f64d42@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 20032609-0028-0000-0000-000003EC1990 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20032609-0029-0000-0000-000024B18A4F Message-Id: <920d9eb5-2e48-8bba-bac1-81a73fe825c6@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-25_15:2020-03-24, 2020-03-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=913 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003260062 X-Spam-Status: No, score=-23.0 required=5.0 tests=BAYES_00, BODY_8BITS, GARBLED_BODY, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_LOTSOFHASH, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2020 09:09:06 -0000 On 3/25/20 4:42 PM, Adhemerval Zanella via Libc-alpha wrote: > > > On 25/03/2020 12:07, Adhemerval Zanella wrote: >> >> >> On 25/03/2020 12:00, Adhemerval Zanella wrote: >>> >>> >>> On 25/03/2020 07:13, Stefan Liebler via Libc-alpha wrote: >>>> Unfortunately, this patch is responsible for testfails on x86_64: >>>> >>>> math/test-float128-exp.out: >>>> Failure: exp (-0x1p-10000): Exception "Underflow" set >>>> Failure: exp (-0x2p-16384): Exception "Underflow" set >>>> ... >>>> >>>> math/test-float128-cexp.out: >>>> Failure: Real part of: cexp (0x2p-16384 - 0x4p-1076 i): Exception "Underflow" set >>>> Failure: Real part of: cexp (0x2p-16384 - 0x8p-152 i): Exception "Underflow" set >>> >>> The sysdeps/x86/fpu/fenv_private.h states: >>> >>> 296 #ifdef __x86_64__ >>> 297 /* The SSE rounding mode is used by soft-fp (libgcc and glibc) on >>> 298 x86_64, so that must be set for float128 computations. */ >>> 299 # define SET_RESTORE_ROUNDF128(RM) \ >>> 300 SET_RESTORE_ROUND_GENERIC (RM, libc_feholdsetround_sse, libc_feresetround_sse) >>> >>> So >>> >>>>> diff --git a/sysdeps/ieee754/ldbl-128/e_expl.c b/sysdeps/ieee754/ldbl-128/e_expl.c >>>>> index 37c1538c08..104ace1690 100644 >>>>> --- a/sysdeps/ieee754/ldbl-128/e_expl.c >>>>> +++ b/sysdeps/ieee754/ldbl-128/e_expl.c >>>>> @@ -66,6 +66,7 @@ >>>>>   #include >>>>>   #include >>>>>   #include >>>>> +#include >>>>>   #include >>>>>   #include >>>>>   #include "t_expl.h" >>>>> @@ -146,9 +147,10 @@ __ieee754_expl (_Float128 x) >>>>>         union ieee854_long_double ex2_u, scale_u; >>>>>         fenv_t oldenv; >>>>>   -      feholdexcept (&oldenv); >>>>>   #ifdef FE_TONEAREST >>>>> -      fesetround (FE_TONEAREST); >>>>> +      libc_feholdexcept_setroundl (&oldenv, FE_TONEAREST); >>> >>> Should be libc_feholdexcept_setroundf128. >> >> But it does not see to help here, so I don't know what is failing as well. > > Ok, so what is happening __sfp_handle_exceptions always use 387 exception > mode for FP_EX_OVERFLOW and FP_EX_UNDERFLOW: > > config/i386/sfp-exceptions.c > > 79 if (_fex & FP_EX_OVERFLOW) > 80 { > 81 struct fenv temp; > 82 asm volatile ("fnstenv\t%0" : "=m" (temp)); > 83 temp.__status_word |= FP_EX_OVERFLOW; > 84 asm volatile ("fldenv\t%0" : : "m" (temp)); > 85 asm volatile ("fwait"); > 86 } > 87 if (_fex & FP_EX_UNDERFLOW) > 88 { > 89 struct fenv temp; > 90 asm volatile ("fnstenv\t%0" : "=m" (temp)); > 91 temp.__status_word |= FP_EX_UNDERFLOW; > 92 asm volatile ("fldenv\t%0" : : "m" (temp)); > 93 asm volatile ("fwait"); > 94 } > Yes this looks like the mentioned disassembly. > Different that FP_EX_INEXACT, for instance, where __SSE_MATH__ sets > whether SSE is used or not. > > So I think it is not safe to use the SSE variants for libc_*_testf128, > as for i387 we should use the default_* instead. > I've just switched to default_* in sysdeps/x86/fpu/fenv_private.h: -#ifdef __x86_64__ +#if 0 /* The SSE rounding mode is used by soft-fp (libgcc and glibc) on x86_64, so that must be set for float128 computations. */ # define SET_RESTORE_ROUNDF128(RM) \ But now there are 7 testfails. For some of them, the max.ulp goes up (over 10), but there are even worse cases. Here are shortened excerpts of the out files: - math/test-float128-clog.out: Failure: Test: Real part of: clog_towardzero (0x2.82b795e420b281a934c6dd315cb2p-4 + 0xf.cd42a15bf9a361243a89663e81e8p-4 i) ulp : 162259276829213363391578010288127.0000 max.ulp : 3.0000 Failure: Test: Real part of: clog_upward (0x2.82b795e420b281a934c6dd315cb2p-4 + 0xf.cd42a15bf9a361243a89663e81e8p-4 i) ulp : 162259276829213363391578010288128.0000 max.ulp : 4.0000 - math/test-float128-clog10.out: Failure: Test: Real part of: clog10_downward (0x3.bea2bd62e35p-4 + 0xf.8e3d619a8d11bfd30b038eep-4 i) ulp : 4.0000 max.ulp : 3.0000 Failure: Test: Real part of: clog10_towardzero (0x2.82b795e420b281a934c6dd315cb2p-4 + 0xf.cd42a15bf9a361243a89663e81e8p-4 i) ulp : 140936617129079063283494433422698.0000 max.ulp : 4.0000 Failure: Test: Real part of: clog10_upward (0x2.82b795e420b281a934c6dd315cb2p-4 + 0xf.cd42a15bf9a361243a89663e81e8p-4 i) ulp : 140936617129079063283494433422698.0000 max.ulp : 4.0000 - math/test-float128-jn.out - math/test-float128-lgamma.out - math/test-float128-tgamma.out: something like: ulp : 12.0000 max.ulp : 4.0000 Failure: tgamma_upward (-0x6.ec00000000000008p+8): errno set to 0, expected 34 (ERANGE) - math/test-float128-y1.out: Failure: Test: y1_downward (0x2p+0) ulp : 13.0000 max.ulp : 4.0000 Failure: Test: y1_towardzero (0x2p+0) ulp : 6.0000 max.ulp : 2.0000 Failure: Test: y1_upward (0x2p+0) ulp : 10.0000 max.ulp : 5.0000 - math/test-float128-yn.out