public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17415] New: 3dNOW and gcc3.3 possible oddities
@ 2004-09-11  7:54 plm at pcug dot org dot au
  2004-09-13 11:07 ` [Bug c++/17415] " fudje at phreaker dot net
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: plm at pcug dot org dot au @ 2004-09-11  7:54 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-01-18  9:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-11  7:54 [Bug c++/17415] New: 3dNOW and gcc3.3 possible oddities plm at pcug dot org dot au
2004-09-13 11:07 ` [Bug c++/17415] " fudje at phreaker dot net
2004-09-13 11:23 ` fudje at phreaker dot net
2004-09-13 15:55 ` [Bug target/17415] " pinskia at gcc dot gnu dot org
2004-12-19 15:05 ` steven at gcc dot gnu dot org
2005-01-15  8:17 ` pinskia at gcc dot gnu dot org
2005-01-15  8:19 ` pinskia at gcc dot gnu dot org
2005-01-18  9:54 ` rth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).