public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kretz at kde dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/49133] New: [4.6 Regression] modification of aliased __m128d miscompiles
Date: Mon, 23 May 2011 22:20:00 -0000	[thread overview]
Message-ID: <bug-49133-4@http.gcc.gnu.org/bugzilla/> (raw)

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

           Summary: [4.6 Regression] modification of aliased __m128d
                    miscompiles
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kretz@kde.org


Compile the following testcase with "g++ -msse2 -O2"

#include <xmmintrin.h>

typedef double double_a __attribute__((__may_alias__));

struct V
{
    __m128d data;
};

int main()
{
    V a;
    __m128d b;
    b      = _mm_set_pd(1., 0.);
    a.data = _mm_set_pd(1., 0.);
    a.data = _mm_add_pd(a.data, _mm_and_pd(_mm_cmpeq_pd(a.data,
_mm_set1_pd(0.)), _mm_set1_pd(2.)));
    reinterpret_cast<double_a *>(&a.data)[1] += 1.;
    b = _mm_add_pd(b, _mm_and_pd(_mm_cmpeq_pd(b, _mm_set1_pd(0.)),
_mm_set1_pd(1.)));
    b = _mm_add_pd(b, _mm_and_pd(_mm_cmpeq_pd(b, _mm_set1_pd(1.)),
_mm_set1_pd(1.)));
    if (_mm_movemask_pd(_mm_cmpeq_pd(a.data, b)) != 0x3) {
        abort();
    }
    return 0;
}

GCC 4.6.[01] calculate the correct values for a.data[0] and a.data[1] but fail
to combine the results correctly. I.e. the resulting shufpd $0x1 is wrong. GCC
4.5.x uses unpacklpd, which gives the correct result, but emits unnecessary
stores to the stack.


             reply	other threads:[~2011-05-23 22:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23 22:20 kretz at kde dot org [this message]
2011-05-24  8:54 ` [Bug target/49133] [4.6/4.7 " ubizjak at gmail dot com
2011-05-24 10:36 ` kretz at kde dot org
2011-05-24 11:48 ` ubizjak at gmail dot com
2011-05-24 11:54 ` ubizjak at gmail dot com
2011-05-24 15:58 ` uros at gcc dot gnu.org
2011-05-24 18:58 ` uros at gcc dot gnu.org
2011-05-25  8:15 ` jakub at gcc dot gnu.org
2011-05-25 13:47 ` uros at gcc dot gnu.org
2011-05-25 16:43 ` uros at gcc dot gnu.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=bug-49133-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).