From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B2B4B385803D; Tue, 23 Nov 2021 11:36:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2B4B385803D From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103359] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) Date: Tue, 23 Nov 2021 11:36:37 +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: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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 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 Nov 2021 11:36:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103359 --- Comment #6 from Richard Biener --- Which means the CCP difference is that we're failing to propagate out copies when they have a useful value: Visiting statement: _25 =3D _24; which is likely CONSTANT Lattice value changed to CONSTANT 0x0 (0xf). Adding SSA edges to worklist. ssa_edge_worklist: adding SSA use in _7 =3D _25; Simulating statement: _7 =3D _25; Visiting statement: _7 =3D _25; which is likely CONSTANT Lattice value changed to CONSTANT 0x0 (0xf). Adding SSA edges to worklist. that's because the copy and constant lattice are unified and we cannot track both. And while forwprop will propagate out copies since it does that when it visits uses it confuses itself with this. Propagating them out immediately fixes this but the obvious use of replace_uses_by causes excessive folding and redundant work as well as out-of-order debug stmt handling. The following would fix the testcase. Note there's still the appearant EVRP regression compared to GCC 11. The single_use test was added with g:2fde61e3caf4c4660743e53497f52b65da1fe760 as a fix for PR66916. diff --git a/gcc/match.pd b/gcc/match.pd index f059b477f58..b32cc4a9368 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -5221,8 +5221,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && ((POINTER_TYPE_P (TREE_TYPE (@00)) && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@00)))) || (POINTER_TYPE_P (TREE_TYPE (@10)) - && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@10))))= )) - && single_use (@0)) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@10))))= ))) (if (TYPE_PRECISION (TREE_TYPE (@00)) =3D=3D TYPE_PRECISION (TREE_TYPE = (@0)) && (TREE_CODE (@10) =3D=3D INTEGER_CST || @1 !=3D @10)=