[Issue 10226] New: core.simd bad codegen
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jun 1 03:12:12 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10226
Summary: core.simd bad codegen
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: code at benjamin-thaut.de
--- Comment #0 from Benjamin Thaut <code at benjamin-thaut.de> 2013-06-01 03:12:12 PDT ---
The following testcode:
import core.simd;
import std.stdio;
void main(string[] args)
{
float[] value1 = [1.0f, 2.0f, 3.0f, 4.0f];
float4 result = __simd(XMM.LODAPS, *cast(float4*)value1.ptr);
result = __simd(XMM.ADDPS, result, result);
__simd_sto(XMM.STOAPS, *cast(float4*)value1.ptr, result);
writefln("%s", value1);
}
Will produce the following assembly
1 mov rax,qword ptr [rbp-68h]
2 movaps xmm0,xmmword ptr [rax]
3 movaps xmmword ptr [rbp-60h],xmm0
4 movdqa xmm0,xmmword ptr [rbp-60h]
5 addps xmm0,xmmword ptr [rbp-60h]
6 movaps xmmword ptr [rbp-60h],xmm0
7 movdqa xmm0,xmmword ptr [rbp-60h]
8 mov rax,qword ptr [rbp-68h]
9 movaps xmmword ptr [rax],xmm0
The instructions 3 and 4 are completely useless, as well as the instructions 6
and 7. Instruction 8 has no effect because RAX already contains that value.
Ideally the assembly should look as follows:
1 mov rax,qword ptr [rbp-68h]
2 movaps xmm0,xmmword ptr [rax]
5 addps xmm0,xmmword ptr [rbp-60h]
9 movaps xmmword ptr [rax],xmm0
This is a huge problem because SIMD does only start to get effective if you
stay within the xmm registers as long as possible.
tested with dmd 2.063
--
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