This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/31043] duplicated data in .rodata / .rodata.cst sections.
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Oct 2009 10:06:22 -0000
- Subject: [Bug other/31043] duplicated data in .rodata / .rodata.cst sections.
- References: <bug-31043-7667@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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