[Bug target/34653] unnecessary REX prefix

dean at arctic dot org gcc-bugzilla@gcc.gnu.org
Thu Jan 3 20:10:00 GMT 2008



------- Comment #1 from dean at arctic dot org  2008-01-03 19:27 -------
oops i should have used an "unsigned long" for the tag rather than unsigned
long long, not that it matters much.

here's an expanded example showing another unnecessary REX:

extern unsigned long table[];

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

which generates:

   0:   0f b6 17                movzbl (%rdi),%edx
   3:   48 89 d0                mov    %rdx,%rax
   6:   48 c1 ea 04             shr    $0x4,%rdx
   a:   83 e0 0f                and    $0xf,%eax
   d:   48 8b 04 c5 00 00 00    mov    0x0(,%rax,8),%rax
  14:   00
                        11: R_X86_64_32S        table
  15:   48 03 04 d5 00 00 00    add    0x0(,%rdx,8),%rax
  1c:   00
                        19: R_X86_64_32S        table
  1d:   c3                      retq

and in this case the "mov %rdx,%rax" could be "mov %edx,%eax" because of the
dominating movzbl.


-- 


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



More information about the Gcc-bugs mailing list