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 r11-3726] tree-optimization/97330 - fix bad load sinking Date: Thu, 8 Oct 2020 12:22:35 +0000 (GMT) [thread overview] Message-ID: <20201008122235.F3776388187F@sourceware.org> (raw) https://gcc.gnu.org/g:629e0547af33221a925f38757b52a9284148b68a commit r11-3726-g629e0547af33221a925f38757b52a9284148b68a Author: Richard Biener <rguenther@suse.de> Date: Thu Oct 8 13:18:57 2020 +0200 tree-optimization/97330 - fix bad load sinking This fixes bad placement of sunk loads. 2020-10-08 Richard Biener <rguenther@suse.de> PR tree-optimization/97330 * tree-ssa-sink.c (statement_sink_location): Avoid skipping PHIs when they dominate the insert location. * gcc.dg/torture/pr97330-1.c: New testcase. * gcc.dg/torture/pr97330-2.c: Likewise. Diff: --- gcc/testsuite/gcc.dg/torture/pr97330-1.c | 19 +++++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr97330-2.c | 14 ++++++++++++++ gcc/tree-ssa-sink.c | 4 +++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr97330-1.c b/gcc/testsuite/gcc.dg/torture/pr97330-1.c new file mode 100644 index 00000000000..7dce5bd90d4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr97330-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +typedef int a; +typedef char b; +int c; +void d(e, f, dst, g, avail, h) int e; +b *f, *dst; +a g, avail; +int h; +{ + b i = *f; + if (e) + goto j; + while (avail) { + *dst = i; + j: + avail -= c; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr97330-2.c b/gcc/testsuite/gcc.dg/torture/pr97330-2.c new file mode 100644 index 00000000000..a0644831cfd --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr97330-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +int a, b, d; +char c, e; +void f(void) { + char g = c; + if (b) + goto h; + while (d) { + e = c; + h: + d -= a; + } +} diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c index ba8e5577e9c..207aae2818a 100644 --- a/gcc/tree-ssa-sink.c +++ b/gcc/tree-ssa-sink.c @@ -391,8 +391,10 @@ statement_sink_location (gimple *stmt, basic_block frombb, if (gimple_code (use_stmt) == GIMPLE_PHI) { /* In case the PHI node post-dominates the current insert location - we can disregard it. */ + we can disregard it. But make sure it is not dominating + it as well as can happen in a CFG cycle. */ if (commondom != bb + && !dominated_by_p (CDI_DOMINATORS, commondom, bb) && dominated_by_p (CDI_POST_DOMINATORS, commondom, bb)) continue; bb = EDGE_PRED (bb, PHI_ARG_INDEX_FROM_USE (use_p))->src;
reply other threads:[~2020-10-08 12:22 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=20201008122235.F3776388187F@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).