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
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
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