From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C269938582B0; Fri, 27 Jan 2023 10:02:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C269938582B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674813777; bh=YgOQFVzXTjvygyWums+AMj4JR9YGWJP+HDqfze+86bM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XLkMiNWoBN/iIHEN9uwLQj+Hjz73VZibXj3LIw+SvPTvliIcRCtm8cqSq0A9dX5D3 0NZk//807zBoRqVqyd10v4y95r/fwyGO4C3Z5i6psm7oZHdmznIGbaHwmMKGcRQcim 2gnlXF5jfwWRcHJu5yr0XwHLFbJ54L66ocPpSMak= From: "xry111 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107608] [13 Regression] Failure on fold-overflow-1.c and pr95115.c Date: Fri, 27 Jan 2023 10:02:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: xry111 at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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=3D107608 --- Comment #48 from Xi Ruoyao --- (In reply to rguenther@suse.de from comment #47) > On Fri, 27 Jan 2023, xry111 at gcc dot gnu.org wrote: >=20 > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107608 > >=20 > > --- Comment #46 from Xi Ruoyao --- > > (In reply to Richard Biener from comment #45) > > > (In reply to Xi Ruoyao from comment #44) > > > > (In reply to rguenther@suse.de from comment #43) > >=20 > > > > > If the result is unused then no, GCC will happily elide exception= s from > > > > > unused computations like Inexact from the statement > > > > >=20 > > > > > 1./3.; > > > > >=20 > > > > > but this has been done before. What's new is that GCC can now el= ide > > > > > some uses (in this case the isnan check is the only use) > > > >=20 > > > > The should we just change PR95115 to "INVALID" and remove the test = case, and > > > > fix any regression on Glibc side? > > >=20 > > > I think we should adjust the testcase with a volatile like I suggeste= d above > > > so we verify that we don't eliminate the computation with a "constant= " NaN. > >=20 > > Ok, I'll post a patch. > >=20 > > Glibc already changed the code from Inf/Inf to (x - x) / (x - x) where = x=20 > > is not a constant, but I'm wandering if the compiler will attempt to=20 > > optimize out (x - x) / (x - x) later... Is it possible to provide a=20 > > "__builtin_feraiseexcept" so we'd be able to use it instead of the nast= y=20 > > (x - x) / (x - x) to raise the exception? >=20 > Not trivially. I'd suggest glibc uses a volatile use, like for example >=20 > tem =3D Inf/Inf; > __asm__ volatile ("" : : "g" (tem)); >=20 > or so to preserve the computation and avoid an actual store to a volatile > variable. Though I see at least GCC 7 optimizing the above division > to a constant, lacking a fix we deployed later. Currently Glibc returns the produced NaN (and there will be no IPA involved= as the TU only contains one function, and AFAIK Glibc just does not support building with LTO). Is it enough to preserve the computation?=