OK.
On Thu, Dec 13, 2018 at 6:03 PM Jakub Jelinek <ja...@redhat.com> wrote:
>
> Hi!
>
> The following patch makes use of RANGE_EXPRs in build_vec_init, instead of
> appending many ctor elements.
>
> E.g. on the PR87436 testcase the memory usage goes down from more than 5GB
> to a few megabytes and compile time decreases significantly too.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> Testcases not included, see follow-up patch.
>
> 2018-12-13 Jakub Jelinek <ja...@redhat.com>
>
> PR c++/82294
> PR c++/87436
> * init.c (build_vec_init): Change num_initialized_elts type from int
> to HOST_WIDE_INT. Build a RANGE_EXPR if e needs to be repeated more
> than once.
>
> --- gcc/cp/init.c.jj 2018-11-13 09:49:33.150035688 +0100
> +++ gcc/cp/init.c 2018-12-13 15:08:08.446783069 +0100
> @@ -4104,7 +4104,7 @@ build_vec_init (tree base, tree maxindex
> tree compound_stmt;
> int destroy_temps;
> tree try_block = NULL_TREE;
> - int num_initialized_elts = 0;
> + HOST_WIDE_INT num_initialized_elts = 0;
> bool is_global;
> tree obase = base;
> bool xvalue = false;
> @@ -4539,10 +4539,13 @@ build_vec_init (tree base, tree maxindex
>
> if (e)
> {
> - int max = tree_to_shwi (maxindex)+1;
> - for (; num_initialized_elts < max; ++num_initialized_elts)
> + HOST_WIDE_INT last = tree_to_shwi (maxindex);
> + if (num_initialized_elts <= last)
> {
> tree field = size_int (num_initialized_elts);
> + if (num_initialized_elts != last)
> + field = build2 (RANGE_EXPR, sizetype, field,
> + size_int (last));
> CONSTRUCTOR_APPEND_ELT (const_vec, field, e);
> }
> }
>
> Jakub