public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5572] tree-optimization/103458 - avoid creating new loops in CD-DCE Date: Mon, 29 Nov 2021 09:12:19 +0000 (GMT) [thread overview] Message-ID: <20211129091219.451FB3885C1E@sourceware.org> (raw) https://gcc.gnu.org/g:85e91ad55a69282c1b0e34569836a026a1a954d1 commit r12-5572-g85e91ad55a69282c1b0e34569836a026a1a954d1 Author: Richard Biener <rguenther@suse.de> Date: Mon Nov 29 09:15:47 2021 +0100 tree-optimization/103458 - avoid creating new loops in CD-DCE When creating forwarders in CD-DCE we have to avoid creating loops where we formerly did not consider those because of abnormal predecessors. At this point simply excuse us when there are any abnormal predecessors. 2021-11-29 Richard Biener <rguenther@suse.de> PR tree-optimization/103458 * tree-ssa-dce.c (make_forwarders_with_degenerate_phis): Do not create forwarders for blocks with abnormal predecessors. * gcc.dg/torture/pr103458.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/torture/pr103458.c | 21 +++++++++++++++++++++ gcc/tree-ssa-dce.c | 8 ++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr103458.c b/gcc/testsuite/gcc.dg/torture/pr103458.c new file mode 100644 index 00000000000..3fd3b5fd2ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr103458.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-div-by-zero" } */ + +__attribute__ ((returns_twice)) int +bar (void); + +void +foo (int *p, int x) +{ + *p = 0; + while (*p < 1) + { + x = 0; + while (x < 1) + bar (); + + x /= 0; + } + + foo (p, x); +} diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index e3e6f0955b7..1f817b95fab 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1650,8 +1650,12 @@ make_forwarders_with_degenerate_phis (function *fn) /* Only PHIs with three or more arguments have opportunities. */ if (EDGE_COUNT (bb->preds) < 3) continue; - /* Do not touch loop headers. */ - if (bb->loop_father->header == bb) + /* Do not touch loop headers or blocks with abnormal predecessors. + ??? This is to avoid creating valid loops here, see PR103458. + We might want to improve things to either explicitely add those + loops or at least consider blocks with no backedges. */ + if (bb->loop_father->header == bb + || bb_has_abnormal_pred (bb)) continue; /* Take one PHI node as template to look for identical
reply other threads:[~2021-11-29 9:12 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211129091219.451FB3885C1E@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).