This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Use assert()s for optimization?
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 6 Nov 2003 22:52:09 +0100 (CET)
- Subject: Use assert()s for optimization?
Hi!
Is there a way to turn an assert() into optimization hints for gcc?
Like in
double mysqrt(double x)
{
assert(x >= 0.0);
return sqrt(x);
}
have some way to tell the compiler x >= 0.0 is true, even in the case
of turning the assertion into a no-op? Something like
#ifdef NDEBUG
#define assert(x) if (!(x)) __builtin_not_reached()
#endif
or similar?
Thanks,
Richard.