From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3D87B3858D28; Thu, 28 Mar 2024 17:18:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D87B3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711646304; bh=X9p9YJcl2FilQRbkdMcimPE9QHW3bwi+2hqe2tXhC24=; h=From:To:Subject:Date:In-Reply-To:References:From; b=k2SlEl6RAc5c75ceE5R/q4tKbXQOOZWPnqQxGrWH+KvUr3NOL11I8EkGdNMc87lf5 zO9TbiY+ep7gLcHdatdPjR+vRyZqUFgJAdNx9kVWpXSYVPbedIR+q7jxe/u49XuHWg I2Kklk2OKbsqEYNQaMeWOAQOeDCDZ3UVEN/D/4c8= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112723] [11/12/13/14 Regression] Missed optimization for invariants 'c+c' when c += -2147483647-1 and c is a global variable Date: Thu, 28 Mar 2024 17:18:23 +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: 14.0 X-Bugzilla-Keywords: missed-optimization, TREE X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: 11.5 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=3D112723 --- Comment #4 from Andrew Pinski --- gimple-ssa-strength-reduction definitely should be improved to handle this = case where it should understand that (a+CSTWITHLASTBITSET)*2 can be done as a*2+NEWCST if the type can wrap. Only can do that if wrapping rather than if overflow is undefined. For a non-signed case which should be handled: ``` unsigned a, b, c; void test() { a =3D c + c; c +=3D -2147483648u; b =3D c + c; } ``` Maybe I will look at this for GCC 15. It might improve other code ...=