Bug 7396 - ix86: cmpgt_ss, cmpge_ss, cmpngt_ss, and cmpnge_ss SSE intriniscs are broken
ix86: cmpgt_ss, cmpge_ss, cmpngt_ss, and cmpnge_ss SSE intriniscs are broken
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: target
3.2
: P3 normal
: ---
Assigned To: Jan Hubicka
: wrong-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2002-07-24 12:16 UTC by Andreas Jaeger
Modified: 2003-07-25 17:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Jaeger 2002-07-24 12:16:01 UTC
The cmpgt_ss (and also the others) intrinsic copies the value
from the wrong argument.  The example program outputs:
$ ./a.out 
Return values: -1 6.000000 2.000000 1.000000
Aborted

but the correct value is:
-1  3.000000 4.000000 1.000000
The last three values should come from m1.

Btw. cmplt_ss works correctly, but it seems that the arguments are switched in the intrinsic.

Release:
GCC 3.1, GCC 3.2 CVS

Environment:
i686-linux-gnu

How-To-Repeat:
#include <xmmintrin.h>
#include <stdlib.h>
#include <stdio.h>

typedef union
{
  __m128 m;
  float f[4];
  double d[2];
  int i[4];
} munion;

int
test_it (void)
{
  __m128 m1, m2;
  munion res;

  m1 = _mm_set_ps (1.0f, 4.0f, 3.0f, 8.0f);
  m2 = _mm_set_ps (1.0f, 2.0f, 6.0f, 4.0f);
  
  res.m = _mm_cmpgt_ss (m1, m2);

  printf ("Return values: %d %f %f %f\n",
	  res.i[0], res.f[1], res.f[2], res.f[3]);
  
  if (res.i[0] != -1)
    abort ();
  if (res.f[1] != 3.0f)
    abort ();
  if (res.f[2] != 4.0f)
    abort ();
  if (res.f[3] != 1.0f)
    abort ();

  return 0;
}

int
main (void)
{
  return test_it ();
}
Comment 1 Jan Hubicka 2002-10-15 13:14:39 UTC
Responsible-Changed-From-To: unassigned->hubicka
Responsible-Changed-Why: mine.
Comment 2 Jan Hubicka 2002-10-16 10:30:50 UTC
State-Changed-From-To: open->closed
State-Changed-Why: * i386.c (builtin_description):Drop cmpg[te]s[sd].
            * xmmintrin.h (__mm_cmpg[te]_s[sd]): Rewrite using
            swapped alternative.