https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88243

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we are arriving here with a vect_nested_cycle def from the pattern_def
sequence but the code only expects to be called with the last stmt of a
reduction pattern.

t.c:5:5: note:   Analyze phi: e_25 = PHI <_48(4), e_14(10)>
t.c:5:5: note:   detected nested cycle: e_14 = e_25 / 2;
t.c:5:5: note:   Detected vectorizable nested cycle.

here the division is the pattern

patt_17 = e_25 < 0 ? 1 : 0;
patt_16 = e_25 + patt_17;
patt_22 = patt_16 >> 1;

t.c:5:5: note:   === vect_pattern_recog ===
t.c:5:5: note:   vect_recog_divmod_pattern: detected: e_14 = e_25 / 2;
t.c:5:5: note:   divmod pattern recognized: patt_22 = patt_16 >> 1;

and the def type is transfered to all stmts in the pattern def sequence
for some reason.  The new way of setting/initializing pattern stmts is
a bit twisted so it looks like re-adjusting all pattern-def-seq stmts
to vect_internal_def is the way to go (and works for the testcase).
Similar for inductions.

Testing the following.

diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 2b56d85afc5..39b6f822d19 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -4723,7 +4723,15 @@ vect_mark_pattern_stmts (stmt_vec_info orig_stmt_info,
gimple *pattern_stmt,
   if (def_seq)
     for (gimple_stmt_iterator si = gsi_start (def_seq);
         !gsi_end_p (si); gsi_next (&si))
-      vect_init_pattern_stmt (gsi_stmt (si), orig_stmt_info, pattern_vectype);
+      {
+       stmt_vec_info pattern_stmt_info
+         = vect_init_pattern_stmt (gsi_stmt (si),
+                                   orig_stmt_info, pattern_vectype);
+       /* Stmts in the def sequence are not vectorizable cycle or
+          induction defs, instead they should all be vect_internal_def
+          feeding the main pattern stmt which retains this def type.  */
+       STMT_VINFO_DEF_TYPE (pattern_stmt_info) = vect_internal_def;
+      }

   if (orig_pattern_stmt)
     {

Reply via email to