__builtin_constant_p for trivial operations

Torbjorn Granlund tg at gmplib.org
Sun Feb 20 21:29:43 CET 2011

Marc Glisse <marc.glisse at inria.fr> writes:

  Ah, indeed, I didn't think of that. There would still be a way, but it
  gets ugly:
  have both names __gmpz_add_ui and __gmpz_add_ui_noinline refer to the
  same function in libgmp (technically, this doesn't require changing
  libgmp, only gmp.h). Have a macro mpz_add_ui=__gmpz_add_ui. And have a
  C99 inline function __gmpz_add_ui that does the __builtin_constant_p
  stuff and calls __gmpz_add_ui_noinline if needed.
I don't understand how this could work.

It seems that you are suggesting to apply __builtin_constant_p to an
argument of an inline function.  Alas, I don't think that would ever
evaluate to 1, since __builtin_constant_p is expanded quite early.


More information about the gmp-discuss mailing list