Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-17 Thread Michal Nazarewicz
On Mon, Jun 16 2014, Andrew Morton wrote: > On Mon, 16 Jun 2014 23:07:22 +0200 Michal Nazarewicz > wrote: > >> It appears that gcc is better at optimising a double call to min >> and max rather than open coded min3 and max3. This can be observed >> here: >> >> ... >> >> Furthermore, after

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-17 Thread Hagen Paul Pfeifer
Wow, back in the days where I submitted the patch I saw improvement in the generated code (focus on number of instructions). Don't know what happends with gcc in the meantime. Anyway, patch and analysis looks good. So from a clean-patch perspective you get an: Signed-off-by: Hagen Paul Pfeifer

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-17 Thread Hagen Paul Pfeifer
Wow, back in the days where I submitted the patch I saw improvement in the generated code (focus on number of instructions). Don't know what happends with gcc in the meantime. Anyway, patch and analysis looks good. So from a clean-patch perspective you get an: Signed-off-by: Hagen Paul Pfeifer

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-17 Thread Michal Nazarewicz
On Mon, Jun 16 2014, Andrew Morton a...@linux-foundation.org wrote: On Mon, 16 Jun 2014 23:07:22 +0200 Michal Nazarewicz min...@mina86.com wrote: It appears that gcc is better at optimising a double call to min and max rather than open coded min3 and max3. This can be observed here: ...

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Steven Rostedt
On Mon, 16 Jun 2014 20:21:20 -0400 Steven Rostedt wrote: > On Mon, 16 Jun 2014 16:54:32 -0700 (PDT) > David Rientjes wrote: > > > > > > > On linux-next, allyesconfig has a 0.0001% savings as a result of the > > patch, but I'd be worried about the extra temp variable it allocates on > > the

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Steven Rostedt
On Mon, 16 Jun 2014 16:54:32 -0700 (PDT) David Rientjes wrote: > > > On linux-next, allyesconfig has a 0.0001% savings as a result of the > patch, but I'd be worried about the extra temp variable it allocates on > the stack that is evident in the mm/slab.c disassembly unless all cases > can

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread David Rientjes
On Mon, 16 Jun 2014, Andrew Morton wrote: > On Mon, 16 Jun 2014 16:25:15 -0700 (PDT) David Rientjes > wrote: > > > On Mon, 16 Jun 2014, Andrew Morton wrote: > > > > > > It appears that gcc is better at optimising a double call to min > > > > and max rather than open coded min3 and max3. This

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Andrew Morton
On Mon, 16 Jun 2014 16:25:15 -0700 (PDT) David Rientjes wrote: > On Mon, 16 Jun 2014, Andrew Morton wrote: > > > > It appears that gcc is better at optimising a double call to min > > > and max rather than open coded min3 and max3. This can be observed > > > here: > > > > > > ... > > > > > >

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread David Rientjes
On Mon, 16 Jun 2014, Andrew Morton wrote: > > It appears that gcc is better at optimising a double call to min > > and max rather than open coded min3 and max3. This can be observed > > here: > > > > ... > > > > Furthermore, after ___make allmodconfig && make bzImage modules___ this is > > the

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Andrew Morton
On Mon, 16 Jun 2014 23:07:22 +0200 Michal Nazarewicz wrote: > It appears that gcc is better at optimising a double call to min > and max rather than open coded min3 and max3. This can be observed > here: > > ... > > Furthermore, after ___make allmodconfig && make bzImage modules___ this is the

[PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Michal Nazarewicz
It appears that gcc is better at optimising a double call to min and max rather than open coded min3 and max3. This can be observed here: $ cat min-max.c #define min(x, y) ({\ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y);

[PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Michal Nazarewicz
It appears that gcc is better at optimising a double call to min and max rather than open coded min3 and max3. This can be observed here: $ cat min-max.c #define min(x, y) ({\ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y);

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Andrew Morton
On Mon, 16 Jun 2014 23:07:22 +0200 Michal Nazarewicz min...@mina86.com wrote: It appears that gcc is better at optimising a double call to min and max rather than open coded min3 and max3. This can be observed here: ... Furthermore, after ___make allmodconfig make bzImage modules___

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread David Rientjes
On Mon, 16 Jun 2014, Andrew Morton wrote: It appears that gcc is better at optimising a double call to min and max rather than open coded min3 and max3. This can be observed here: ... Furthermore, after ___make allmodconfig make bzImage modules___ this is the comparison of

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Andrew Morton
On Mon, 16 Jun 2014 16:25:15 -0700 (PDT) David Rientjes rient...@google.com wrote: On Mon, 16 Jun 2014, Andrew Morton wrote: It appears that gcc is better at optimising a double call to min and max rather than open coded min3 and max3. This can be observed here: ...

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread David Rientjes
On Mon, 16 Jun 2014, Andrew Morton wrote: On Mon, 16 Jun 2014 16:25:15 -0700 (PDT) David Rientjes rient...@google.com wrote: On Mon, 16 Jun 2014, Andrew Morton wrote: It appears that gcc is better at optimising a double call to min and max rather than open coded min3 and max3.

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Steven Rostedt
On Mon, 16 Jun 2014 16:54:32 -0700 (PDT) David Rientjes rient...@google.com wrote: On linux-next, allyesconfig has a 0.0001% savings as a result of the patch, but I'd be worried about the extra temp variable it allocates on the stack that is evident in the mm/slab.c disassembly unless

Re: [PATCH] include: kernel.h: rewrite min3, max3 and clamp using min and max

2014-06-16 Thread Steven Rostedt
On Mon, 16 Jun 2014 20:21:20 -0400 Steven Rostedt rost...@goodmis.org wrote: On Mon, 16 Jun 2014 16:54:32 -0700 (PDT) David Rientjes rient...@google.com wrote: On linux-next, allyesconfig has a 0.0001% savings as a result of the patch, but I'd be worried about the extra temp