From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2D9D23858D39; Thu, 27 Jul 2023 17:53:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D9D23858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690480418; bh=FwjWdhICFfAB/kyPAu/pN5SXWad/oNdkGTohmQyPuu0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OCA/qrVct799bDSm+0GOL7oKsAlfvebyOgqkwoazoSKWog5r1nOcx6fW/yYasr0BJ FJkeidcyj7fyAQQfgfrYeE9mWmdqhc2GnaqJ61+DSvHsQagYKtOdDy4uS14NTZEMZ6 19y0Xe98wKEKl23rvk3KlRuH+5/pUy4UZrI9oOTw= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110755] [13 Regression] Wrong optimization of fabs on ppc64el at -O1 Date: Thu, 27 Jul 2023 17:53:36 +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.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 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=3D110755 --- Comment #14 from CVS Commits --- The releases/gcc-13 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:e684084a5fa9edaedb1a14e118b966a60e3449b9 commit r13-7615-ge684084a5fa9edaedb1a14e118b966a60e3449b9 Author: Jakub Jelinek Date: Wed Jul 26 10:50:50 2023 +0200 range-op-float: Fix up -frounding-math frange_arithmetic +- handling [PR110755] IEEE754 says that x + (-x) and x - x result in +0 in all rounding modes but rounding towards negative infinity, in which case the result is -0 for all finite x. x + x and x - (-x) if it is zero retain sign of x. Now, range_arithmetic implements the normal rounds to even rounding, and as the addition or subtraction in those cases is exact, we don't do= any further rounding etc. and e.g. on the testcase below distilled from gli= bc compute a range [+0, +INF], which is fine for -fno-rounding-math or if we'd have a guarantee that those statements aren't executed with rounding towards negative infinity. I believe it is only +- which has this problematic behavior and I think it is best to deal with it in frange_arithmetic; if we know -frounding-= math is on, it is x + (-x) or x - x and we are asked to round to negative infinity (i.e. want low bound rather than high bound), change +0 result= to -0. 2023-07-26 Jakub Jelinek PR tree-optimization/110755 * range-op-float.cc (frange_arithmetic): Change +0 result to -0 for PLUS_EXPR or MINUS_EXPR if -frounding-math, inf is negative= and it is exact op1 + (-op1) or op1 - op1. * gcc.dg/pr110755.c: New test. (cherry picked from commit 21da32d995c8b574c929ec420cd3b0fcfe6fa4fe)=