public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-5983] tree-optimization/108782 - nested first order recurrence vectorization
@ 2023-02-14 11:50 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-02-14 11:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:994224236e0231807681b62e880d3c2772c69521

commit r13-5983-g994224236e0231807681b62e880d3c2772c69521
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Feb 14 11:10:56 2023 +0100

    tree-optimization/108782 - nested first order recurrence vectorization
    
    First order recurrence vectorization isn't possible for nested
    loops.
    
            PR tree-optimization/108782
            * tree-vect-loop.cc (vect_phi_first_order_recurrence_p):
            Make sure we're not vectorizing an inner loop.
    
            * gcc.dg/torture/pr108782.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr108782.c | 21 +++++++++++++++++++++
 gcc/tree-vect-loop.cc                   |  4 ++++
 2 files changed, 25 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr108782.c b/gcc/testsuite/gcc.dg/torture/pr108782.c
new file mode 100644
index 00000000000..1eac93db574
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr108782.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-copy-prop" } */
+
+int m;
+
+__attribute__ ((simd)) int
+foo (void)
+{
+  unsigned a;
+  int b = 0;
+
+  m = a = 1;
+  while (a != 0)
+    {
+      b = m;
+      m = 2;
+      ++a;
+    }
+
+  return b;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index becf96bb2b8..8387f7690b2 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -538,6 +538,10 @@ static bool
 vect_phi_first_order_recurrence_p (loop_vec_info loop_vinfo, class loop *loop,
 				   gphi *phi)
 {
+  /* A nested cycle isn't vectorizable as first order recurrence.  */
+  if (LOOP_VINFO_LOOP (loop_vinfo) != loop)
+    return false;
+
   /* Ensure the loop latch definition is from within the loop.  */
   edge latch = loop_latch_edge (loop);
   tree ldef = PHI_ARG_DEF_FROM_EDGE (phi, latch);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-14 11:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 11:50 [gcc r13-5983] tree-optimization/108782 - nested first order recurrence vectorization Richard Biener

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).