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 9f44b6fd9f8a7f835a9c876e5f4f201217ec193f..3eafd66f3b461cff003d0ebfecf95d73c29d9590 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 81ebea01c17d3fcc279ec9e043a3d573a949a9a9..1844550b5a2d1196a70e52e19fd4f65947bbe3d9 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 ea8594db19357b839e0663fb83774afaa694fe0b..f03ad3a586fcdc26f2c740b2cc8c572f1cccef05 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 2ffbc643669490f48dc6209994cc104b32baf921..33cd12b202ffae1d8c732907d53b3ef8f452a7c9 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)