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

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think that's a separate issue.  if-conversion is confused about

.MEM_198 = PHI <.MEM_191(43)>

which it should simply ignore.

Index: tree-if-conv.c
===================================================================
--- tree-if-conv.c      (revision 235305)
+++ tree-if-conv.c      (working copy)
@@ -659,7 +659,7 @@ if_convertible_phi_p (struct loop *loop,

   if (bb != loop->header)
     {
-      if (gimple_phi_num_args (phi) != 2
+      if (gimple_phi_num_args (phi) > 2
          && !aggressive_if_conv
          && !phi_convertible_by_degenerating_args (phi))
        {

should fix the ICE but it leads to another latent issue:

/space/rguenther/src/svn/trunk/gcc/testsuite/gcc.dg/pr70725.c: In function
'fn1':
/space/rguenther/src/svn/trunk/gcc/testsuite/gcc.dg/pr70725.c:13:1: error:
statement uses released SSA name:
# .MEM_202 = VDEF <.MEM_198>
# lhs access alignment 32+0
c[_73] = _ifc__387;
The use of .MEM_198 should have been replaced
/space/rguenther/src/svn/trunk/gcc/testsuite/gcc.dg/pr70725.c:13:1: internal
compiler error: cannot update SSA form


Fixed by

Index: tree-if-conv.c
===================================================================
--- tree-if-conv.c      (revision 235305)
+++ tree-if-conv.c      (working copy)
@@ -1911,20 +1911,31 @@ predicate_all_scalar_phis (struct loop *
       if (bb == loop->header)
        continue;

-      if (EDGE_COUNT (bb->preds) == 1)
-       continue;
-
       phi_gsi = gsi_start_phis (bb);
       if (gsi_end_p (phi_gsi))
        continue;

-      gsi = gsi_after_labels (bb);
-      while (!gsi_end_p (phi_gsi))
+      if (EDGE_COUNT (bb->preds) == 1)
        {
-         phi = phi_gsi.phi ();
-         predicate_scalar_phi (phi, &gsi);
-         release_phi_node (phi);
-         gsi_next (&phi_gsi);
+         /* Propagate degenerate PHIs.  */
+         for (phi_gsi = gsi_start_phis (bb); !gsi_end_p (phi_gsi);
+              gsi_next (&phi_gsi))
+           {
+             gphi *phi = phi_gsi.phi ();
+             replace_uses_by (gimple_phi_result (phi),
+                              gimple_phi_arg_def (phi, 0));
+           }
+       }
+      else
+       {
+         gsi = gsi_after_labels (bb);
+         while (!gsi_end_p (phi_gsi))
+           {
+             phi = phi_gsi.phi ();
+             predicate_scalar_phi (phi, &gsi);
+             release_phi_node (phi);
+             gsi_next (&phi_gsi);
+           }
        }

       set_phi_nodes (bb, NULL);

Reply via email to