[Issue 9200] New: Wrong SIMD cod generated

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 23 10:38:27 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9200

           Summary: Wrong SIMD cod generated
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jerro.public at gmail.com


--- Comment #0 from jerro.public at gmail.com 2012-12-23 10:38:26 PST ---
When compiled with no flags, the following program gives wrong results:

import std.stdio;
import core.simd;

double2 * v(double* a)
{
    return cast(double2*)a;
}

void main()
{
    double2 a;
    auto p = cast(double*) &a;
    p[0] = 1;
    p[1] = 2;

    double2 b = v(p)[0];
    v(p)[0] = b;

    writeln(p[0 .. 2]); // prints [1, 0]
}

Disassembly of the relevant part of the code:


call   426344 <_D3tmp1vFPdZPNhG2d>
movapd xmm0,XMMWORD PTR [rax]
movapd XMMWORD PTR [rbp-0x10],xmm0
movapd xmm1,XMMWORD PTR [rbp-0x10]
movsd  QWORD PTR [rbp-0x40],xmm1        ; should be movapd
mov    rdi,QWORD PTR [rbp-0x20]
call   426344 <_D3tmp1vFPdZPNhG2d>
movsd  xmm1,QWORD PTR [rbp-0x40]        ; should be movapd
movapd XMMWORD PTR [rax],xmm1

This happens with both DMD 2.060 and the latest version of 2.061 from github.
It doesn't happen if I use either -O flag or -inline. It doesn't happen with
LDC or GDC.

I have only tested this on linux.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list