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

2010-07-14 Thread yottui at yahoo dot co dot jp


--- Comment #23 from yottui at yahoo dot co dot jp  2010-07-15 03:45 ---
(In reply to comment #22)
> Please file that as a different bug.
May I enter comment #15 as a new bug to Bugzilla?


-- 


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



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

2010-07-14 Thread yottui at yahoo dot co dot jp


--- 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 
#include 

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



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

2010-07-14 Thread yottui at yahoo dot co dot jp


--- Comment #15 from yottui at yahoo dot co dot jp  2010-07-14 09:22 ---
I found the similar case with gcc 4.4.4 of MacPorts and gcc 4.4.0 of MinGW.

-- begin testcase --
// g++ -O -msse2 test.cpp
typedef long long __m128i __attribute__ ((__vector_size__ (16),
__may_alias__));

struct vec
{
__m128i v;

static vec load(const int * p)
{ return (__m128i) __builtin_ia32_loaddqu((char const *)p); }

const int & operator [](int i) const
{
union u {
__m128i v;
int e[4];
};

return ((const u &)v).e[i];
}

vec() {}
vec(const __m128i & a) : v(a) {}
};

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

int main( int argc, char * argv[] )
{
__attribute__((aligned(16))) int data[] =
{ 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5 };

vec a = vec::load(data);

printf("v: %d, %d, %d, %d\n", a[0], a[1], a[2], a[3]);

return 0;
}
-- end testcase --

-- begin output --
v: 16, 16, 14, 14
-- end output --


-- 


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



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

2010-07-11 Thread yottui at yahoo dot co dot jp


--- Comment #10 from yottui at yahoo dot co dot jp  2010-07-11 23:11 ---
Please use '-m32' if host is x64.


-- 


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



[Bug c++/44900] The variable of SSE will be broken

2010-07-10 Thread yottui at yahoo dot co dot jp


--- Comment #1 from yottui at yahoo dot co dot jp  2010-07-10 15:12 ---
Also, I reproduced it on gcc45 of MacPorts 1.9.1 with '-O -m32 -msse' compiler
options.
At that time, I modified errno of the test code.

--- test.old.cpp2010-07-10 23:27:22.0 +0900
+++ test.new.cpp2010-07-10 23:32:57.0 +0900
@@ -48,7 +48,7 @@
 };

 extern "C" {
-int* _errno(void);
+extern int errno;
 int  printf (const char*, ...);
 }

@@ -58,9 +58,9 @@
 if ( !is_succeed )
 {
 printf("error: %s(%d)\n", file_name, line_num);
-if ( *_errno() ) // LINE_A
+if ( errno ) // LINE_A
 {
-printf("errno: %d\n", *_errno());
+printf("errno: %d\n", errno);
 }
 }


-- 


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



[Bug c++/44900] New: The variable of SSE will be broken

2010-07-10 Thread yottui at yahoo dot co dot jp
I'm using gcc-4.5.0-1 of MinGW with Intel x86.
When I execute the following test code with '-O -msse' compiler options, it
outputs the wrong value.
I'm expecting that v2.e[3] will be 7.0f.

And, when I exclude LINE_A, LINE_B, LINE_C or LINE_D as a comment, the program
outputs the expected value.

-- begin test code --
// g++ -O -msse test.cpp
typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
typedef float __v4sf __attribute__ ((__vector_size__ (16)));

extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
_mm_set_ps (const float __Z, const float __Y, const float __X, const float __W)
{
  return __extension__ (__m128)(__v4sf){ __W, __X, __Y, __Z };
}

struct vec
{
union {
__m128 v;
float  e[4];
};

static const vec & zero()
{
static const vec v = _mm_set_ps(0, 0, 0, 0);
return v;
}

vec() {}
vec(const __m128 & a) : v(a) {}

operator const __m128&() const { return v; }
};

struct vec2
{
vec _v1;
vec _v2;

vec2() {}
vec2(const vec & a, const vec & b) : _v1(a), _v2(b) {}

static vec2 load(const float * a)
{
return vec2(
__builtin_ia32_loadups(&a[0]),
__builtin_ia32_loadups(&a[4]));
}

const vec & v1() const { return _v1; }
const vec & v2() const { return _v2; }
};

extern "C" {
int* _errno(void);
int  printf (const char*, ...);
}

inline bool test_assert( bool is_succeed, const char * file_name, int line_num
)
{
if ( !is_succeed )
{
printf("error: %s(%d)\n", file_name, line_num);
if ( *_errno() ) // LINE_A
{
printf("errno: %d\n", *_errno());
}
}

return is_succeed;
}

inline bool operator==(const vec & a, const vec & b)
{ return 0xf == __builtin_ia32_movmskps(__builtin_ia32_cmpeqps(a, b)); }

#define test(x, y) test_assert( (x)==(y), __FILE__, __LINE__ )

int main( int argc, char * argv[] )
{
__attribute__((aligned(16))) float data[] =
{ 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5 };

float * p = &data[2];
vec2 a;

a = vec2::load(p);

vec v1 = a.v1();
vec v2 = a.v2();
printf(
"v1: %f, %f, %f, %f\n"
"v2: %f, %f, %f, %f\n",
v1.e[0], v1.e[1], v1.e[2], v1.e[3],
v2.e[0], v2.e[1], v2.e[2], v2.e[3]);

test(_mm_set_ps(11, 12, 13, 14), a.v1()); // LINE_B
test(_mm_set_ps( 7,  8,  9, 10), a.v2()); // LINE_C

a._v1 = vec::zero();

test(_mm_set_ps(0, 0, 0, 0), a.v1()); // LINE_D

return 0;
}
-- end test code --

-- begin output --
v1: 14.00, 13.00, 12.00, 11.00
v2: 10.00, 9.00, 8.00, 0.00
error: test.cpp(92)
-- end output --


-- 
   Summary: The variable of SSE will be broken
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: normal
      Priority: P3
         Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yottui at yahoo dot co dot jp


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