Builtin/headers: Constant arguments and adding extra entry points.
Richard Henderson
rth@twiddle.net
Mon Jun 8 21:03:00 GMT 2015
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 construct as the original multiplication.
Consider PPC64, where 4 insns are required to form this kind of replicated
64-bit constant, and 3 insns are required to replicate C.
Then there's other RISC for which replicating C is easily done in parallel with
the initial alignment checks.
r~
More information about the Libc-alpha
mailing list