From 8801ca5c28c3a9e9f36fa39a6a4455b48c8221fa Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 22 Jul 2019 11:18:55 +0000 Subject: [PATCH] re PR tree-optimization/91221 (ICE in get_int_cst_ext_nunits, at tree.c:1299 since r273548) 2019-07-22 Richard Biener 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 | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr91221.C | 13 +++++++++++++ gcc/tree-ssa-sccvn.c | 6 ++++-- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr91221.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e861effcd5..e58dfe153c0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-07-22 Richard Biener + + 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 * config/i386/sse.md (ternlogsuffix): New. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7332696d395..e0637748eb8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-22 Richard Biener + + PR tree-optimization/91221 + * g++.dg/pr91221.C: New testcase. + 2019-07-22 Martin Liska PR driver/91172 diff --git a/gcc/testsuite/g++.dg/pr91221.C b/gcc/testsuite/g++.dg/pr91221.C new file mode 100644 index 00000000000..3036f1bc43b --- /dev/null +++ b/gcc/testsuite/g++.dg/pr91221.C @@ -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; } diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 5b0460d2bc6..cab2460a308 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -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 -- 2.30.2