public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37809]  New: Incorrect code with MMX right shift __builtin_ia32_psradi
@ 2008-10-12  2:39 suckfish at ihug dot co dot nz
  2008-10-12  2:49 ` [Bug c/37809] " suckfish at ihug dot co dot nz
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: suckfish at ihug dot co dot nz @ 2008-10-12  2:39 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-04-29 15:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-12  2:39 [Bug c/37809] New: Incorrect code with MMX right shift __builtin_ia32_psradi suckfish at ihug dot co dot nz
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

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).