[Issue 10226] core.simd inefficient codegen

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Mar 13 12:41:51 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=10226

Martin Nowak <code at dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code at dawg.eu

--- Comment #11 from Martin Nowak <code at dawg.eu> ---
cat > bug.d << CODE
import core.simd;

alias vec = __vector(double[2]);

void storeUnaligned(ref vec a, in ref vec val)
{
    __simd_sto(XMM.STOUPD, a, val);
}

void test(ref vec a, in vec b)
{
    __simd_sto(XMM.STOUPD, a, b * b); // works
    immutable tmp = b * b;
    __simd_sto(XMM.STOUPD, a, tmp); // dips stack
    storeUnaligned(a, tmp); // dips stack
}
CODE
dmd -c -O -release -inline bug
----
        mulpd   xmm1, xmm3                              ; 000C _ 66: 0F 59. CB
        movapd  xmmword ptr [rsp], xmm1                 ; 0010 _ 66: 0F 29. 0C
24
        movdqa  xmm2, xmmword ptr [rsp]                 ; 0015 _ 66: 0F 6F. 14
24
        movupd  xmmword ptr [rdi], xmm2                 ; 001A _ 66: 0F 11. 17
----
Turns out that dmd's codegen is almost prohibitively inefficient, the
intermediate value unnecessarily get pushed to the stack.

--


More information about the Digitalmars-d-bugs mailing list