>From PR 34653, for

---
extern unsigned long table[];

unsigned long foo(unsigned char *p) {
  unsigned long tag = *p;
  return table[tag >> 4] + table[tag & 0xf];
}
---

at -O2, IRA generates an extra register move:

gcc-4.3 with -O2 generates:

foo:
        movzbl  (%rdi), %edx
        movq    %rdx, %rax
        shrq    $4, %rdx
        andl    $15, %eax
        movq    table(,%rax,8), %rax
        addq    table(,%rdx,8), %rax
        ret

And gcc-4.4+ -O2 generates:

foo:
        movzbl  (%rdi), %eax
        movq    %rax, %rcx
>>      movq    %rax, %rdx
        andl    $15, %ecx
        shrq    $4, %rdx
        movq    table(,%rcx,8), %rax
        addq    table(,%rdx,8), %rax
        ret

Please note extra move.


-- 
           Summary: [4.4/4.5/4.6 Regression] IRA generates extra register
                    move
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl dot tools at gmail dot com


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

Reply via email to