mini-gmp

bodrato at mail.dm.unipi.it bodrato at mail.dm.unipi.it
Sun Feb 23 10:58:06 UTC 2014


Ciao,

Il Ven, 17 Gennaio 2014 1:10 pm, Vincent Lefevre ha scritto:
> you may also have optimizations based on the fact that some variable
> cannot be zero. But you have no types that don't include zero. The
> right solution is to make sure that the compiler knows the range.

> #define HINT(expr) ((expr) || (__builtin_unreachable(), 0))

This can be interesting in some contexts.
Moreover, most of the ASSERTs we have in the code might be changed into
HINTs when we do not want asserts, because they can give some information
to the compiler...

#if WANT_ASSERT
 #define ASSERT_OR_HINT(expr) ASSERT(expr)
#else
 #define ASSERT_OR_HINT(expr) HINT(expr)
#endif

Then we might use ASSERT_OR_HINT ((n) >= 0) ...

Regards,
m

-- 
http://bodrato.it/papers/



More information about the gmp-devel mailing list