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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the vectorizer issue is highlighted by the following assert.  It triggers
because scalar and if-converted loop do not have a 1:1 match in the number of
loop-closed PHIs.  And that happens because split_loop_exit_edge elides
copying of the PHI node with a constant argument.

diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 1d1d1147696..b369200e15b 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -980,7 +980,12 @@ slpeel_duplicate_current_defs_from_edges (edge from, edge
to)
       else
        {
          if (get_current_def (to_arg) == NULL_TREE)
-           set_current_def (to_arg, get_current_def (from_arg));
+           {
+             gcc_assert (types_compatible_p (TREE_TYPE (to_arg),
+                                             TREE_TYPE (get_current_def
+                                                          (from_arg))));
+             set_current_def (to_arg, get_current_def (from_arg));
+           }
        }
       gsi_next (&gsi_from);
       gsi_next (&gsi_to);

we can keep the fragile code working by making split_loop_exit_edge also
copy constants (for the vectorizer use only).  Which also shows again
the code isn't prepared to handle constants here... (or rather constants
in one copy but not the other).

Reply via email to