public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/93661 properly guard tree_to_poly_int64
@ 2020-02-11  9:52 Richard Biener
  2020-02-14  1:04 ` Hans-Peter Nilsson
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2020-02-11  9:52 UTC (permalink / raw)
  To: gcc-patches


Bootstrapped / tested on x86_64-unknown-linux-gnu, pushed.

Richard.

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/testsuite/gcc.dg/pr93661.c | 9 +++++++++
 gcc/tree-sra.c                 | 6 ++++--
 gcc/tree-ssa-sccvn.c           | 1 +
 3 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr93661.c

diff --git a/gcc/testsuite/gcc.dg/pr93661.c b/gcc/testsuite/gcc.dg/pr93661.c
new file mode 100644
index 00000000000..e311ba545c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr93661.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int f ()
+{
+  unsigned x = 0xffffffff;
+  __builtin_memset (1+(char *) &x, 0, -1); /* { dg-warning "maximum object size" } */
+  return (x != 0xf0000000);
+}
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 b42a30ed3fc..15cc567f8fd 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -2527,6 +2527,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)
-- 
2.16.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] tree-optimization/93661 properly guard tree_to_poly_int64
  2020-02-11  9:52 [PATCH] tree-optimization/93661 properly guard tree_to_poly_int64 Richard Biener
@ 2020-02-14  1:04 ` Hans-Peter Nilsson
  0 siblings, 0 replies; 2+ messages in thread
From: Hans-Peter Nilsson @ 2020-02-14  1:04 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Tue, 11 Feb 2020, Richard Biener wrote:
> Bootstrapped / tested on x86_64-unknown-linux-gnu, pushed.

> diff --git a/gcc/testsuite/gcc.dg/pr93661.c b/gcc/testsuite/gcc.dg/pr93661.c
> new file mode 100644
> index 00000000000..e311ba545c4
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr93661.c
> @@ -0,0 +1,9 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */

Missing int32plus qualifier considering the assumed-to-fit
constants?

> +
> +int f ()
> +{
> +  unsigned x = 0xffffffff;
> +  __builtin_memset (1+(char *) &x, 0, -1); /* { dg-warning "maximum object size" } */
> +  return (x != 0xf0000000);

brgds, H-P
PS. no, doesn't fail for targets I care for, just random.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-14  1:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11  9:52 [PATCH] tree-optimization/93661 properly guard tree_to_poly_int64 Richard Biener
2020-02-14  1:04 ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).