This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37809] New: Incorrect code with MMX right shift __builtin_ia32_psradi
- From: "suckfish at ihug dot co dot nz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Oct 2008 02:37:42 -0000
- Subject: [Bug c/37809] New: Incorrect code with MMX right shift __builtin_ia32_psradi
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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