From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id C2F8E3856945; Fri, 14 Apr 2023 19:49:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2F8E3856945 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1681501764; i=anlauf@gmx.de; bh=0JRovpn6J74pfVpn+M9ydOG6c9ZNxjg0Uknn7iYhHLw=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=fr1q/lQnzYzatkNCM3/ppKUwvpj3E14GDL0TKjIb3peLQvnwxqFXzdvOfTj60mCWP DvrqxDr1pylZyWZJ/Do8BT5GnL1hcDbPT2ebEcBoH9ZqRlfkgoZRvKFsU5fiCNhsKD Thvc+oYobn90GYOYZa/77NoJ3snmFKS6MCBOPrCcacs9BNRmN9xLS7fAsBxELqOU9U 0p/r5ujmL/wYsG5tbhC+3OZqOPGtMh+3qyu70j/Xzsm5yaipwtdExpfiAPnNKnjq+M 6RUZpGmkgUDf1+FMVSZNhg80IQFuHuAP93LrSvrG3ARHo4Btj3p7XZQm90s2OUFwID lvcYBa/n8dFZQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([79.251.14.165]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MWRVb-1ppvSR0rRT-00XrEv; Fri, 14 Apr 2023 21:49:24 +0200 Message-ID: Date: Fri, 14 Apr 2023 21:49:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] Fortran: fix compile-time simplification of SET_EXPONENT [PR109511] To: sgk@troutmask.apl.washington.edu, Harald Anlauf via Fortran Cc: gcc-patches Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: Content-Language: en-US From: Harald Anlauf In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:7GR++4oKpDcxYtotft2YiZ9TLma9rqB0aCRsnsFf6ZuoqfkV2TQ Dw/PYqGi799h89QYVRPbFfJ6v/oef0psxvq5isvECte2bteOcaTbJ7wauO0aZcIqeRzDy93 X8F+fQdCOqguzjv6UKlweL678YOo+zOX6r1d3emeNJ5yoLQTForqgRBEI7OAPlh151uPrz4 /N0qcRz/U57OGv7PfO7Cg== UI-OutboundReport: notjunk:1;M01:P0:m4GZiKexwx0=;6iRL2JZaWzIrZlxJ3RioGDo8O9T 6ki+fBeGAHxRH3TacwIOuRSRK9guBl4Wp3gu70Zd027PVGOk3WOl5N7HabxvjbbMvtulPLQCR RBFBEtYNBwHG1IzxXSOPDm/92Or1cLpG3F9l84MfPi6u62TCM5Okc895GXuXNYCeG1RLIgaQM xc0XcxMAzTxQIV4OQxXRb00ZYGVxGbUi+3Db0lBGsTqmptUADdRGJZ8Gm4rTk+BUtKQ+ycjqn StztRI3BxkMR9yyse+jBjmaiXnAIMnhmRY2Ai1GqYSoTSiQRC9KyHlbj5f/6MTlYMG6X7eO0T 7JpgL2nsBhRFQcm+wrzv2V3pbWctpaZBv2i6EBfj1pljyNHV2vZ+NZVFX+afQKM2ZVqv1/GPe 3lWGegEkq4TrvGUiqop38f75Vc6GjpVZ4LDF4dMnhfWfWvBmEsEN2/PmgnpeUFPkdLH0tMY4l bYUSPM1TpzE9cJrsmwPoJTMN/n5VwmEwRXtO9trFuVchZGzGs/O1f4UV6HxX7CAJX1Su7BDHs PVDjodEmYc0qUl5O3CBSqGUA8rW4zhzIPM5Mxpir3z4pqzmih1Iim6N1t60KJ97o1No6861aF YYUgY0EgDbWYDT6I2W0DYzcJZWj+lZ+5MKjEc2CcodAxErH8aDxPqGO4HuFQw4c0WSwP9hw0K WJaUX7fbdHrKUy5xhv2LYz7ZKtr9evw4gBWL6V86N8zmto9N8dxn1AaVowXSzcjzmN5QyJsPd P76/7XJRSZgo0NrgkYsbTdNLkBn87uBrrCa33Y09H3B62xiFSLOqp8hM8mW8fD5WGeWiiwO6t JWEcpi6xznKu2GadtI/53qfld3CWTUQe96uSR2vKiVyIdw7dDQh24qQZckvhd3+s6WJmKzO5D HOhBVZ2uI5GvEEmKHtR+PGOCWWskqCsODvLvhtzP9ZySCbncHjBb/U66jCSDxKBXZXwsw9RF+ O6Kfy1XMDcJfOKzn58u5Aa3Rri8= X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Steve, On 4/14/23 21:33, Steve Kargl via Gcc-patches wrote: > On Fri, Apr 14, 2023 at 08:59:24PM +0200, Harald Anlauf via Fortran wrot= e: >> >> the compile-time simplification of intrinsic SET_EXPONENT was >> broken since the early days of gfortran for argument X < 1 >> (including negative X) and for I < 0. I identified and fixed >> several issues in the implementation. The testcase explores >> argument space comparing compile-time and runtime results and >> is checked against Intel. >> >> Regtested on x86_64-pc-linux-gnu. OK for mainline? >> > > Yes, it is certainly better than the current situation. > >> This is not a regression, but can lead to wrong code. >> Would it be OK to backport to open branches? > > Sure. Looks simply and fairly specific. OK, thanks, will proceed. > I was wondering about the difference between set_exponent() > and scale(), and found that set_exponent() talks about IEEE > values while scale() doesn't. I'm wondering if we should > add the IEEE special cases to the testsuite. Of particular > note, I doubt that this is true: > > If X is an IEEE NaN, the result is the same NaN. > > program foo > real x, y > x =3D 1 > y =3D x - x > x =3D (x - x) / y > print '(F4.0,1X,Z8.8)', x, x > y =3D set_exponent(x,1) > print '(F4.0,1X,Z8.8)', y, y > end program foo > > gfcx -o z a.f90 && ./z > NaN FFC00000 > NaN 7FC00000 > > Those are not the same NaN. The second is a qNaN. > The first looks like a qNaN with the sign bit set. Until now there was no testing at all of SET_EXPONENT in the testsuite. It would be really good to have better coverage of compile-time and runtime behavior of the intrinsics and checking consistency ... ;-) I think you have much more experience in that area. (Hint!) Cheers, Harald