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

* [Bug c++/17415] 3dNOW and gcc3.3 possible oddities
  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 ` fudje at phreaker dot net
  2004-09-13 11:23 ` fudje at phreaker dot net
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fudje at phreaker dot net @ 2004-09-13 11:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fudje at phreaker dot net  2004-09-13 11:07 -------
Created an attachment (id=7119)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7119&action=view)
Non-C++ Example

Not just in C++, assured.  The error is in the builtins.

An example in C pour vous.

-- 


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


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

* [Bug c++/17415] 3dNOW and gcc3.3 possible oddities
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fudje at phreaker dot net @ 2004-09-13 11:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fudje at phreaker dot net  2004-09-13 11:23 -------
(Follow-up to comment #1)
(Sorry about the bugspam)
This yields more or less the same effect:

$ gcc-3.3 -O3 -m3dnow -o 3dnow_test 3dnow-test.c
$ ./3dnow_test
a = [1 2]
b = [3 4]
mul
a = [1 0]
b = [3 4]
c = [3 8]

Oddly enough, in 3.5 we get a different result....

gcc-3.5, -O3 -m3dnow

a = [1 2]
b = [3 4]
mul
a = [nan 2]
b = [3 4]
c = [nan 8]

O0, 3dnow

a = [1 2]
b = [3 4]
mul
a = [1 nan]
b = [3 4]
c = [nan 8]

O1, 3dnow

a = [1 2]
b = [3 4]
mul
a = [1 nan]
b = [3 4]
c = [3 8]

O3, 3dnow, arch=athlon

a = [1 2]
b = [3 4]
mul
a = [nan 2]
b = [3 4]
c = [3 8]



-- 


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


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

* [Bug target/17415] 3dNOW and gcc3.3 possible oddities
  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 ` pinskia at gcc dot gnu dot org
  2004-12-19 15:05 ` steven at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-13 15:55 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |target


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


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

* [Bug target/17415] 3dNOW and gcc3.3 possible oddities
  2004-09-11  7:54 [Bug c++/17415] New: 3dNOW and gcc3.3 possible oddities plm at pcug dot org dot au
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-12-19 15:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2004-12-19 15:05 -------
With GCC4 (CVS HEAD) I can't compile the test case:  
  
t.cc:1: warning: specifying vector types with __attribute__ ((mode)) is  
deprecated  
t.cc:1: warning: use __attribute__ ((vector_size)) instead  
t.cc:1: error: mode 'V2SF' applied to inappropriate type  
t.cc: In function 'vec2f mul(const vec2f&, const vec2f&)':  
t.cc:26: error: '__builtin_ia32_pfmul' was not declared in this scope  
  
With gcc 3.3.4, I also get:  
t.cc: In function `vec2f mul(const vec2f&, const vec2f&)':  
t.cc:28: error: `__builtin_ia32_pfmul' undeclared (first use this function)  
t.cc:28: error: (Each undeclared identifier is reported only once for each  
   function it appears in.)  
  
For the C test case, I get: 
t.c: In function `mul': 
t.c:15: error: cast to union type from type not present in union 
 

-- 


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


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

* [Bug target/17415] 3dNOW and gcc3.3 possible oddities
  2004-09-11  7:54 [Bug c++/17415] New: 3dNOW and gcc3.3 possible oddities plm at pcug dot org dot au
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-15  8:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-15 08:17 -------
To fix the compiling C++/C example use the following code:
typedef float V2SF __attribute__((mode(V2SF)));

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|                            |i686-pc-linux-gnu (3dnow)
           Keywords|                            |wrong-code


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


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

* [Bug target/17415] 3dNOW and gcc3.3 possible oddities
  2004-09-11  7:54 [Bug c++/17415] New: 3dNOW and gcc3.3 possible oddities plm at pcug dot org dot au
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-15  8:19 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ssemmx


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


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

* [Bug target/17415] 3dNOW and gcc3.3 possible oddities
  2004-09-11  7:54 [Bug c++/17415] New: 3dNOW and gcc3.3 possible oddities plm at pcug dot org dot au
                   ` (5 preceding siblings ...)
  2005-01-15  8:19 ` pinskia at gcc dot gnu dot org
@ 2005-01-18  9:54 ` rth at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2005-01-18  9:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2005-01-18 09:52 -------


*** This bug has been marked as a duplicate of 19161 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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).