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 rtl-optimization/46200] New: optimization regression in simple pointer loop


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

           Summary: optimization regression in simple pointer loop
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: miles@gnu.org


I compiled this simple test function with both g++ 4.5.1 and g++-4.6
(2010-10-16 snapshot):

  void test (int *b, int *e, int stride)
  {
    for (int *p = b; p != e; p += stride)
      *p = 1;
  }

Using compiler options "-O2 -march=core2 -S".

I got the following asm output;

g++ 4.5.1:

  .globl test(int*, int*, int)
  test(int*, int*, int):
          cmpq    %rsi, %rdi
          je      .L1
          movslq  %edx, %rax
          salq    $2, %rax
  .L3:
          movl    $1, (%rdi)
          addq    %rax, %rdi
          cmpq    %rdi, %rsi
          jne     .L3
  .L1:
          rep
          ret


g++-4.6 (2010-10-16 snapshot):

  test(int*, int*, int):
          cmpq    %rsi, %rdi
          je      .L1
          movslq  %edx, %rdx
          salq    $2, %rdx
          movq    %rdx, %rcx
          addq    %rdx, %rdi
          negq    %rcx
          jmp     .L3
  .L4:
          movq    %rax, %rdi
  .L3:
          movl    $1, (%rdi,%rcx)
          leaq    (%rdi,%rdx), %rax
          cmpq    %rdi, %rsi
          jne     .L4
  .L1:
          rep
          ret


The output of 4.6 seems clearly worse than the output of 4.5.

Thanks,

-miles


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