From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7E12B385702F; Tue, 15 Aug 2023 09:23:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E12B385702F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692091431; bh=SGUFwEMIVCA5gd5Skw9g99ahYbaxPeaULHH5I0ih09E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=b2bJUXuMOgu5W7g3qpvItkmzZj0PfHkNWCV6KAhFcK501dx47zFDkcGFTLhMGPG6E YKotaVYaryiWKFWLQkiwLdhrCwJNuLpunksFDndEgNjEEHeQqP+q2m697CZA1xSUN5 miiVoipEMlOjDmhDnNUV/8qr/XAvYhKS/cqTOy5k= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110963] [14 Regression] Dead Code Elimination Regression since r14-2946-g46c8c225455 Date: Tue, 15 Aug 2023 09:23:48 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110963 --- Comment #8 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:4d6132e59327e809a4d4e39fb9465dbd43775b7c commit r14-3217-g4d6132e59327e809a4d4e39fb9465dbd43775b7c Author: Richard Biener Date: Thu Aug 10 13:55:36 2023 +0200 tree-optimization/110963 - more PRE when optimizing for size The following adjusts the heuristic when we perform PHI insertion during GIMPLE PRE from requiring at least one edge that is supposed to be optimized for speed to also doing insertion when the expression is available on all edges (but possibly with different value) and we'd at most have one copy from a constant. The first ensures we optimize two computations on all paths to one plus a possible copy due to the PHI, the second makes sure we do not need to insert many possibly large copies from constants, disregarding the cummulative size cost of the register copies when they are not coalesced. The case in the testcase is _14 =3D h; if (_14 =3D=3D 0B) goto ; else goto ; h =3D 0B; h.6_12 =3D h; and we want to optimize that to # h.6_12 =3D PHI <_14(5), 0B(6)> If we want to consider the cost of the register copies I think the only simplistic enough way would be to restrict the special-case to two incoming edges - we'd assume one register copy is coalesced leaving one copy from a register or from a constant. As with every optimization the downstream effects are probably bigger than what we can locally estimate. PR tree-optimization/110963 * tree-ssa-pre.cc (do_pre_regular_insertion): Also insert a PHI node when the expression is available on all edges and we insert at most one copy from a constant. * gcc.dg/tree-ssa/ssa-pre-34.c: New testcase.=