This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: optimization/8878: miscompilation with -O and SSE


Synopsis: miscompilation with -O and SSE

State-Changed-From-To: open->analyzed
State-Changed-By: reichelt
State-Changed-When: Wed Dec 11 06:08:13 2002
State-Changed-Why:
    Confirmed.
    
    Here's a cleaned-up testcase (which does not suffer from
    aliasing problems as the original one, where &c is casted):
    
    ----------------------------snip here-------------------------
    #include <stdio.h>
    
    typedef int v4sf __attribute__((mode(V4SF)));
    
    int main(void)
    {
        v4sf v = {1.0, 2.0, 3.0, 4.0};
        union { v4sf v; float f[4]; } u;
    
        u.v = __builtin_ia32_mulps(v,v);
    
        printf("%f %f %f %f\n", u.f[0], u.f[1], u.f[2], u.f[3]);
    
        return 0;
    }
    ----------------------------snip here-------------------------
    
    Compiling this with "gcc -O -msse" on a i686-pc-linux-gnu machine
    results in an executable that prints
    
       16.000000 0.000000 0.000000 0.000000
    
    instead of
    
       1.000000 4.000000 9.000000 16.000000
    
    as expeceted. Replacing "mulps" by "addps" will generate equally wrong results.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8878


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]