This is the mail archive of the
mailing list for the GCC project.
Re: Builtin/headers: Constant arguments and adding extra entry points.
- From: Richard Henderson <rth at twiddle dot net>
- To: OndÅej BÃlka <neleai at seznam dot cz>, gcc at gcc dot gnu dot org
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 08 Jun 2015 13:55:47 -0700
- Subject: Re: Builtin/headers: Constant arguments and adding extra entry points.
- Authentication-results: sourceware.org; auth=none
- References: <20150604193107 dot GA24282 at domone>
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.