From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A7FC83858D20; Thu, 28 Mar 2024 07:24:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7FC83858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711610665; bh=eDASjg38h09rLUWyqqfObE2ak0QdbMnSCIq6/6YZ7zo=; h=From:To:Subject:Date:From; b=IdCFReIllPkUS18Rtsxtog6+Ab/agcarZRFmEmiZcazf89JyKJg1mlCJUiMoIz3R4 4n0KbF+NCmzAXFUX1PrHU1dZwUWPNRd6XCWql8pRZ9sxgQYo2pFAhXEYWPoQ822ljF ibavBSiPH1Cfq0nAjq12JTbTtPpztYTFXtJpWQEs= From: "652023330028 at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114511] New: [Regression] Missed optimization: x = -y; x = c + x + y; ==> x=c; Date: Thu, 28 Mar 2024 07:24:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: 652023330028 at smail dot nju.edu.cn 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=3D114511 Bug ID: 114511 Summary: [Regression] Missed optimization: x =3D -y; x =3D c + x= + y; =3D=3D> x=3Dc; Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: 652023330028 at smail dot nju.edu.cn Target Milestone: --- Hello, we noticed that y can be eliminated from the calculation of x in the following code. (x =3D c) https://godbolt.org/z/716814Eh5 int x, y; void func(int a, int b, int c, int d){ y =3D d / a + (-b + a); x =3D -y; x =3D c + x + y; } But GCC -O3 -fwrapv: [local count: 1073741824]: # DEBUG BEGIN_STMT _1 =3D d_7(D) / a_8(D); _2 =3D a_8(D) - b_9(D); _3 =3D _1 + _2; y =3D _3; # DEBUG BEGIN_STMT _18 =3D b_9(D) + c_12(D); _19 =3D _18 - a_8(D); # DEBUG BEGIN_STMT _20 =3D _3 + _19; _6 =3D _20 - _1; x =3D _6; return; Expected code: GCC-7.5 -O3 -fwrapv [100.00%]: _1 =3D d_7(D) / a_8(D); _2 =3D a_8(D) - b_9(D); _3 =3D _1 + _2; y =3D _3; x =3D c_12(D); return; Thank you very much for your time and effort! We look forward to hearing fr= om you.=