------- Comment #8 from hubicka at gcc dot gnu dot org 2009-11-12 13:23 ------- There are some bugs on LTO and unused vars elimination, but in this testcase we end up with: main: .LFB2: subq $8, %rsp .LCFI0: movl y(%rip), %esi movl $.LC0, %edi xorl %eax, %eax addl $5, %esi movl %esi, y(%rip) call printf xorl %eax, %eax addq $8, %rsp .LCFI1: ret .LFE2:
While GCC might be able to recognize that main is not reentrant and thus computing the static variable is useless, this is bit tricky to do. Honza -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41589