From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8B5B43857827; Wed, 7 Oct 2020 06:49:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B5B43857827 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/97307] Optimization for pure vs. const function Date: Wed, 07 Oct 2020 06:49:08 +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: 10.2.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal 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: bug_status component everconfirmed cc cf_reconfirmed_on 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: Wed, 07 Oct 2020 06:49:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97307 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Component|middle-end |tree-optimization Ever confirmed|0 |1 CC| |rguenth at gcc dot gnu.org Last reconfirmed| |2020-10-07 --- Comment #1 from Richard Biener --- It's because we hit /* If this is a load then do not sink past any stores. ??? This is overly simple but cheap. We basically look for an existing load with the same VUSE in the path to one of the sink candidate blocks and we adjust commondom to the nearest to commondom. */ if (gimple_vuse (stmt)) { ... imm_use_iterator imm_iter; use_operand_p use_p; basic_block found =3D NULL; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, gimple_vuse (stmt)) { gimple *use_stmt =3D USE_STMT (use_p); basic_block bb =3D gimple_bb (use_stmt); /* For PHI nodes the block we know sth about is the incoming block with the use. */ if (gimple_code (use_stmt) =3D=3D GIMPLE_PHI) bb =3D EDGE_PRED (bb, PHI_ARG_INDEX_FROM_USE (use_p))->src; /* Any dominator of commondom would be ok with adjusting commondom to that block. */ bb =3D nearest_common_dominator (CDI_DOMINATORS, bb, commondo= m); if (!found) found =3D bb; where we do not ignore stmt itself (nor stmts in its same block). We also do not ignore the function return which directs us to BB2 as well. The heuristic looks quite misguided to me ...=