June 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10225

           Summary: core.simd wrong codegen for XMM.STOUPS with __simd_sto
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@benjamin-thaut.de


--- Comment #0 from Benjamin Thaut <code@benjamin-thaut.de> 2013-06-01 03:05:09 PDT ---
For the follwing small test program:

import core.simd;
import std.stdio;

void main(string[] args)
{
    float[] value1 = [1.0f, 2.0f, 3.0f, 4.0f];
    float4 result = __simd(XMM.LODUPS, *cast(float4*)value1.ptr);
    result = __simd(XMM.ADDPS, result, result);
    __simd_sto(XMM.STOUPS, *cast(float4*)value1.ptr, result);
    writefln("%s", value1);
}

Dmd will generate the follwing assembly:
mov         rax,qword ptr [rbp-68h]
movups      xmm0,xmmword ptr [rax]
movaps      xmmword ptr [rbp-60h],xmm0
movdqa      xmm0,xmmword ptr [rbp-60h]
addps       xmm0,xmmword ptr [rbp-60h]
movaps      xmmword ptr [rbp-60h],xmm0

As you can clearly see the last instruction is a movaps but it should be a movups because XMM.STOUPS was given (unaligned store)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 03, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10225


Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |turkeyman@gmail.com


--- Comment #1 from Manu <turkeyman@gmail.com> 2013-06-03 03:02:18 PDT ---
(In reply to comment #0)
> For the follwing small test program:
> 
> import core.simd;
> import std.stdio;
> 
> void main(string[] args)
> {
>     float[] value1 = [1.0f, 2.0f, 3.0f, 4.0f];
>     float4 result = __simd(XMM.LODUPS, *cast(float4*)value1.ptr);
>     result = __simd(XMM.ADDPS, result, result);
>     __simd_sto(XMM.STOUPS, *cast(float4*)value1.ptr, result);
>     writefln("%s", value1);
> }
> 
> Dmd will generate the follwing assembly:
> mov         rax,qword ptr [rbp-68h]
> movups      xmm0,xmmword ptr [rax]
> movaps      xmmword ptr [rbp-60h],xmm0
> movdqa      xmm0,xmmword ptr [rbp-60h]
> addps       xmm0,xmmword ptr [rbp-60h]
> movaps      xmmword ptr [rbp-60h],xmm0
> 
> As you can clearly see the last instruction is a movaps but it should be a movups because XMM.STOUPS was given (unaligned store)

Indeed. Wrong opcode >_<
I never use unaligned vectors, so I missed it!
Haven't widely tested the unaligned bit of std.simd yet.

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