This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR86363


The following fixes an oversight in a previous patch to enhance VN
of memset calls.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

>From b35c162ee7126057134d3b478e80160880402f1a Mon Sep 17 00:00:00 2001
From: Richard Guenther <rguenther@suse.de>
Date: Mon, 2 Jul 2018 13:11:39 +0200
Subject: [PATCH] fix-pr86363

2018-07-02  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/86363
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Check the
	memset argument refers to a non-variable address.

	* gcc.dg/torture/pr86363.c: New testcase.

diff --git a/gcc/testsuite/gcc.dg/torture/pr86363.c b/gcc/testsuite/gcc.dg/torture/pr86363.c
new file mode 100644
index 00000000000..154f9386e05
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr86363.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-additional-options "-w -Wno-psabi" } */
+
+typedef char U __attribute__ ((vector_size (16)));
+typedef unsigned V __attribute__ ((vector_size (16)));
+
+V g;
+
+V
+f (V v, U u)
+{
+  __builtin_memset (&u[v[0]], 0, 1);
+  g ^= u[0];
+  return g;
+}
+
+int
+main (void)
+{
+  V x = f ((V) { 5 }, (U) { 1 });
+
+  if (x[0] != 1 || x[1] != 1 || x[2] != 1 || x[3] != 1)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index e5eddf902b8..1e16e13cfa1 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1988,6 +1988,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
 	  base2 = get_ref_base_and_extent (ref2, &offset2, &size2, &maxsize2,
 					   &reverse);
 	  if (!known_size_p (maxsize2)
+	      || !known_eq (maxsize2, size2)
 	      || !operand_equal_p (base, base2, OEP_ADDRESS_OF))
 	    return (void *)-1;
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]