From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DB04B38A8038; Tue, 11 Jan 2022 10:16:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB04B38A8038 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/100221] Takes two passes at DSE to remove some dead stores Date: Tue, 11 Jan 2022 10:16:47 +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: enhancement X-Bugzilla-Who: rguenth 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: version 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, 11 Jan 2022 10:16:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100221 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unknown |12.0 --- Comment #4 from Richard Biener --- For the reduced testcase the issue is simply that DSE doesn't walk across multiple paths and we have : # .MEM_9 =3D VDEF g =3D &c; a.1_2 =3D a; if (a.1_2 !=3D 0) goto ; [INV] else goto ; [INV] : b =3D 0; : .MEM_5 =3D PHI <.MEM_9(4), .MEM_12(5)> b.2_3 =3D b; if (b.2_3 !=3D 0) goto ; [INV] else goto ; [INV] : .MEM_6 =3D PHI <.MEM_9(4), .MEM_5(6)> g =3D{v} {CLOBBER}; return 0; with the walking gathered the .MEM_5 and .MEM_6 defs when following the .MEM_9 uses and /* In addition to kills we can remove defs whose only use is another def in defs. That can only ever be PHIs of which we track two for simplicity reasons, the first and last in {first,last}_phi_def (we fail for multiple PHIs anyways). We can also ignore defs that feed only into already visited PHIs. */ else if (single_imm_use (vdef, &use_p, &use_stmt) && (use_stmt =3D=3D first_phi_def || use_stmt =3D=3D last_phi_def || (gimple_code (use_stmt) =3D=3D GIMPLE_PHI && bitmap_bit_p (visited, SSA_NAME_VERSION (PHI_RESULT (use_stmt)))))) defs.unordered_remove (i); does not trigger to remove either PHI def from consideration (but in principle we could elide .MEM_6 and continue processing .MEM_5 which eventually will lead us to .MEM_6 anyway). I suppose the key would be realizing that one of the PHI defs is a PHI argument of the PHI we can postpone in this round.=