public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mathog at caltech dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/46716] New: bad code generated with -mno-sse2 -m64
Date: Tue, 30 Nov 2010 00:59:00 -0000	[thread overview]
Message-ID: <bug-46716-4@http.gcc.gnu.org/bugzilla/> (raw)

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

           Summary: bad code generated with -mno-sse2 -m64
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mathog@caltech.edu


The following small program generates incorrect output when compiled with
the flags -mno-sse2 -m64 on a 64 bit system.  Output is correct for -m32
or -msse2 -m64.  The problem manifests as the lower double of the second
parameter passed into test() being replaced by the value of the second double
from the first parameter.

% cat /etc/release
Mandriva Linux release 2010.0 (Official) for x86_64
% cat /proc/cpuinfo | head -10
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 33
model name      : Dual Core AMD Opteron(tm) Processor 280
stepping        : 2
cpu MHz         : 1000.000
cache size      : 1024 KB
physical id     : 0
siblings        : 2
% gcc --version
gcc (GCC) 4.4.1

example:

% gcc -msse -mno-sse2 -I. -m64   -o foo gccprob2.c
% ./foo
s1      1.000000 2.000000
test s1 1.000000 2.000000
test s2 2.000000 2.000000
% gcc -msse -mno-sse2 -I. -m32   -o foo gccprob2.c
OR
% gcc -msse -msse2 -I. -m64   -o foo gccprob2.c
s1      1.000000 2.000000
test s1 1.000000 2.000000
test s2 1.000000 2.000000

*************************************************
#include <stdio.h> /* for printf */
typedef double    __m128d __attribute__ ((__vector_size__ (16),
__may_alias__));
typedef union
{
  __m128d x;
  double a[2];
} union128d;
#define EMM_FLT8(a)    ((double *)&(a))

void test ( __m128d s1, __m128d s2)
{
printf("test s1 %lf %lf\n",EMM_FLT8(s1)[0],EMM_FLT8(s1)[1]);
printf("test s2 %lf %lf\n",EMM_FLT8(s2)[0],EMM_FLT8(s2)[1]);
}

int main (void)
{
__attribute__ ((aligned (16)))  union128d s1;
  s1.a[0] = 1.0;
  s1.a[1] = 2.0;
printf("s1      %lf %lf\n",s1.a[0],s1.a[1]);
  test (s1.x, s1.x);
}
**************************************************


             reply	other threads:[~2010-11-30  0:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30  0:59 mathog at caltech dot edu [this message]
2010-11-30 10:01 ` [Bug target/46716] [4.3/4.4/4.5/4.6 Regression] " jakub at gcc dot gnu.org
2010-11-30 12:36 ` rguenth at gcc dot gnu.org
2010-11-30 12:59 ` jakub at gcc dot gnu.org
2010-11-30 13:49 ` hjl.tools at gmail dot com
2010-11-30 17:50 ` mathog at caltech dot edu
2010-12-05 12:03 ` rguenth at gcc dot gnu.org
2011-01-03 20:28 ` rguenth at gcc dot gnu.org
2011-06-27 13:40 ` [Bug target/46716] [4.3/4.4/4.5/4.6/4.7 Regression] wrong " rguenth at gcc dot gnu.org
2012-03-02 14:36 ` [Bug target/46716] [4.4/4.5/4.6/4.7 " ubizjak at gmail dot com
2012-03-02 17:04 ` [Bug target/46716] [4.4/4.5/4.6/4.7/4.8 " uros at gcc dot gnu.org
2012-03-13 14:08 ` [Bug target/46716] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org
2012-07-02 12:10 ` rguenth at gcc dot gnu.org
2013-04-12 15:16 ` [Bug target/46716] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
2014-01-23  7:12 ` law at redhat dot com

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=bug-46716-4@http.gcc.gnu.org/bugzilla/ \
    --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).