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/45434] x86 missed optimization: use high register (ah, bh, ch, dh) when available to make comparisons


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

--- Comment #8 from Adam Warner <adam at consulting dot net.nz> 2012-01-18 07:00:44 UTC ---
Apologies for the noise. I had my machine constraints around the wrong way.
Here is the fixed version of the code:

#include <stdint.h>

uint64_t u8l(uint64_t in) {
  uint64_t out;
  asm ("movzbl %b1, %k0" : "=r" (out) : "q" (in));
  return out;
}

uint64_t u8h(uint64_t in) {
  uint64_t out;
  asm ("movzbl %h1, %k0" : "=r" (out) : "Q" (in));
  return out;
}

int main(void) {
  return 0;
}

With the X86-64 Linux ABI u8l() generates "movzbl %dil,%eax" and u8h() "mov
%rdi,%rdx; movzbl %dh,%eax" as expected.


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