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]

[PR 82363] Fix thinko in SRA subaccess propagation


Hi,

the following fixes a thinko in propagate_subaccesses_across_link.
When we cannot copy over a tree of accesses of RHS to LHS because of
some conflict, we must mark the whole LHS access (sub-)tree as
potentially written, even when the RHS access describing this level is
not, because some of its sub-accesses might be, which is exactly what
happens in the PR.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin



2017-10-02  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/82363
	* tree-sra.c (propagate_subaccesses_across_link): In unrecoverable
	mismatch, mark lacc written regardless of racc.

	testsuite/
	* gcc.dg/tree-ssa/pr82363.c: New test.
---
 gcc/testsuite/gcc.dg/tree-ssa/pr82363.c | 50 +++++++++++++++++++++++++++++++++
 gcc/tree-sra.c                          |  2 +-
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr82363.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c b/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c
new file mode 100644
index 00000000000..6652468976b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+struct A
+{
+  int b;
+  int c;
+  int d;
+};
+
+struct E
+{
+  int f;
+  int g:18;
+  struct A h;
+};
+
+struct I
+{
+  int b;
+  int j;
+  struct E k;
+};
+
+int l, *m = &l;
+
+struct A n;
+struct I o;
+
+void __attribute__ ((noipa))
+test_l (void)
+{
+  if (l != 1)
+    __builtin_abort ();
+}
+
+int main ()
+{
+  while (1)
+    {
+      struct I q = { 0, 0, {0, 0, {1, 1, 1}}}, p = q, r = p, *s = &q;
+      if (p.k.h.c)
+        o = p;
+      *m = r.k.h.d;
+      n = (*s).k.h;
+      break;
+    }
+  test_l ();
+  return 0;
+}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index f5675edc7f1..bac593951e7 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2691,7 +2691,7 @@ propagate_subaccesses_across_link (struct access *lacc, struct access *racc)
 	    }
 	  else
 	    {
-	      if (rchild->grp_write && !lacc->grp_write)
+	      if (!lacc->grp_write)
 		{
 		  ret = true;
 		  subtree_mark_written_and_enqueue (lacc);
-- 
2.14.1



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