This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]