From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A3DD9385C418; Tue, 16 Nov 2021 20:51:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3DD9385C418 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103281] [9/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) Date: Tue, 16 Nov 2021 20:51:29 +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: 12.0 X-Bugzilla-Keywords: missed-optimization 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: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: target_milestone keywords everconfirmed cf_known_to_fail short_desc cf_reconfirmed_on cf_known_to_work bug_status 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Nov 2021 20:51:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103281 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |12.0 Keywords| |missed-optimization Ever confirmed|0 |1 Known to fail| |10.1.0, 12.0, 4.7.1, 4.8.1, | |9.1.0 Summary|[12 Regression] Dead Code |[9/12 Regression] Dead Code |Elimination Regression at |Elimination Regression at |-O3 (trunk vs 11.2.0) |-O3 (trunk vs 11.2.0) Last reconfirmed| |2021-11-16 Known to work| |11.1.0, 4.9.0, 4.9.4, | |5.1.0, 6.1.0, 7.1.0, 8.1.0 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski --- The only thing which PHIOPT does is change: if (c_15 =3D=3D 0) goto ; [INV] else goto ; [INV] : : # iftmp.1_10 =3D PHI <0(4), c_15(3)> to be: iftmp.1_10 =3D c_15; This is a missed VRP: # RANGE [0, 2] NONZERO 3 c_9 =3D (charD.10) b.4_5; _1 =3D c_9 <=3D 0; # RANGE [0, 1] NONZERO 1 _2 =3D (unsigned intD.14) _1; if (_2 =3D=3D b.4_5) _1/_2 is true/1 only when c_9 is 0 and only when b.4_5 is 0. ----- CUT ----- We should be able to optimize: void foo(void); static unsigned b; int main() { for (; b < 3; b++) { char c =3D b; char a =3D c; if (!((a < 1) ^ b)) foo(); } } Too. We also miss: void foo(void); static unsigned b; int main() { for (; b < 3; b++) { if (!((b < 1) ^ b)) foo(); } } _1 =3D b.2_6 =3D=3D 0; _2 =3D (unsigned int) _1; if (_2 =3D=3D b.2_6) I want to say we should defer this until after GCC 12 because this was only being optimized on accident. phiopt1=