This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
__builtin_constant_p to stop constant folding
- To: gcc at gcc dot gnu dot org
- Subject: __builtin_constant_p to stop constant folding
- From: Sylvain Pion <Sylvain dot Pion at sophia dot inria dot fr>
- Date: Wed, 6 Jun 2001 16:41:18 +0200
It seems that with GCC 3, __builtin_constant_p sometimes answers 0, even when
GCC actually does some constant folding (in a later pass ?). It's
annoying for me since I used to use __builtin_constant_p to stop constant
folding on certain variables using something like :
inline double stop_cprop(double d)
{
volatile double e = d;
return e;
}
#define STOP_CPROP(x) (__builtin_constant_p(x) ? stop_cprop(x) : (x))
inline double div (double a, double b)
{
return a / STOP_CPROP(b);
}
div(1.0, 3.0); // return value depends on current rounding mode.
It's hard to extract a test case from my code, but it worked for me with GCC
2.95, so it's a performance regression since I will be forced to call
stop_cprop() everytime now.
I guess the right way to do what I want is to use "#pragma STDC FENV_ACCESS",
but it's not supported by GCC 3 :(.
Is there a possibility to restore this old __builtin_constant_p property ?
--
Sylvain