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 r14-8524] tree-optimization/113659 - early exit vectorization and missing VUSE Date: Tue, 30 Jan 2024 10:59:37 +0000 (GMT) [thread overview] Message-ID: <20240130105937.E891C3857739@sourceware.org> (raw) https://gcc.gnu.org/g:4c2169d2f4061e72e1e61e9a175d16f7ff50f5c0 commit r14-8524-g4c2169d2f4061e72e1e61e9a175d16f7ff50f5c0 Author: Richard Biener <rguenther@suse.de> Date: Tue Jan 30 09:42:08 2024 +0100 tree-optimization/113659 - early exit vectorization and missing VUSE The following handles the case of the main exit going to a path without virtual use and handles it similar to the alternate exit handling. PR tree-optimization/113659 * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg): Handle main exit without virtual use. * gcc.dg/pr113659.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/pr113659.c | 14 ++++++++++++++ gcc/tree-vect-loop-manip.cc | 20 +++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/pr113659.c b/gcc/testsuite/gcc.dg/pr113659.c new file mode 100644 index 000000000000..dc1091b647d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr113659.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-sra" } */ +/* { dg-additional-options "-msse4.1" { target { x86_64-*-* i?86-*-* } } } */ + +struct Foo { + int *ptr; +}; +int Baz(struct Foo first) +{ + while (first.ptr) + if (*first.ptr++) + return 0; + __builtin_unreachable (); +} diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 873a28d7c560..3f974d6d839e 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -1708,9 +1708,23 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit, LC PHI node to feed the merge PHI. */ tree *res; if (virtual_operand_p (new_arg)) - /* Use the existing virtual LC SSA from exit block. */ - new_arg = gimple_phi_result - (get_virtual_phi (main_loop_exit_block)); + { + /* Use the existing virtual LC SSA from exit block. */ + gphi *vphi = get_virtual_phi (main_loop_exit_block); + /* ??? When the exit yields to a path without + any virtual use we can miss a LC PHI for the + live virtual operand. Simply choosing the + one live at the start of the loop header isn't + correct, but we should get here only with + early-exit vectorization which will move all + defs after the main exit, so leave a temporarily + wrong virtual operand in place. This happens + for gcc.dg/pr113659.c. */ + if (vphi) + new_arg = gimple_phi_result (vphi); + else + new_arg = gimple_phi_result (from_phi); + } else if ((res = new_phi_args.get (new_arg))) new_arg = *res; else
reply other threads:[~2024-01-30 10:59 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=20240130105937.E891C3857739@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).