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/12419] New: Performace regression: poor optimization of const memory


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

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

           Summary: Performace regression: poor optimization of const memory
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aph at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org

This program:

extern const int a[];
extern void f();

int foo ()
{
  int n = a[0]; 
  f();
  n += a[0];
  return n;
}

generates this code:

foo:
        pushl   %ebx
        subl    $8, %esp
        movl    a, %ebx
        call    f
        movl    a, %eax
        addl    $8, %esp
        addl    %eax, %ebx
        movl    %ebx, %eax
        popl    %ebx
        ret

Note that the memory 'a' is read twice.  3.2 did this:

foo:
        pushl   %ebx
        subl    $8, %esp
        movl    a, %ebx
        sall    $1, %ebx
        call    f
        addl    $8, %esp
        movl    %ebx, %eax
        popl    %ebx
        ret


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