|
From: | FÖLDY Lajos |
Subject: | Re: unsigned int to float conversion |
Date: | Tue, 28 Jul 2009 22:40:29 +0200 |
Thanks, so I was missing zero-extension.As it turned out, the GCC vectorizer was wrong. The bug was fixed in 24 hours: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40809
regrads, lajos On Tue, 28 Jul 2009, sveiki wrote:
You're compiling here in 64-bit, but keep in mind that your unsigned int is 32 bits wide. With the top 32 bits in rax zeroed, rax (signed) is equivalent to eax (unsigned), keeping int mind that eax is just the least significant 32 bits of rax. The conversion instruction (cvtsi2ss) works on 64-bit signed integers (since your operand is a 64- bit register). The 32-bit encoded move, by default zero-extends to 64-bit (according to x86). You might want to check these out: http://www.intel.com/products/processor/manuals/index.htm Jeremy On Jul 20, 1:15 pm, FÖLDY Lajos <fo...@rmki.kfki.hu> wrote:Hi guys, I have some weird results from my program. The suspect is unsigned int to float conversion. I have created the following simple test: // a.cc void cvt_u4_f4(unsigned int* u4, float* f4) { *f4=*u4; } Compiling it with g++-4.4 -m64 -O3 -S a.cc creates the following listing: .file "a.cc" .text .p2align 4,,15 .globl _Z9cvt_u4_f4PjPf .type _Z9cvt_u4_f4PjPf, @function _Z9cvt_u4_f4PjPf: .LFB0: .cfi_startproc .cfi_personality 0x3,__gxx_personality_v0 mov (%rdi), %eax cvtsi2ssq %rax, %xmm0 movss %xmm0, (%rsi) ret .cfi_endproc .LFE0: .size _Z9cvt_u4_f4PjPf, .-_Z9cvt_u4_f4PjPf .ident "GCC: (GNU) 4.4.0" .section .note.GNU-stack,"",@progbits Now, here %eax is filled with the unsigned int value, then %rax is converted to float. It seems to me that the higher 32 bit of %rax is never set, I miss an xor %rax, %rax before mov. Am I right, or I miss something else? thanks, lajos
[Prev in Thread] | Current Thread | [Next in Thread] |