This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/12395] Suboptimal code with global variables


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12395



------- Additional Comments From steven at gcc dot gnu dot org  2003-09-25 19:38 -------
Well I don't _know_ for sure if it is related to global variabes, but it sure
seems so:

void foo(int a) {
  if(++a) ++a;
  printf ("%d",a);
}



        .file   "t.c"
        .section        .rodata.str1.1,"aMS",@progbits,1
.LC0:
        .string "%d"
        .text
.globl foo
        .type   foo,@function
foo:
        movl    4(%esp), %eax
        incl    %eax
        je      .L2
        incl    %eax
.L2:
        pushl   %eax
        pushl   $.LC0
        call    printf
        popl    %eax
        popl    %edx
        ret
.Lfe1:
        .size   foo,.Lfe1-foo
        .ident  "GCC: (GNU) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)"


void foo() {
  int a
  if(++a) ++a;
  printf ("%d",a);
}

produces something similar.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]