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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The vectorizer is confused by a LC PHI node with a constant argument.  That's
indeed sth that usually doesn't happen.

It's simple to avoid this propagation being done but the question is whether
code should rather deal with this (given I do not remember other code
avoiding this kind of propagation).  But then we should amend the LC-SSA
verifier appropriately.

diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 43641916d52..d16b7ee2d8e 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -6171,6 +6171,13 @@ process_bb (rpo_elim &avail, basic_block bb,
      exits PHIs.  */
   if (!iterate && eliminate)
     FOR_EACH_EDGE (e, ei, bb->succs)
+      {
+       bool lc_phi_nodes = false;
+       if (loops_state_satisfies_p (LOOP_CLOSED_SSA)
+           && e->src->loop_father != e->dest->loop_father
+           && flow_loop_nested_p (e->dest->loop_father,
+                                  e->src->loop_father))
+         lc_phi_nodes = true;
        for (gphi_iterator gsi = gsi_start_phis (e->dest);
             !gsi_end_p (gsi); gsi_next (&gsi))
          {
@@ -6197,9 +6204,12 @@ process_bb (rpo_elim &avail, basic_block bb,
                                              arg);
            if (sprime
                && sprime != arg
-             && may_propagate_copy (arg, sprime))
+               && may_propagate_copy (arg, sprime)
+               /* Do not substitute constants into LC PHI node arguments.  */
+               && (!lc_phi_nodes || TREE_CODE (sprime) == SSA_NAME))
              propagate_value (use_p, sprime);
          }
+      }

   vn_context_bb = NULL;
   return todo;

Reply via email to