From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BCFC93858C53; Thu, 20 Jul 2023 20:18:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCFC93858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689884332; bh=LFkGrFboEwdxwBhqxhZxZUBgCQ9PUsFpmg5vi+iAeuM=; h=From:To:Subject:Date:From; b=JGUTuqcGruKeh4cxLoblS/R6UHgyOE1ogQAdm1VYw2XMBP2Jz+1jWgCUUu6jjj9Cn 6ZwFGYuDl7j75Ls09oEA22ni/wXPyVjzbMwM30JQBIRJM1PtFNHXKPvM3hDrPfGikW hizBx+z34ihSwgzGYjqWqWFHhi3f4miHnhcaph1I= From: "aurelien at aurel32 dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/110755] New: Wrong optimization of fabs on ppc64el at -O1 Date: Thu, 20 Jul 2023 20:18:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aurelien at aurel32 dot net X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D110755 Bug ID: 110755 Summary: Wrong optimization of fabs on ppc64el at -O1 Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: aurelien at aurel32 dot net Target Milestone: --- The following code, extracted and simplified from the PowerPC implementatio= n of nearbyintf() in the GNU libc is wrongly optimized at -O1 and -O2 on ppc64el with GCC 13. The fabs is removed, while it is not the case with GCC 12 #include #include #include static float my_nearbyintf (float x) {=20 float r =3D x; if (x > 0.0) {=20 r +=3D 0x1p+23; r -=3D 0x1p+23; r =3D fabs (r); } return r; } int main() { volatile float in =3D 0.5f; fesetround (FE_DOWNWARD); printf("mynearbyintf(in) =3D %lf\n", my_nearbyintf(in)); } This causes the result to have the wrong sign.=