public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "suckfish at ihug dot co dot nz" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/37809]  New: Incorrect code with MMX right shift __builtin_ia32_psradi
Date: Sun, 12 Oct 2008 02:39:00 -0000	[thread overview]
Message-ID: <bug-37809-2018@http.gcc.gnu.org/bugzilla/> (raw)

Bug on both trunk and 4.3.2 [for the latter, change psradi to psrad as the
builtin function name changed].

Compiling the following code with  -O2 -flax-vector-conversions -mmmx -msse
-msse2  generates incorrect code:


typedef int v2si __attribute__ ((vector_size (8)));
v2si foo (v2si x)
{
    x &= (v2si) 0xffffffffll;
    x = __builtin_ia32_psradi (x, 1);
    x &= (v2si) 0x80000000ll;
    return x;
}


The compile incorrectly assumes that bit 31 of the shift result always ends up
as zero:

foo:
        pxor    %xmm0, %xmm0
        ret


Presumeably, some optimiseration is incorrectly treating the v2si right shift
as a 64-bit right shift.

[It appears to me that both nonzero_bits1 and num_sign_bit_copies1 can
incorrectly optimise vector operation as if they were scalar ops, which is what
inspired this example, however, attempting to fix those did not fix this bug,
which makes me think the problem is elsewhere.]


-- 
           Summary: Incorrect code with MMX right shift
                    __builtin_ia32_psradi
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: suckfish at ihug dot co dot nz
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


             reply	other threads:[~2008-10-12  2:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-12  2:39 suckfish at ihug dot co dot nz [this message]
2008-10-12  2:49 ` [Bug c/37809] " suckfish at ihug dot co dot nz
2008-10-12 10:37 ` [Bug target/37809] [4.2/4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
2008-10-12 19:01 ` ubizjak at gmail dot com
2008-10-14  7:19 ` suckfish at ihug dot co dot nz
2008-10-17  6:37 ` ubizjak at gmail dot com
2008-10-17 22:20 ` [Bug middle-end/37809] " suckfish at ihug dot co dot nz
2008-10-22  3:31 ` mmitchel at gcc dot gnu dot org
2008-11-10  7:45 ` suckfish at ihug dot co dot nz
2008-11-10  9:11 ` uros at gcc dot gnu dot org
2008-11-10 10:46 ` [Bug middle-end/37809] [4.2/4.3 " uros at gcc dot gnu dot org
2008-11-10 12:23 ` uros at gcc dot gnu dot org
2008-11-10 12:25 ` ubizjak at gmail dot com
2009-04-29 15:21 ` pinskia 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=bug-37809-2018@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).