re PR tree-optimization/79351 (Invalid tree PRE optimization around compound literal)
authorRichard Biener <rguenther@suse.de>
Wed, 28 Nov 2018 11:01:06 +0000 (11:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 28 Nov 2018 11:01:06 +0000 (11:01 +0000)
2018-11-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/79351
* tree-ssa-sccvn.c (vn_reference_lookup_3): For assignments from
empty CONSTRUCTORs ensure the store is at a constant position.

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

From-SVN: r266551

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr79351.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 93b35e87c5c526f1fd9c44b299fee8df70fa20a5..d1123888cb847c33ea626fc38fb074e23f0f3970 100644 (file)
@@ -1,3 +1,9 @@
+2018-11-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79351
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): For assignments from
+       empty CONSTRUCTORs ensure the store is at a constant position.
+
 2018-11-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/88229
index 5d3b2d1266468903252529e5e7afd5695cbbee9a..b56d3dc40dd8b0034e50037ab0b01cef53811348 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79351
+       * gcc.dg/torture/pr79351.c: New testcase.
+
 2018-11-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/88189
@@ -13,7 +18,7 @@
        PR c++/88215
        * c-c++-common/ubsan/pr88215.c: New test.
 
-2018-10-19  Richard Biener  <rguenther@suse.de>
+2018-11-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/88182
        * g++.dg/gomp/pr88182.C: Move from libgomp and use -fopenmp-simd.
diff --git a/gcc/testsuite/gcc.dg/torture/pr79351.c b/gcc/testsuite/gcc.dg/torture/pr79351.c
new file mode 100644 (file)
index 0000000..0e145eb
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+
+static struct state {
+    int k;
+    int dummy;
+} states[256];
+
+__attribute((noipa))
+static void
+ismatch(int n)
+{
+  for (int j=0; j<n; j++) {
+      states[j] = (struct state){0};
+      for (int i = 0; i <= j; i++) {
+         states[i].k++;
+      }
+  }
+}
+
+int
+main()
+{
+  ismatch(2);
+  if (states[0].k != 2)
+    __builtin_abort();
+}
index e0ff40555ea3cc0790133bbcb4f6fbc5d13681af..b0b9d5221f49f81169456111507083e1ca100bce 100644 (file)
@@ -2115,6 +2115,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
       base2 = get_ref_base_and_extent (gimple_assign_lhs (def_stmt),
                                       &offset2, &size2, &maxsize2, &reverse);
       if (known_size_p (maxsize2)
+         && known_eq (maxsize2, size2)
          && operand_equal_p (base, base2, 0)
          && known_subrange_p (offset, maxsize, offset2, size2))
        {