public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3381] tree-optimization/102226 - fix epilogue vector re-use
@ 2021-09-07 11:10 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-09-07 11:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:843068149ec8fcaaaec12751f5b70221a1153857

commit r12-3381-g843068149ec8fcaaaec12751f5b70221a1153857
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Sep 7 11:46:00 2021 +0200

    tree-optimization/102226 - fix epilogue vector re-use
    
    This fixes re-use of the reduction value in epilogue vectorization
    when a conversion from/to variable lenght vectors is required.
    
    2021-09-07  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/102226
            * tree-vect-loop.c (vect_transform_cycle_phi): Record
            the converted value for the epilogue PHI use.
    
            * g++.dg/vect/pr102226.cc: New testcase.

Diff:
---
 gcc/testsuite/g++.dg/vect/pr102226.cc | 29 +++++++++++++++++++++++++++++
 gcc/tree-vect-loop.c                  |  4 ++--
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/vect/pr102226.cc b/gcc/testsuite/g++.dg/vect/pr102226.cc
new file mode 100644
index 00000000000..ddf5e460c28
--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/pr102226.cc
@@ -0,0 +1,29 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-msve-vector-bits=128" { target aarch64_sve } }
+
+template <typename a> struct b { using c = a; };
+template <typename a, template <typename> class> using f = b<a>;
+template <typename a, template <typename> class g>
+using h = typename f<a, g>::c;
+struct i {
+  template <typename j> using k = typename j::l;
+};
+struct m : i {
+  using l = h<char *, k>;
+};
+class n {
+public:
+  char operator[](long o) {
+    m::l s;
+    return s[o];
+  }
+} p;
+n r;
+int q() {
+  long d;
+  for (long e; e; e++)
+    if (p[e] == r[e])
+      d++;
+  return d;
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 0c8d992624b..c9dcc647d2c 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -7755,11 +7755,11 @@ vect_transform_cycle_phi (loop_vec_info loop_vinfo,
 						  (reduc_info),
 						&stmts);
 	    }
+	  if (!useless_type_conversion_p (vectype_out, TREE_TYPE (def)))
+	    def = gimple_convert (&stmts, vectype_out, def);
 	  /* Adjust the input so we pick up the partially reduced value
 	     for the skip edge in vect_create_epilog_for_reduction.  */
 	  accumulator->reduc_input = def;
-	  if (!useless_type_conversion_p (vectype_out, TREE_TYPE (def)))
-	    def = gimple_convert (&stmts, vectype_out, def);
 	  if (loop_vinfo->main_loop_edge)
 	    {
 	      /* While we'd like to insert on the edge this will split


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

only message in thread, other threads:[~2021-09-07 11:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 11:10 [gcc r12-3381] tree-optimization/102226 - fix epilogue vector re-use 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).