Re: Builtin/headers: Constant arguments and adding extra entry points.

2015-06-08 Thread Ondřej Bílka
On Mon, Jun 08, 2015 at 01:55:47PM -0700, Richard Henderson wrote: > On 06/04/2015 12:35 PM, Ondřej Bílka wrote: > >char *strchr_c(char *x, unsigned long u); > >#define strchr(x,c) \ > >(__builtin_constant_p(c) ? strchr_c (x, c * (~0ULL / 255)) : strchr (x,c)) > > > > Certainly not a universal win

Re: Builtin/headers: Constant arguments and adding extra entry points.

2015-06-08 Thread Richard Henderson
On 06/04/2015 12:35 PM, Ondřej Bílka wrote: char *strchr_c(char *x, unsigned long u); #define strchr(x,c) \ (__builtin_constant_p(c) ? strchr_c (x, c * (~0ULL / 255)) : strchr (x,c)) Certainly not a universal win, especially for 64-bit RISC. This constant can be just as expensive to construc

Builtin/headers: Constant arguments and adding extra entry points.

2015-06-04 Thread Ondřej Bílka
I start with simplest suggestion which is precomputing constant arguments like saving multiplication cost in strchr with: char *strchr_c(char *x, unsigned long u); #define strchr(x,c) \ (__builtin_constant_p(c) ? strchr_c (x, c * (~0ULL / 255)) : strchr (x,c)) Then I am working on using constan