------- Comment #2 from ubizjak at gmail dot com 2009-10-28 10:06 -------
4.3.x and newer gcc says:
pr31043.c:3: warning: 'pi' initialized and declared 'extern'
So, if you don't want to be treated as a constant, write
double pi = M_PI;
and this will generate the code you are looking for:
foo:
movsd pi(%rip), %xmm0
ret
pi:
.long 1413754136
.long 1074340347
As far as double copy when "double const pi = M_PI;" is used, tree optimizers
already propagate constant to return, as evident from optimized dump:
foo ()
{
<bb 2>:
return 3.141592653589793115997963468544185161590576171875e+0;
}
And this constant is handled in different way than its shadow in the memory.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31043