[Bug tree-optimization/44900] [4.5 Regression] The variable of SSE will be broken

yottui at yahoo dot co dot jp gcc-bugzilla@gcc.gnu.org
Wed Jul 14 12:25:00 GMT 2010



------- Comment #16 from yottui at yahoo dot co dot jp  2010-07-14 12:24 -------
This is also the wrong result with MinGW gcc 3.4.5.
I'm expecting that all component of v will be 2500.

4.4.4 of MacPorts, 4.5.0 of MacPorts, 4.4.0 of MinGW and 4.5.0-1 of MinGW were
worked fine.

This time, I did not check 3.4.6 of MacPorts.
I tried to install gcc34 of MacPorts, but failed.

-- begin testcase --
// g++ -O -msse2 test.cpp
#include <xmmintrin.h>
#include <emmintrin.h>

extern "C" int  printf (const char*, ...);

// There is no _mm_castps_si128() in gcc 3.4
inline __m128i my_castps_si128(const __m128 & a)
{
        //return *(const __m128i *)&a; // same result

        union u {
                __m128  s;
                __m128i i;
        };
        const u & v = (const u &)a;

        return v.i;
}

inline __m128 my_castsi128_ps(const __m128i & a)
{
        //return *(const __m128 *)&a; // same result

        union u {
                __m128  s;
                __m128i i;
        };
        const u & v = (const u &)a;

        return v.s;
}

int main( int argc, char * argv[] )
{

        union u {
                __m128i v;
                int     e[4];
        };
        __m128i a  = _mm_set1_epi32(1250);
        __m128i b  = _mm_set1_epi32(2);
        __m128i v0 = _mm_setzero_si128();
        __m128i al = _mm_unpacklo_epi32(a, v0);
        __m128i ah = _mm_unpackhi_epi32(a, v0);
        __m128i bl = _mm_unpacklo_epi32(b, v0);
        __m128i bh = _mm_unpackhi_epi32(b, v0);
        __m128i lo = _mm_mul_epu32(al, bl);
        __m128i hi = _mm_mul_epu32(ah, bh);
        __m128  sl = my_castsi128_ps(lo);
        __m128  sh = my_castsi128_ps(hi);
        __m128  s  = _mm_shuffle_ps(sl, sh, 0x88); // 2, 0, 2, 0
        __m128i r  = my_castps_si128(s);

        u & v = (u &)r;
        printf("v: %d, %d, %d, %d\n", v.e[0], v.e[1], v.e[2], v.e[3]);

        return 0;
}
-- end testcase --

-- begin output --
v: 0, 0, 2500, 2500
-- end output --


-- 


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



More information about the Gcc-bugs mailing list