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-8403] tree-optimization/105618 - restore load sinking Date: Thu, 19 May 2022 12:47:40 +0000 (GMT) [thread overview] Message-ID: <20220519124740.2A56A384BC2C@sourceware.org> (raw) https://gcc.gnu.org/g:374cee99d01fceb89d0929da8b38051e6c9768f0 commit r12-8403-g374cee99d01fceb89d0929da8b38051e6c9768f0 Author: Richard Biener <rguenther@suse.de> Date: Tue May 17 09:45:02 2022 +0200 tree-optimization/105618 - restore load sinking The PR97330 fix caused some missed sinking of loads out of loops the following patch re-instantiates. 2022-05-17 Richard Biener <rguenther@suse.de> PR tree-optimization/105618 * tree-ssa-sink.cc (statement_sink_location): For virtual PHI uses ignore those defining the used virtual operand. * gcc.dg/tree-ssa/ssa-sink-19.c: New testcase. (cherry picked from commit ebce0e9bd8d714a8607ae24331a3d842b0d11859) Diff: --- gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-19.c | 21 +++++++++++++++++++++ gcc/tree-ssa-sink.cc | 3 +++ 2 files changed, 24 insertions(+) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-19.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-19.c new file mode 100644 index 00000000000..e98d13fe85b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-19.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-sink1-details -fdump-tree-cddce2-details" } */ + +static int b=4; +int c; + +int +main() +{ + int e[5] = {1,1,1,1,1}; + for (; b >= 0; b--) { + c = e[b]; + } + return 0; +} + +/* We should sink e[b] out of the loop which is possible after + applying store motion to c and b. */ +/* { dg-final { scan-tree-dump "Sinking # VUSE" "sink1" } } */ +/* And remove the loop after final value replacement. */ +/* { dg-final { scan-tree-dump "fix_loop_structure: removing loop" "cddce2" } } */ diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc index 1c226406feb..8ce4403ddc8 100644 --- a/gcc/tree-ssa-sink.cc +++ b/gcc/tree-ssa-sink.cc @@ -390,6 +390,9 @@ statement_sink_location (gimple *stmt, basic_block frombb, with the use. */ if (gimple_code (use_stmt) == GIMPLE_PHI) { + /* If the PHI defines the virtual operand, ignore it. */ + if (gimple_phi_result (use_stmt) == gimple_vuse (stmt)) + continue; /* In case the PHI node post-dominates the current insert location we can disregard it. But make sure it is not dominating it as well as can happen in a CFG cycle. */
reply other threads:[~2022-05-19 12:47 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=20220519124740.2A56A384BC2C@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).