public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "julien dot pommier at insa-toulouse dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/21149] New: invalid code generation for _mm_movehl_ps SSE intrisinc
Date: Thu, 21 Apr 2005 13:07:00 -0000	[thread overview]
Message-ID: <20050421130742.21149.julien.pommier@insa-toulouse.fr> (raw)

The following code does generate wrong results when optimization is turned on :

#include <stdio.h>
#include <xmmintrin.h>

void pv(const char *s, __m128 v) {
  float *p = (float*)&v;
  printf("%s=[%g %g %g %g]\n", s,p[0],p[1],p[2],p[3]);
}

#define P(x) pv(#x,x)


static void plop(__m128 *Y) {
  __m128 zero = _mm_setzero_ps();
  __m128 foo = _mm_movehl_ps(zero, *Y);
  __m128 bar = _mm_movehl_ps(*Y, zero);
  P(*Y);P(foo);P(bar);
}

int main() {
  __m128 y=_mm_set_ps(-3,2,1,9);
  plop(&y); 
  return 0;
}

Here are some outputs:

> gcc-3.4 -O3 -Wall -W -msse  -o toto toto.c && ./toto
*Y=[9 1 2 -3]
foo=[0 0 9 1]
bar=[9 1 0 0]

> gcc-4.0 -g -O0 -Wall -W -msse -o toto toto.c && ./toto
*Y=[9 1 2 -3]
foo=[2 -3 0 0]
bar=[0 0 2 -3]   (this one is correct)

> gcc-4.0 -O3 -Wall -W -msse  -o toto toto.c && ./toto
*Y=[9 1 2 -3]
foo=[9 1 0 0]
bar=[0 0 2 -3]
(same output with gcc-4.1 from cvs)


Tested with:
gcc-3.4 (GCC) 3.4.4 20050314 (prerelease) (Debian 3.4.3-12)
gcc-4.0 (GCC) 4.0.0 20050410 (prerelease) (Debian 4.0-0pre10)
gcc (GCC) 4.0.0 20050418 (prerelease)
gcc (GCC) 4.1.0 20050421 (experimental)

-- 
           Summary: invalid code generation for _mm_movehl_ps SSE intrisinc
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: julien dot pommier at insa-toulouse dot fr
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


             reply	other threads:[~2005-04-21 13:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-21 13:07 julien dot pommier at insa-toulouse dot fr [this message]
2005-04-21 13:14 ` [Bug target/21149] " pinskia at gcc dot gnu dot org
2005-07-06 14:36 ` pinskia at gcc dot gnu dot org
2005-07-20 15:26 ` pinskia at gcc dot gnu dot org
2005-07-21 19:59 ` cvs-commit at gcc dot gnu dot org
2005-07-21 20:03 ` cvs-commit at gcc dot gnu dot org
2005-07-21 20:33 ` pinskia at gcc dot gnu dot org
2005-07-28 14:39 ` cvs-commit at gcc dot gnu dot org
2005-07-28 14:47 ` cvs-commit at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050421130742.21149.julien.pommier@insa-toulouse.fr \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).