A bug in VC++ compiler. RRS feed

  • Question

  • consdier the following code.
    #include <intrin.h>
    #include <iostream>

    using namespace std;

    union my_data
            __int64 si64[2];
            __m128i si128;

    my_data * g_data;

    int main()
            g_data = new my_data[128];

            int idx = 32;

            __m128i m = _mm_load_si128(&g_data[idx].si128);

            __int64 a = _mm_cvtsi128_si64(m);
            __int64 b = g_data[idx].si64[0];

            if (a != b)
                    cout << a << ' ' << b << endl; // this line is excuted, but a and b are equal...

            return 0;

    I tried VC2008SP1 and VC2010, they have the same problem, i have a look at the asm code excuted in VC2008SP1, it seems VC2010 have the same problem.

            __m128i m = _mm_load_si128(&g_data[idx].si128);
    000000013FDA102D  movdqa      xmm0,xmmword ptr [rax+200h] 

    000000013FDA1035  lfence           
            __int64 a = _mm_cvtsi128_si64(m);
            __int64 b = g_data[idx].si64[0];
    000000013FDA1038  mov         rax,qword ptr [g_data (13FDA35F8h)] 
    000000013FDA103F  movd        rdx,xmm0 
    000000013FDA1044  mov         rbx,qword ptr [rax+200h] 

            if (a != b)
    000000013FDA104B  cmp         rax,rbx 
                                      Oh, rax??????? should be rdx.....
    000000013FDA104E  je          main+83h (13FDA1083h) 
    Monday, December 21, 2009 3:55 AM

All replies

  • er...
    no reply -,-

    Will someboy try compile the code in VS2010 RC and tell me the result?
    Friday, February 19, 2010 3:19 PM
  • D:\Public>CPP_Test.exe
    0 0

    I created a bug against this Tal.
    Monday, February 22, 2010 9:23 PM