This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/80974] [8 Regression] wrong code (generated code hangs) at -O2 on x86_64-linux-gnu


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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the issue is indeed that we change side-band info on "leaders" to sth
optimistic later proved wrong during iteration but we do not undo this setting
(the lattice changes are not undone later but it is expected to converge and
just the VN expression hashtables are undone).

Your simple patch isn't correct though as other equivalences might still need
the info to be different.  That also means the current updating is bogus for
the same reason.  Consider i_10 = h_13 ending up clearing range-info on h_13,
then
i_12 = h_13 with favorable dominance relationship causing i_12 range-info to be
installed on h_13 (but not valid in _10 context).

So I think we have to bite the bullet and do


Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c        (revision 248913)
+++ gcc/tree-ssa-sccvn.c        (working copy)
@@ -3328,6 +3328,9 @@ set_ssa_val_to (tree from, tree to)
               == get_addr_base_and_unit_offset (TREE_OPERAND (to, 0), &toff))
           && coff == toff))
     {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       fprintf (dump_file, " (changed)\n");
+
       /* If we equate two SSA names we have to make the side-band info
          of the leader conservative (and remember whatever original value
         was present).  */
@@ -3342,22 +3345,6 @@ set_ssa_val_to (tree from, tree to)
                         gimple_bb (SSA_NAME_DEF_STMT (to))))
                /* Keep the info from the dominator.  */
                ;
-             else if (SSA_NAME_IS_DEFAULT_DEF (from)
-                      || dominated_by_p_w_unex
-                           (gimple_bb (SSA_NAME_DEF_STMT (to)),
-                            gimple_bb (SSA_NAME_DEF_STMT (from))))
-               {
-                 /* Save old info.  */
-                 if (! VN_INFO (to)->info.range_info)
-                   {
-                     VN_INFO (to)->info.range_info = SSA_NAME_RANGE_INFO (to);
-                     VN_INFO (to)->range_info_anti_range_p
-                       = SSA_NAME_ANTI_RANGE_P (to);
-                   }
-                 /* Use that from the dominator.  */
-                 SSA_NAME_RANGE_INFO (to) = SSA_NAME_RANGE_INFO (from);
-                 SSA_NAME_ANTI_RANGE_P (to) = SSA_NAME_ANTI_RANGE_P (from);
-               }
              else
                {
                  /* Save old info.  */
@@ -3369,6 +3356,9 @@ set_ssa_val_to (tree from, tree to)
                    }
                  /* Rather than allocating memory and unioning the info
                     just clear it.  */
+                 fprintf (dump_file, "clearing range info of ");
+                 print_generic_expr (dump_file, to);
+                 fprintf (dump_file, "\n");
                  SSA_NAME_RANGE_INFO (to) = NULL;
                }
            }
@@ -3381,17 +3371,6 @@ set_ssa_val_to (tree from, tree to)
                         gimple_bb (SSA_NAME_DEF_STMT (to))))
                /* Keep the info from the dominator.  */
                ;
-             else if (SSA_NAME_IS_DEFAULT_DEF (from)
-                      || dominated_by_p_w_unex
-                           (gimple_bb (SSA_NAME_DEF_STMT (to)),
-                            gimple_bb (SSA_NAME_DEF_STMT (from))))
-               {
-                 /* Save old info.  */
-                 if (! VN_INFO (to)->info.ptr_info)
-                   VN_INFO (to)->info.ptr_info = SSA_NAME_PTR_INFO (to);
-                 /* Use that from the dominator.  */
-                 SSA_NAME_PTR_INFO (to) = SSA_NAME_PTR_INFO (from);
-               }
              else if (! SSA_NAME_PTR_INFO (from)
                       /* Handle the case of trivially equivalent info.  */
                       || memcmp (SSA_NAME_PTR_INFO (to),
@@ -3403,14 +3382,15 @@ set_ssa_val_to (tree from, tree to)
                    VN_INFO (to)->info.ptr_info = SSA_NAME_PTR_INFO (to);
                  /* Rather than allocating memory and unioning the info
                     just clear it.  */
+                 fprintf (dump_file, "clearing points-to info of ");
+                 print_generic_expr (dump_file, to);
+                 fprintf (dump_file, "\n");
                  SSA_NAME_PTR_INFO (to) = NULL;
                }
            }
        }

       VN_INFO (from)->valnum = to;
-      if (dump_file && (dump_flags & TDF_DETAILS))
-       fprintf (dump_file, " (changed)\n");
       return true;
     }
   if (dump_file && (dump_flags & TDF_DETAILS))


for "better" results we could remember the clears we've done during iteration
and undo them if there'll be another iteration.

But the real answer lies in ditching the SCC VN iteration scheme for a RPO one
and using available names for match-and-simplify.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]