For whatever reason, the attached program, when compiled with the options
gcc-3.4 -msse2 -O0 test.c -o test
will crash. This is not the case if -O2 is specified or -march=i686.

However, I have a larger testcase (the program this came from) which will fail
regardless of optimization flags or -march. It seems that this problem only
happens when gcc is given complicated enough code.

A quick look at it with gdb shows:
Program received signal SIGSEGV, Segmentation fault.
0x080483b0 in _mm_srli_epi32 (__A={51539607552, 51539607564}, __B=31)
    at emmintrin.h:1261
1261    {
(gdb) up
#1  0x080483e3 in bar (x={4294967297, 4294967297}, y={4294967297, 4294967297})
    at test.c:8
8               return _mm_sub_epi32(x, _mm_srli_epi32(y, 31));
(gdb) print &x
$1 = (__v2di *) 0xbffffa00
(gdb) down
#0  0x080483b0 in _mm_srli_epi32 (__A={51539607552, 51539607564}, __B=31)
    at emmintrin.h:1261
1261    {
(gdb) print &__A
$2 = (__v2di *) 0xbffff9cc

This looks to me like the alignment has somehow gotten messed up.

-- 
           Summary: gcc produces bad (misaligned?) sse2 code
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: terpstra at ito dot tu-darmstadt dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-linux-gnu
  GCC host triplet: i386-linux-gnu
GCC target triplet: i386-linux-gnu


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

Reply via email to