Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.

2019-12-04  Richard Biener  <rguent...@suse.de>

        * tree-ssa-sccvn.c (vn_reference_lookup_3): Properly guard
        empty CTOR and memset partial-def registering.  Take advantage
        of fancy offset analysis in memset handling.

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c        (revision 278955)
+++ gcc/tree-ssa-sccvn.c        (working copy)
@@ -2432,6 +2432,12 @@ vn_reference_lookup_3 (ao_ref *ref, tree
        }
       else
        return (void *)-1;
+      /* Sometimes the above trickery is smarter than alias analysis.  Take
+         advantage of that.  */
+      if (!ranges_maybe_overlap_p (offset, maxsize, offset2,
+                                  (wi::to_poly_offset (len)
+                                   << LOG2_BITS_PER_UNIT)))
+       return NULL;
       tree len = gimple_call_arg (def_stmt, 2);
       HOST_WIDE_INT leni, offset2i, offseti;
       if (data->partial_defs.is_empty ()
@@ -2471,7 +2477,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree
               && tree_to_poly_int64 (len).is_constant (&leni)
               && offset.is_constant (&offseti)
               && offset2.is_constant (&offset2i)
-              && maxsize.is_constant (&maxsizei))
+              && maxsize.is_constant (&maxsizei)
+              && ranges_known_overlap_p (offseti, maxsizei, offset2i, leni))
        {
          pd_data pd;
          pd.rhs = build_constructor (NULL_TREE, NULL);
@@ -2527,7 +2534,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree
                   && offset2.is_constant (&offset2i)
                   && offset2i % BITS_PER_UNIT == 0
                   && size2.is_constant (&size2i)
-                  && size2i % BITS_PER_UNIT == 0)
+                  && size2i % BITS_PER_UNIT == 0
+                  && ranges_known_overlap_p (offseti, maxsizei,
+                                             offset2i, size2i))
            {
              /* Let clobbers be consumed by the partial-def tracker
                 which can choose to ignore them if they are shadowed

Reply via email to