This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17415] New: 3dNOW and gcc3.3 possible oddities
- From: "plm at pcug dot org dot au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Sep 2004 07:54:29 -0000
- Subject: [Bug c++/17415] New: 3dNOW and gcc3.3 possible oddities
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I was mucking around with 3dNOW and gcc3.3, and I think I've found a bug. As you
can see, the result in vector 'c' is correct, but the input vector 'a' has been
damaged.
$ cat test.cc
#include <stdio.h>
typedef int V2SF __attribute__((mode(V2SF)));
struct vec2f {
union {
V2SF vec;
struct {
float x;
float y;
};
};
vec2f(){};
vec2f( const vec2f& v )
: vec(v.vec)
{};
vec2f( const V2SF& v )
: vec(v)
{};
vec2f( float x, float y)
: x(x), y(y)
{};
};
inline vec2f mul( const vec2f &a, const vec2f &b )
{ return vec2f( __builtin_ia32_pfmul(a.vec,b.vec) ); }
int main()
{
vec2f a( 1.0, 2.0 );
vec2f b( 3.0, 4.0 );
printf( "a = %g %g\n", a.x, a.y );
printf( "b = %g %g\n", b.x, b.y );
printf( "mul\n" );
vec2f c = mul(a,b);
printf( "a = %g %g\n", a.x, a.y );
printf( "b = %g %g\n", b.x, b.y );
printf( "c = %g %g\n", c.x, c.y );
return 0;
};
$ g++ -o test -O3 -fno-strict-aliasing -march=athlon-xp
-mmmx -msse -m3dnow test.cc
$ ./test
a = 1 2
b = 3 4
mul
a = 1 0
b = 3 4
c = 3 8
One of the local users had a look at this any said
with everything except -O3 we get:
./test
a = 1 2
b = 3 4
mul
a = 1 nan
b = 3 4
c = 3 8
Very interesting.
with -march=i586:
./test
a = 1 2
b = 3 4
mul
a = 0 0
b = 3 4
c = 3 8
-march=[i486,i386]:
a = nan 2
Combinations of the other -m flags don't seem to make a difference,
(except if you remove -m3dnow, where it fails at compile, oddly
enough due to the lack of a __builtin_ia32_pfmul function.)
That's some very strange behaivour. Sorry I can't help..
It's quite possible that I'm missing something obvious here. The manual is a bit
sparse on this matter. Especially how to get data into and out of the vectors.
--
Summary: 3dNOW and gcc3.3 possible oddities
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: plm at pcug dot org dot au
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17415