From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED3F73857829; Tue, 23 Mar 2021 20:56:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED3F73857829 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99739] New: [11 Regression] missing optimization of a repeated conditional Date: Tue, 23 Mar 2021 20:56:47 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org 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 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, 23 Mar 2021 20:56:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99739 Bug ID: 99739 Summary: [11 Regression] missing optimization of a repeated conditional Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Prior to r11-5805 both ff() and gg() in the test case below resulted in opt= imal code. With the change, the second conditional in g() is no longer recogniz= ed as equivalent to the first and so the function isn't optimized as expected. Incidentally, the same regression was also introduced once before: in r2356= 53. $ cat x.c && gcc -O1 -S -Wall -fdump-tree-optimized=3D/dev/stdout x.c static inline int f (int i, int j, int k) { int x =3D 1; if (i && j && k) x =3D 2; if (i && j && k) return x; return -1; } void ff (int i, int j, int k) { int x =3D f (i, j, k); if (x =3D=3D 1) __builtin_abort (); } static inline int g (int i, int j, int k) { int x =3D 1; if (i && j && k) x =3D 2; if (i && k && j) return x; return -1; } void gg (int i, int j, int k) { int x =3D g (i, j, k); if (x =3D=3D 1) __builtin_abort (); } ;; Function ff (ff, funcdef_no=3D1, decl_uid=3D1951, cgraph_uid=3D2, symbol= _order=3D1) void ff (int i, int j, int k) { [local count: 1073741824]: return; } ;; Function gg (gg, funcdef_no=3D3, decl_uid=3D1963, cgraph_uid=3D4, symbol= _order=3D3) Removing basic block 6 Removing basic block 7 void gg (int i, int j, int k) { _Bool _7; _Bool _8; _Bool _11; _Bool _14; _Bool _16; [local count: 1073741824]: _7 =3D i_2(D) !=3D 0; _8 =3D j_3(D) !=3D 0; _14 =3D k_4(D) !=3D 0; _11 =3D _7 & _14; _16 =3D _8 & _11; if (_16 !=3D 0) goto ; [94.27%] else goto ; [5.73%] [local count: 1012175616]: if (k_4(D) !=3D 0) goto ; [100.00%] else goto ; [0.00%] [count: 0]: __builtin_abort (); [local count: 1073741824]: return; }=