Re: calloc = malloc + memset

2014-07-15 Thread Richard Biener
On Tue, Jul 15, 2014 at 2:33 PM, Bernd Schmidt wrote: > On 02/28/2014 11:48 PM, Marc Glisse wrote: >> >> /* Optimize >> + ptr = malloc (n); >> + memset (ptr, 0, n); >> + into >> + ptr = calloc (n); >> + gsi_p is known to point to a call to __builtin_memset. */ > > > Is there anything in

Re: calloc = malloc + memset

2014-07-15 Thread Bernd Schmidt
On 02/28/2014 11:48 PM, Marc Glisse wrote: /* Optimize + ptr = malloc (n); + memset (ptr, 0, n); + into + ptr = calloc (n); + gsi_p is known to point to a call to __builtin_memset. */ Is there anything in here to prevent us making an infinite loop if the above pattern occurs in a fu

Re: calloc = malloc + memset

2014-06-23 Thread Andrew Pinski
On Mon, Jun 23, 2014 at 1:21 PM, Andi Kleen wrote: > On Mon, Jun 23, 2014 at 10:14:25PM +0200, Marc Glisse wrote: >> On Mon, 23 Jun 2014, Andi Kleen wrote: >> >> >I would prefer to not do it. >> >> For the sake of micro benchmarks? > > Yes benchmarks are important. But micro-benchmarks are not i

Re: calloc = malloc + memset

2014-06-23 Thread Andi Kleen
On Mon, Jun 23, 2014 at 10:14:25PM +0200, Marc Glisse wrote: > On Mon, 23 Jun 2014, Andi Kleen wrote: > > >I would prefer to not do it. > > For the sake of micro benchmarks? Yes benchmarks are important. -Andi

Re: calloc = malloc + memset

2014-06-23 Thread Marc Glisse
On Mon, 23 Jun 2014, Andi Kleen wrote: I would prefer to not do it. For the sake of micro benchmarks? I'm not sure it has a lot of benefit. It has a non-zero benefit. If you want to keep it please make sure there is an easy way to turn it off. Any of these flags works: -fdisable-tree-s

Re: calloc = malloc + memset

2014-06-23 Thread Andi Kleen
On Mon, Jun 23, 2014 at 09:00:02PM +0200, Marc Glisse wrote: > On Mon, 23 Jun 2014, Andi Kleen wrote: > > >FWIW i believe the transformation will break a large variety of micro > >benchmarks. > > > >calloc internally knows that memory fresh from the OS is zeroed. > >But the memory may not be faul

Re: calloc = malloc + memset

2014-06-23 Thread Marc Glisse
On Mon, 23 Jun 2014, Andi Kleen wrote: FWIW i believe the transformation will break a large variety of micro benchmarks. calloc internally knows that memory fresh from the OS is zeroed. But the memory may not be faulted in yet. memset always faults in the memory. So if you have some test lik

Re: calloc = malloc + memset

2014-06-23 Thread Andrew Pinski
On Mon, Jun 23, 2014 at 11:17 AM, Andi Kleen wrote: > Marc Glisse writes: > >> Hello, >> >> this is a stage 1 patch, and I'll ping it then, but if you have >> comments now... > > FWIW i believe the transformation will break a large variety of micro > benchmarks. > > calloc internally knows that

Re: calloc = malloc + memset

2014-06-23 Thread Andi Kleen
Marc Glisse writes: > Hello, > > this is a stage 1 patch, and I'll ping it then, but if you have > comments now... FWIW i believe the transformation will break a large variety of micro benchmarks. calloc internally knows that memory fresh from the OS is zeroed. But the memory may not be faulte

Re: calloc = malloc + memset

2014-06-23 Thread Richard Biener
On Mon, Jun 23, 2014 at 6:19 PM, Marc Glisse wrote: > On Mon, 23 Jun 2014, Richard Biener wrote: > >> On June 23, 2014 5:51:30 PM CEST, Marc Glisse >> wrote: >>> >>> On Mon, 23 Jun 2014, Jakub Jelinek wrote: >>> Ok for trunk, sorry for the delay. >>> >>> >>> Thanks. Richard has moved the pas

Re: calloc = malloc + memset

2014-06-23 Thread Marc Glisse
On Mon, 23 Jun 2014, Richard Biener wrote: On June 23, 2014 5:51:30 PM CEST, Marc Glisse wrote: On Mon, 23 Jun 2014, Jakub Jelinek wrote: Ok for trunk, sorry for the delay. Thanks. Richard has moved the passes a bit since then, but I still have exactly one spot where the testsuite is ok :

Re: calloc = malloc + memset

2014-06-23 Thread Richard Biener
On June 23, 2014 5:51:30 PM CEST, Marc Glisse wrote: >On Mon, 23 Jun 2014, Jakub Jelinek wrote: > >> Ok for trunk, sorry for the delay. > >Thanks. Richard has moved the passes a bit since then, but I still have > >exactly one spot where the testsuite is ok :-) I need strlen to be >after >dom (for

Re: calloc = malloc + memset

2014-06-23 Thread Marc Glisse
On Mon, 23 Jun 2014, Jakub Jelinek wrote: Ok for trunk, sorry for the delay. Thanks. Richard has moved the passes a bit since then, but I still have exactly one spot where the testsuite is ok :-) I need strlen to be after dom (for calloc.C) and before vrp (for several strlenopt-*.c). I'll co

Re: calloc = malloc + memset

2014-06-23 Thread Jakub Jelinek
On Tue, Jun 03, 2014 at 04:00:17PM +0200, Marc Glisse wrote: > Ping? Ok for trunk, sorry for the delay. Jakub

Re: calloc = malloc + memset

2014-06-03 Thread Marc Glisse
Ping? On Sat, 17 May 2014, Marc Glisse wrote: Ping Jakub? https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01104.html On Wed, 23 Apr 2014, Richard Biener wrote: On Fri, Apr 18, 2014 at 8:27 PM, Marc Glisse wrote: Thanks for the comments! On Fri, 18 Apr 2014, Jakub Jelinek wrote: The passe

Re: calloc = malloc + memset

2014-05-17 Thread Marc Glisse
Ping Jakub? https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01104.html On Wed, 23 Apr 2014, Richard Biener wrote: On Fri, Apr 18, 2014 at 8:27 PM, Marc Glisse wrote: Thanks for the comments! On Fri, 18 Apr 2014, Jakub Jelinek wrote: The passes.def change makes me a little bit nervous, but i

Re: calloc = malloc + memset

2014-04-23 Thread Richard Biener
On Fri, Apr 18, 2014 at 8:27 PM, Marc Glisse wrote: > Thanks for the comments! > > > On Fri, 18 Apr 2014, Jakub Jelinek wrote: > >> The passes.def change makes me a little bit nervous, but if it works, >> perhaps. > > > Would you prefer running the pass twice? I thought there would be less > resis

Re: calloc = malloc + memset

2014-04-18 Thread Marc Glisse
Thanks for the comments! On Fri, 18 Apr 2014, Jakub Jelinek wrote: The passes.def change makes me a little bit nervous, but if it works, perhaps. Would you prefer running the pass twice? I thought there would be less resistance to moving the pass than duplicating it. By the way, I think eve

Re: calloc = malloc + memset

2014-04-18 Thread Jakub Jelinek
On Sun, Mar 23, 2014 at 05:13:46PM +0100, Marc Glisse wrote: > 2014-03-23 Marc Glisse > > PR tree-optimization/57742 > gcc/ > * tree-ssa-strlen.c (get_string_length): Ignore malloc. > (handle_builtin_malloc, handle_builtin_memset): New functions. > (strlen_optimize

Re: calloc = malloc + memset

2014-04-15 Thread Marc Glisse
Let me ping this. There's no hurry, but it may have got lost with 4.9 approaching. http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01205.html On Sun, 23 Mar 2014, Marc Glisse wrote: On Mon, 3 Mar 2014, Richard Biener wrote: That's a bit much of ad-hoc pattern-matching ... wouldn't be p = mallo

Re: calloc = malloc + memset

2014-03-23 Thread Marc Glisse
On Mon, 3 Mar 2014, Richard Biener wrote: That's a bit much of ad-hoc pattern-matching ... wouldn't be p = malloc (n); memset (p, 0, n); transform better suited to the strlen opt pass? After all that tracks what 'string' is associated with a SSA name pointer through arbitrary satements using a

Re: calloc = malloc + memset

2014-03-03 Thread Marc Glisse
On Mon, 3 Mar 2014, Richard Biener wrote: That's a bit much of ad-hoc pattern-matching ... wouldn't be p = malloc (n); memset (p, 0, n); transform better suited to the strlen opt pass? After all that tracks what 'string' is associated with a SSA name pointer through arbitrary satements using a

Re: calloc = malloc + memset

2014-03-03 Thread Richard Biener
On Fri, Feb 28, 2014 at 11:48 PM, Marc Glisse wrote: > Hello, > > this is a stage 1 patch, and I'll ping it then, but if you have comments > now... > > Passes bootstrap+testsuite on x86_64-linux-gnu. > > 2014-02-28 Marc Glisse > > PR tree-optimization/57742 > gcc/ > * tree-ssa-f

Re: calloc = malloc + memset

2014-03-01 Thread Marc Glisse
On Sat, 1 Mar 2014, Paolo Carlini wrote: Hi On 28/feb/2014, at 23:48, Marc Glisse wrote: Hello, this is a stage 1 patch, and I'll ping it then, but if you have comments now... Passes bootstrap+testsuite on x86_64-linux-gnu. 2014-02-28 Marc Glisse PR tree-optimization/57742 gcc/

Re: calloc = malloc + memset

2014-03-01 Thread Paolo Carlini
Hi > On 28/feb/2014, at 23:48, Marc Glisse wrote: > > Hello, > > this is a stage 1 patch, and I'll ping it then, but if you have comments > now... > > Passes bootstrap+testsuite on x86_64-linux-gnu. > > 2014-02-28 Marc Glisse > >PR tree-optimization/57742 > gcc/ >* tree-ssa-forwp

calloc = malloc + memset

2014-02-28 Thread Marc Glisse
Hello, this is a stage 1 patch, and I'll ping it then, but if you have comments now... Passes bootstrap+testsuite on x86_64-linux-gnu. 2014-02-28 Marc Glisse PR tree-optimization/57742 gcc/ * tree-ssa-forwprop.c (simplify_malloc_memset): New function. (simplify_bui