This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/45434] x86 missed optimization: use high register (ah, bh, ch, dh) when available to make comparisons
- From: "adam at consulting dot net.nz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 18 Jan 2012 07:00:44 +0000
- Subject: [Bug rtl-optimization/45434] x86 missed optimization: use high register (ah, bh, ch, dh) when available to make comparisons
- Auto-submitted: auto-generated
- References: <bug-45434-4@http.gcc.gnu.org/bugzilla/>
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.