public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102880] [12 Regression] Dead Code Elimination Regression at -O3
Date: Thu, 11 Nov 2021 12:42:15 +0000	[thread overview]
Message-ID: <bug-102880-4-h4CSjLi7ch@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102880-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102880

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So interestingly as a band-aid fix I bootstrapped and tested

diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index a016ee47a02..c2a0555dd78 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -351,6 +351,7 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
       /* If PHI_WANTED is false, BB must not have any PHI nodes.
         Otherwise, BB must have PHI nodes.  */
       || gimple_seq_empty_p (phi_nodes (bb)) == phi_wanted
+      || single_pred_p (bb) == phi_wanted
       /* BB may not be a predecessor of the exit block.  */
       || single_succ (bb) == EXIT_BLOCK_PTR_FOR_FN (cfun)
       /* Nor should this be an infinite loop.  */

which makes the forwarder block removal of CFG cleanup only remove forwarders
with a single predecessor (formerly it handled multiple predecessors if they
did not have PHIs).

There's no testsuite fallout from this patch but the testcase is fixed.

IMHO we should handle degenerate PHIs with a single predecessor here
and yank the PHI node restriction if we go with this.

It will still not catch all CD-DCE opportunities since that's of course not
a reliable way to have common arguments factored.  We talked a bit about
recovering the control dependence info of a virtuall inserted forwarder
but if possible it isn't anything trivial so I'd tend to go with explicit
factoring before running CD-DCE.

  parent reply	other threads:[~2021-11-11 12:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 13:27 [Bug tree-optimization/102880] New: " theodort at inf dot ethz.ch
2021-10-21 13:46 ` [Bug tree-optimization/102880] " marxin at gcc dot gnu.org
2021-10-22  6:56 ` pinskia at gcc dot gnu.org
2021-10-22  6:57 ` rguenth at gcc dot gnu.org
2021-10-22  8:44 ` rguenth at gcc dot gnu.org
2021-10-29  9:09 ` rguenth at gcc dot gnu.org
2021-11-11 12:42 ` rguenth at gcc dot gnu.org [this message]
2021-11-16 10:31 ` cvs-commit at gcc dot gnu.org
2021-11-16 10:32 ` cvs-commit at gcc dot gnu.org
2021-11-16 10:33 ` rguenth at gcc dot gnu.org
2021-11-17  8:41 ` clyon at gcc dot gnu.org
2021-11-17  8:47 ` pinskia at gcc dot gnu.org
2021-11-18  8:56 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102880-4-h4CSjLi7ch@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).