Slow performance compared to C++, ideas?

David Nadlinger see at klickverbot.at
Sat Jun 1 03:21:53 PDT 2013


On Friday, 31 May 2013 at 15:02:00 UTC, bearophile wrote:
> Thanks to Kenji the latest dmd 2.063 solves part of this 
> problem:
> http://d.puremagic.com/issues/show_bug.cgi?id=2356
>
> Maybe this improvement is not yet in LDC/GDC.

Regarding static array initialization from literals, yes, that 
change isn't in 2.062.

However, what pains me a bit is that LDC does even manage to 
remove the dynamic array allocation after the fact:

---
__D9raytracer4Vec36__ctorMFxfZS9raytracer4Vec3:
	movss	DWORD PTR [RSP - 12], XMM0
	movss	DWORD PTR [RSP - 8], XMM0
	movss	DWORD PTR [RSP - 4], XMM0
	mov	EAX, DWORD PTR [RSP - 4]
	mov	DWORD PTR [RDI + 8], EAX
	mov	RAX, QWORD PTR [RSP - 12]
	mov	QWORD PTR [RDI], RAX
	mov	RAX, RDI
	ret
---

It just happens too late in the optimizer pipeline for the 
temporary memcpy to go away. Re-running the IR through the LLVM 
optimizer then produces this:

---
__D9raytracer4Vec36__ctorMFxfZS9raytracer4Vec3:
	movss	DWORD PTR [RDI], XMM0
	movss	DWORD PTR [RDI + 4], XMM0
	movss	DWORD PTR [RDI + 8], XMM0
	mov	RAX, RDI
	ret
---

  — David


More information about the Digitalmars-d mailing list