www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10225] New: core.simd wrong codegen for XMM.STOUPS with __simd_sto

reply d-bugmail puremagic.com writes:
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



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: -------
Jun 01 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10225


Manu <turkeyman gmail.com> changed:

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




 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: -------
Jun 03 2013