Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Richard Biener
On Wed, 1 Feb 2017, Nathan Sidwell wrote: > On 02/01/2017 10:18 AM, Richard Biener wrote: > > > True. Updated patch below. > > > > Richard. > > > > 2017-02-01 Richard Biener > > > > PR cp/14179 > > cp/ > > * cp-gimplify.c (cp_fold): When folding a CONSTRUCTOR copy > > it la

Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Nathan Sidwell
On 02/01/2017 10:18 AM, Richard Biener wrote: True. Updated patch below. Richard. 2017-02-01 Richard Biener PR cp/14179 cp/ * cp-gimplify.c (cp_fold): When folding a CONSTRUCTOR copy it lazily on the first changed element only and copy it fully upfr

Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Jakub Jelinek
On Wed, Feb 01, 2017 at 04:18:49PM +0100, Richard Biener wrote: > 2017-02-01 Richard Biener > > PR cp/14179 > cp/ > * cp-gimplify.c (cp_fold): When folding a CONSTRUCTOR copy > it lazily on the first changed element only and copy it > fully upfront, only storing ch

Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Richard Biener
On Wed, 1 Feb 2017, Nathan Sidwell wrote: > On 02/01/2017 09:03 AM, Richard Biener wrote: > > > > Currently we copy CONSTRUCTORs we cp_fold even if no elements fold > > (we throw the copy away then). That's wasteful and we can easily > > do the copying on-demand. For simplicity the following re

Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Nathan Sidwell
On 02/01/2017 09:03 AM, Richard Biener wrote: Currently we copy CONSTRUCTORs we cp_fold even if no elements fold (we throw the copy away then). That's wasteful and we can easily do the copying on-demand. For simplicity the following resorts to memcpy-ing the whole original vector on the first

Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Richard Biener
On Wed, 1 Feb 2017, Jakub Jelinek wrote: > On Wed, Feb 01, 2017 at 03:35:49PM +0100, Richard Biener wrote: > > > > changed = false; > > > > break; > > > > } > > > > - changed = true; > > > > + if (! changed) > >

Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Jakub Jelinek
On Wed, Feb 01, 2017 at 03:35:49PM +0100, Richard Biener wrote: > > > changed = false; > > > break; > > > } > > > - changed = true; > > > + if (! changed) > > > + { > > > + nelts = elts->copy (); > > > > Isn't the above

Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Richard Biener
On Wed, 1 Feb 2017, Jakub Jelinek wrote: > On Wed, Feb 01, 2017 at 03:03:15PM +0100, Richard Biener wrote: > > 2017-02-01 Richard Biener > > > > PR cp/14179 > > cp/ > > * cp-gimplify.c (cp_fold): When folding a CONSTRUCTOR copy > > it lazily on the first changed element only an

Re: [PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Jakub Jelinek
On Wed, Feb 01, 2017 at 03:03:15PM +0100, Richard Biener wrote: > 2017-02-01 Richard Biener > > PR cp/14179 > cp/ > * cp-gimplify.c (cp_fold): When folding a CONSTRUCTOR copy > it lazily on the first changed element only and copy it > fully upfront, only storing ch

[PATCH][C++] Save memory/time when folding CONSTRUCTORs

2017-02-01 Thread Richard Biener
Currently we copy CONSTRUCTORs we cp_fold even if no elements fold (we throw the copy away then). That's wasteful and we can easily do the copying on-demand. For simplicity the following resorts to memcpy-ing the whole original vector on the first change and only overwrites changed elements in t