Has there been historical work done to investigate small integer optimization?

Richard Biener rguenther at suse.de
Mon Feb 12 12:57:09 CET 2024

On Mon, 12 Feb 2024, Torbj?rn Granlund wrote:

> marco.bodrato at tutanota.com writes:
>   But implementing it with the current mpz type is "impossible".
>   I mean, one should break the current interface.
>   Currently, _mp_d is always a pointer AND it always point to a readable limb. Even if _mp_alloc is zero.
> If we set alloc = 0 and size >= 2^30, then that means the the pointer
> field is actually a numeric value, and perhaps the low 30 bits of the
> size field is more bits for the numeric value.  :-)

Since both _mp_alloc is signed _mp_alloc < 0 could indicate an inline
limb, you can then declare _mp_size irrelevant, fixed to one limb
plus 2 * sizeof (int) * 8 - 1 bits.  Though that missing bit is
likely going to be awkward (also the position of the sign-bit given


Richard Biener <rguenther at suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

More information about the gmp-devel mailing list