From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7745B3858C60; Thu, 9 Feb 2023 17:13:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7745B3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675962818; bh=FiLxJLpByD7NT5jem/sSSn+KqEAePRtdlCDlDI69n8o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BtzgwrDeD7A35+Hlz/CV10KeQQ9Fglrr7KJEsYYlG59t1Wfoe26KteIicHN8pi0qU xOjcJX1jsT1UOspK1PlrYAJ4cdHnfXqkRdKM/9F/VTqWz9P0tdA0tfr2XBlY/6bDOt mA3lbkRQ+iKyMC7kKMr0CmPKafr1L1x0YAnpHbu4= From: "matz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108742] Incorrect constant folding with (or exposed by) -fexcess-precision=standard Date: Thu, 09 Feb 2023 17:13:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: matz at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108742 --- Comment #10 from Michael Matz --- (In reply to Jakub Jelinek from comment #9) > (In reply to Michael Matz from comment #7) > > (In reply to Jakub Jelinek from comment #5) > > > https://eel.is/c++draft/cfloat.syn points to the C standard for > > > FLT_EVAL_METHOD > > > (plus https://eel.is/c++draft/expr#pre-6 talks about excess precision= too) > > > and e.g. C17 > > > 5.2.4.2.2/9): > > > "2 evaluate all operations and constants to the range and precision o= f the > > > long double type." > > >=20 > > > Note the " and constants" above. > >=20 > > Yes. But that leaves unspecified exactly to what bit pattern the string > > "4.2" should be converted to. >=20 > It should be converted to the closest long double, which is > 0x8.6666666666668p-1, > otherwise the constants wouldn't be evaluated to the range and precision = of > the long double type, only to double type then extended to long double. Yes. > In that case there > would be no point to mention the " and constants" above, only operations > would have excess precision, so double d; ... d =3D d + 4.2; would be d = =3D > (double) ((long double) d + (long double) (double) 4.2), while it actuall > should be d =3D (double) ((long double) d + 4.2L); As is clear by now, I disagree on that. FLT_EVAL_METHOD is for dealing with excess presicion hardware in a predictable way. x87 loads double constants into the 80bit regs trivially (with the value I want "(long double)4.2" to have, not 4.2L), so that's what the frontend should do. I think an argument that involves that the standard otherwise "would have no point mentioning" somet= hing is slippery at best. > Sure, see the typeof above, 4.2 with FLT_EVAL_METHOD =3D=3D 2 has typeof = double, > but value of 4.2L. I think we'll have to agree to disagree here and let Joseph have the say :-= )=