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 r13-3356] tree-optimization/107302 - fix vec_perm placement for recurrence vect Date: Tue, 18 Oct 2022 10:50:10 +0000 (GMT) [thread overview] Message-ID: <20221018105010.C7B893858C83@sourceware.org> (raw) https://gcc.gnu.org/g:92ef7822bfd4ea3393e0a1dd40b4abef9fce027f commit r13-3356-g92ef7822bfd4ea3393e0a1dd40b4abef9fce027f Author: Richard Biener <rguenther@suse.de> Date: Tue Oct 18 10:01:45 2022 +0200 tree-optimization/107302 - fix vec_perm placement for recurrence vect The following fixes the VEC_PERM_EXPR placement when the latch definition is a PHI node. PR tree-optimization/107302 * tree-vect-loop.cc (vectorizable_recurrence): Fix vec_perm placement for a PHI latch def. * gcc.dg/vect/pr107302.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/pr107302.c | 13 +++++++++++++ gcc/tree-vect-loop.cc | 12 +++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/pr107302.c b/gcc/testsuite/gcc.dg/vect/pr107302.c new file mode 100644 index 00000000000..293f7e4067a --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr107302.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-pre" } */ + +int a[2000]; +int s292_im1; + +void +s292() { + for (int i = 0; i < 2000; i++) { + a[i] = s292_im1; + s292_im1 = i; + } +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 63e86540d12..92790bd8095 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -8485,9 +8485,15 @@ vectorizable_recurr (loop_vec_info loop_vinfo, stmt_vec_info stmt_info, second and later operands are tentative and will be updated when we have vectorized the latch definition. */ edge le = loop_latch_edge (LOOP_VINFO_LOOP (loop_vinfo)); - gimple_stmt_iterator gsi2 - = gsi_for_stmt (SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, le))); - gsi_next (&gsi2); + gimple *latch_def = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, le)); + gimple_stmt_iterator gsi2; + if (is_a <gphi *> (latch_def)) + gsi2 = gsi_after_labels (gimple_bb (latch_def)); + else + { + gsi2 = gsi_for_stmt (latch_def); + gsi_next (&gsi2); + } for (unsigned i = 0; i < ncopies; ++i) {
reply other threads:[~2022-10-18 10:50 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=20221018105010.C7B893858C83@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).