From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 104153858C2C; Fri, 2 Feb 2024 08:31:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 104153858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706862661; bh=Rw314TfUV13/1AuxvIBoW/q3zvUjs29zoj8Sw7HCNaU=; h=From:To:Subject:Date:From; b=C441AsS8ieiQg08Y0ryN2GMw94cPaOpj2afg/XfojSg6ci7L3fsVHECru4qZOs57h p3QWeHIiWqsCiFeycCn13zZPWr2MbQmyZWKbjHfrI/HfhrbKJWF4/oFGcPADGxxXUX 9Wq6T3Z69WsuuTkGEeQd2lxQaoPcC5NiZVuVzI+g= From: "652023330028 at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113714] New: [11/12/13/14 Regression] Missed optimization for redundancy computation elimination: -(w+d-x)-x => -(w+d) Date: Fri, 02 Feb 2024 08:31:00 +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=3D113714 Bug ID: 113714 Summary: [11/12/13/14 Regression] Missed optimization for redundancy computation elimination: -(w+d-x)-x =3D> -(w+d) 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 x can be eliminated from the calculation of z in the following code: c-x =3D> -(w+d-x)-x =3D> -(w+d) https://godbolt.org/z/MYhGTc4Pv int x,y,z,w; void func(int a, int b, int c, int d){ x=3Da/b - y; c=3D-(w+d-x); z=3Dc-x; } But GCC -O3 -fwrapv: _1 =3D a_7(D) / b_8(D); y.0_2 =3D y; _3 =3D _1 - y.0_2; x =3D _3; #Here is the part related to the calculation of z: w.2_4 =3D w; _20 =3D y.0_2 - w.2_4; _21 =3D _20 - d_11(D); _22 =3D _3 + _21; _6 =3D _22 - _1; z =3D _6; return; Expected code: GCC-10.5 -O3 -fwrapv _1 =3D a_7(D) / b_8(D); y.0_2 =3D y; _3 =3D _1 - y.0_2; x =3D _3; #Here is the part related to the calculation of z: w.2_4 =3D w; _5 =3D w.2_4 + d_11(D); _6 =3D -_5; z =3D _6; return; Thank you very much for your time and effort! We look forward to hearing fr= om you.=