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 r10-10099] tree-optimization/101394 - fix PRE full redundancy wrt abnormals Date: Mon, 6 Sep 2021 10:18:42 +0000 (GMT) [thread overview] Message-ID: <20210906101842.603D13838002@sourceware.org> (raw) https://gcc.gnu.org/g:424737442fb7cd6ea8f0e63098c26cebdaf82a51 commit r10-10099-g424737442fb7cd6ea8f0e63098c26cebdaf82a51 Author: Richard Biener <rguenther@suse.de> Date: Mon Jul 12 10:49:03 2021 +0200 tree-optimization/101394 - fix PRE full redundancy wrt abnormals This avoids adding a copy from an abnormal picked up from PHI translation much like we'd avoid inserting the translated expression on pred edges. 2021-07-12 Richard Biener <rguenther@suse.de> PR tree-optimization/101394 * tree-ssa-pre.c (do_pre_regular_insertion): Avoid inserting copies from abnormals for a full redundancy. * gcc.dg/torture/pr101394.c: New testcase. (cherry picked from commit 92343e0ba4d47f21ae20ffcb83d736bdbc15dae0) Diff: --- gcc/testsuite/gcc.dg/torture/pr101394.c | 18 ++++++++++++++++++ gcc/tree-ssa-pre.c | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr101394.c b/gcc/testsuite/gcc.dg/torture/pr101394.c new file mode 100644 index 00000000000..87fbdadc152 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr101394.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +int a, b, c, d; +void h(); +int e() __attribute__((returns_twice)); +void f() { + int *g = (int *)(__INTPTR_TYPE__)c; + if (b) { + h(); + g--; + if (a) + if (d) + h(); + } + if (g++) + e(); + c = (__INTPTR_TYPE__)g; +} diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 82fc364b036..b406eadf080 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3312,7 +3312,11 @@ do_pre_regular_insertion (basic_block block, basic_block dom) /* If all edges produce the same value and that value is an invariant, then the PHI has the same value on all edges. Note this. */ - else if (!cant_insert && all_same) + else if (!cant_insert + && all_same + && (edoubleprime->kind != NAME + || !SSA_NAME_OCCURS_IN_ABNORMAL_PHI + (PRE_EXPR_NAME (edoubleprime)))) { gcc_assert (edoubleprime->kind == CONSTANT || edoubleprime->kind == NAME);
reply other threads:[~2021-09-06 10:18 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=20210906101842.603D13838002@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).