this may or may not be the same as #29775.

% cat extra-mov.c <<EOF
unsigned *table;
unsigned shift;

unsigned foo1(unsigned p)
{
  unsigned block = p >> shift;
  unsigned value = table[block];
  return (value >> 8);
}
EOF
% gcc -g -O3 -Wall   -c -o extra-mov.o extra-mov.c
% objdump -dr extra-mov.o

extra-mov.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <foo1>:
   0:   8b 0d 00 00 00 00       mov    0(%rip),%ecx        # 6 <foo1+0x6>
                        2: R_X86_64_PC32        shift+0xfffffffffffffffc
   6:   48 8b 05 00 00 00 00    mov    0(%rip),%rax        # d <foo1+0xd>
                        9: R_X86_64_PC32        table+0xfffffffffffffffc
   d:   d3 ef                   shr    %cl,%edi
   f:   89 ff                   mov    %edi,%edi
  11:   8b 04 b8                mov    (%rax,%rdi,4),%eax
  14:   c1 e8 08                shr    $0x8,%eax
  17:   c3                      retq

the "mov %edi,%edi" is presumably there as a 32->64 extend... but it's not
necessary because %edi was written in previous instruction.

% gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/home/odo/gcc --disable-multilib
--disable-biarch x86_64-unknown-linux-gnu --enable-languages=c
Thread model: posix
gcc version 4.3.0 20070217 (experimental)

i've seen it in 4.1.1 too.

-dean


-- 
           Summary: extra register move to self
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dean at arctic dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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

Reply via email to