From: Richard Biener Date: Tue, 11 Feb 2020 09:52:31 +0000 (+0100) Subject: tree-optimization/93661 properly guard tree_to_poly_int64 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9714f1a70d184fb6d282ac543c57734ed1fb39ac;p=gcc.git tree-optimization/93661 properly guard tree_to_poly_int64 2020-02-11 Richard Biener 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. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9f44b6fd9f8..3eafd66f3b4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2020-02-11 Richard Biener + + 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 PR target/93637 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 81ebea01c17..1844550b5a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-02-11 Richard Biener + + PR tree-optimization/93661 + PR tree-optimization/93662 + * gcc.dg/pr93661.c: New testcase. + 2020-02-12 Patrick Palka PR c++/69448 diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index ea8594db193..f03ad3a586f 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -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; } diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 2ffbc643669..33cd12b202f 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -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)