(The same phenomenon happens in 4.2 subversion alpha.)

Incorrect code is generated when using -ftree-vectorize on the SSE2 Pentium 4
target. (The same code works on the AMD64 64-bit target.)

See attached source code.

$ gcc -O2 -Wall -march=pentium4 -mfpmath=sse -ftree-vectorize
-ftree-vectorizer-verbose=1 gcc_plantage2.c -o ./gcc_plantage2
$ ./gcc_plantage2
will segfault (the same program works perfectly without -ftree-vectorize).

The segfault appears at the second movapd instruction:

        movapd  .LC0, %xmm0
.L17:
        movapd  %xmm0, (%eax)
        addl    $1, %edx
        addl    $16, %eax
        cmpl    %edx, %ebx
        ja      .L17

%eax is at this point equal to 4 modulo 16, which results in a segmentation
fault, since movapd assumes 16-byte alignment.


-- 
           Summary: wrong alignment or incorrect address computation in
                    vectorized code on Pentium 4 SSE
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: David dot Monniaux at ens dot fr
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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

Reply via email to