Why set zero in zero.c rather than use xor_n
Marc Glisse
marc.glisse at inria.fr
Mon Feb 5 22:44:43 UTC 2018
On Mon, 5 Feb 2018, Vincent Lefevre wrote:
> On 2018-02-05 21:48:47 +0100, Torbjorn Granlund wrote:
>> I suppose memset is not used as it might come with more overhead for
>> checking alignment. I haven't timed it, though.
>
> The compiler knows the alignment from the types.
Quite often it does not, the C type system is too weak.
> This is where the optimization should be.
Sadly, I don't think gcc has an optimization like what Niels suggested,
with multiple memset entry points according to the alignment. Searching a
bit, it looks like Intel's compiler does (they recommend using
__assume_aligned on the target of memset).
> The GCC manual mentions a __builtin_memset
> builtin, though I don't know what it does exactly.
That's how a regular call to memset is encoded internally... For small
constant sizes, it may be expanded inline, but usually it remains a call
to memset.
--
Marc Glisse
More information about the gmp-devel
mailing list