help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unsigned int to float conversion


From: FÖLDY Lajos
Subject: unsigned int to float conversion
Date: Mon, 20 Jul 2009 19:15:12 +0200

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]