From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DC1D83857023; Mon, 29 Mar 2021 07:35:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC1D83857023 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99793] missed optimization for dead code elimination at -Os, -O2 and -O3 (vs. -O1) Date: Mon, 29 Mar 2021 07:35:56 +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: 11.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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed assigned_to bug_status version cf_reconfirmed_on keywords 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: Mon, 29 Mar 2021 07:35:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99793 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org Status|UNCONFIRMED |ASSIGNED Version|unknown |11.0 Last reconfirmed| |2021-03-29 Keywords| |missed-optimization --- Comment #1 from Richard Biener --- So the difference is -fstrict-aliasing which causes us to not elide the redundant store to 'd' which in turn makes us fail to promote 'd' read-only: Value numbering stmt =3D d =3D d.2_2; -Store matched earlier value, value numbering store vdefs to matching vuses. -Setting value number of .MEM_9 to .MEM_8 (changed) -Deleted redundant store d =3D d.2_2; +No store match +Value numbering store d to d.2_2 +Setting value number of .MEM_9 to .MEM_9 (changed) and the issue is that we "optimize" part of the walking with recording last_vuse and using that vuse to insert the preceeding load into the hashtables but since the walking is different for redundant store detection (no TBAA), it cannot walk that far (beyond the non-TBAA aliasing store to *b) and thus it cannot find the hashtable entry of the d.2_2 =3D d load. The last-vuse trick is poor-mans "PRE" - I do rememb= er experimenting with inserting both last and original vuse exprs but I do not remember the outcome.=