[Issue 10225] core.simd wrong codegen for XMM.STOUPS with __simd_sto

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 21 05:33:22 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=10225


yebblies <yebblies at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |SIMD, wrong-code
                 CC|                            |yebblies at gmail.com
           Severity|normal                      |critical


--- Comment #2 from yebblies <yebblies at gmail.com> 2013-11-22 00:33:18 EST ---
I think it's worse than that actually.

import core.simd;

__gshared float[] value1 = [1.0f, 2.0f, 3.0f, 4.0f];

void func();

void main(string[] args)
{
    float4 result = __simd(XMM.LODUPS, *cast(float4*)value1.ptr);
    result = __simd(XMM.ADDPS, result, result);
    __simd_sto(XMM.STOUPS, *cast(float4*)value1.ptr, result);
    func();
}

gives

mov     rax, qword ptr [_D5testx6value1Af+8H]   ; 0008 _ 48: 8B. 05,
00000008(rel)
movups  xmm0, xmmword ptr [rax]                 ; 000F _ 0F 10. 00
movaps  xmmword ptr [rbp-10H], xmm0             ; 0012 _ 0F 29. 45, F0
movdqa  xmm1, xmmword ptr [rbp-10H]             ; 0016 _ 66: 0F 6F. 4D, F0
addps   xmm1, xmmword ptr [rbp-10H]             ; 001B _ 0F 58. 4D, F0
movaps  xmmword ptr [rbp-10H], xmm1             ; 001F _ 0F 29. 4D, F0

So the value is loaded from value1, then stored into a stack slot, then loaded,
added, and stored back into the stack slot.  The result is never written back
into value1.

With -O the whole thing is dropped, despite the call to func() which could
easily access value1.  Elevating to critical.

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


More information about the Digitalmars-d-bugs mailing list