tree-optimization/93661 properly guard tree_to_poly_int64
authorRichard Biener <rguenther@suse.de>
Tue, 11 Feb 2020 09:52:31 +0000 (10:52 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 11 Feb 2020 09:53:31 +0000 (10:53 +0100)
2020-02-11  Richard Biener  <rguenther@suse.de>

PR tree-optimization/93661
PR tree-optimization/93662
* tree-ssa-sccvn.c (vn_reference_lookup_3): Properly guard
tree_to_poly_int64.
* tree-sra.c (get_access_for_expr): Likewise.

* gcc.dg/pr93661.c: New testcase.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/tree-sra.c
gcc/tree-ssa-sccvn.c

index 9f44b6f..3eafd66 100644 (file)
@@ -1,3 +1,11 @@
+2020-02-11  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/93661
+       PR tree-optimization/93662
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): Properly guard
+       tree_to_poly_int64.
+       * tree-sra.c (get_access_for_expr): Likewise.
+
 2020-02-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/93637
index 81ebea0..1844550 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-11  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/93661
+       PR tree-optimization/93662
+       * gcc.dg/pr93661.c: New testcase.
+
 2020-02-12  Patrick Palka  <ppalka@redhat.com>
 
        PR c++/69448
index ea8594d..f03ad3a 100644 (file)
@@ -3605,8 +3605,10 @@ get_access_for_expr (tree expr)
 
   if (tree basesize = DECL_SIZE (base))
     {
-      poly_int64 sz = tree_to_poly_int64 (basesize);
-      if (offset < 0 || known_le (sz, offset))
+      poly_int64 sz;
+      if (offset < 0
+         || !poly_int_tree_p (basesize, &sz)
+         || known_le (sz, offset))
        return NULL;
     }
 
index 2ffbc64..33cd12b 100644 (file)
@@ -2504,6 +2504,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
       /* For now handle clearing memory with partial defs.  */
       else if (known_eq (ref->size, maxsize)
               && integer_zerop (gimple_call_arg (def_stmt, 1))
+              && tree_fits_poly_int64_p (len)
               && tree_to_poly_int64 (len).is_constant (&leni)
               && offset.is_constant (&offseti)
               && offset2.is_constant (&offset2i)