re PR tree-optimization/91221 (ICE in get_int_cst_ext_nunits, at tree.c:1299 since...
authorRichard Biener <rguenther@suse.de>
Mon, 22 Jul 2019 11:18:55 +0000 (11:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 22 Jul 2019 11:18:55 +0000 (11:18 +0000)
2019-07-22  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91221
* tree-ssa-sccvn.c (vn_reference_lookup_3): Appropriately
restrict partial-def handling of empty constructors and
memset to refs with known offset.

* g++.dg/pr91221.C: New testcase.

From-SVN: r273667

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr91221.C [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 3e861ef..e58dfe1 100644 (file)
@@ -1,3 +1,10 @@
+2019-07-22  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91221
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): Appropriately
+       restrict partial-def handling of empty constructors and
+       memset to refs with known offset.
+
 2019-07-22  Jan Beulich  <jbeulich@suse.com>
 
        * config/i386/sse.md (ternlogsuffix): New.
index 7332696..e063774 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-22  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91221
+       * g++.dg/pr91221.C: New testcase.
+
 2019-07-22  Martin Liska  <mliska@suse.cz>
 
        PR driver/91172
diff --git a/gcc/testsuite/g++.dg/pr91221.C b/gcc/testsuite/g++.dg/pr91221.C
new file mode 100644 (file)
index 0000000..3036f1b
--- /dev/null
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-options "-O2 -fno-ipa-pure-const -fpack-struct -Wno-address-of-packed-member" }
+
+void printf(...);
+struct A {
+    A() : bar_(), dbar_() {
+       for (int i;; i++)
+         printf(i, bar_[i]);
+    }
+    int bar_[5];
+    double dbar_[5];
+};
+void fn1() { A a; }
index 5b0460d..cab2460 100644 (file)
@@ -2455,7 +2455,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
                   (vuse, vr->set, vr->type, vr->operands, val);
        }
       /* For now handle clearing memory with partial defs.  */
-      else if (integer_zerop (gimple_call_arg (def_stmt, 1))
+      else if (known_eq (ref->size, maxsize)
+              && integer_zerop (gimple_call_arg (def_stmt, 1))
               && tree_to_poly_int64 (len).is_constant (&leni)
               && offset.is_constant (&offseti)
               && offset2.is_constant (&offset2i)
@@ -2503,7 +2504,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
              return vn_reference_lookup_or_insert_for_pieces
                  (vuse, vr->set, vr->type, vr->operands, val);
            }
-         else if (maxsize.is_constant (&maxsizei)
+         else if (known_eq (ref->size, maxsize)
+                  && maxsize.is_constant (&maxsizei)
                   && maxsizei % BITS_PER_UNIT == 0
                   && offset.is_constant (&offseti)
                   && offseti % BITS_PER_UNIT == 0