optimization/8878: miscompilation with -O and SSE

reichelt@igpm.rwth-aachen.de reichelt@igpm.rwth-aachen.de
Wed Dec 11 06:08:00 GMT 2002


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



More information about the Gcc-prs mailing list