Jump to page: 1 233  
Page
Thread overview
dmd codegen improvements
Aug 18, 2015
Walter Bright
Aug 18, 2015
Etienne Cimon
Aug 18, 2015
Etienne Cimon
Aug 18, 2015
Walter Bright
Aug 18, 2015
Jacob Carlborg
Aug 18, 2015
Walter Bright
Aug 18, 2015
welkam
Aug 18, 2015
Walter Bright
Aug 19, 2015
Jacob Carlborg
Aug 19, 2015
Dmitry Olshansky
Aug 19, 2015
Jacob Carlborg
Aug 20, 2015
Jonathan M Davis
Aug 19, 2015
Dmitry Olshansky
Aug 19, 2015
Jacob Carlborg
Aug 18, 2015
Vladimir Panteleev
Aug 18, 2015
Dicebot
Aug 19, 2015
ChangLong
Aug 18, 2015
Joakim
Aug 18, 2015
anonymous
Aug 18, 2015
Joakim
Aug 18, 2015
Temtaime
Aug 18, 2015
Jacob Carlborg
Aug 18, 2015
deadalnix
Aug 18, 2015
H. S. Teoh
Aug 18, 2015
Walter Bright
Aug 18, 2015
deadalnix
Aug 18, 2015
Walter Bright
Aug 18, 2015
deadalnix
Aug 18, 2015
Walter Bright
Aug 18, 2015
deadalnix
Aug 18, 2015
Walter Bright
Aug 18, 2015
deadalnix
Aug 19, 2015
Dmitry Olshansky
Aug 19, 2015
Walter Bright
Aug 19, 2015
deadalnix
Aug 18, 2015
H. S. Teoh
Aug 18, 2015
Walter Bright
Aug 18, 2015
H. S. Teoh
Aug 18, 2015
Walter Bright
Aug 19, 2015
Ivan Kazmenko
Aug 19, 2015
Walter Bright
Aug 19, 2015
Walter Bright
Aug 21, 2015
H. S. Teoh
Aug 21, 2015
Walter Bright
Aug 21, 2015
H. S. Teoh
Aug 21, 2015
Walter Bright
Aug 21, 2015
jmh530
Aug 21, 2015
H. S. Teoh
Aug 21, 2015
Kagamin
Aug 21, 2015
Iain Buclaw
Aug 21, 2015
Kagamin
Aug 21, 2015
Ivan Kazmenko
Aug 21, 2015
H. S. Teoh
Aug 21, 2015
rsw0x
Aug 21, 2015
Jonathan M Davis
Aug 19, 2015
Walter Bright
Aug 18, 2015
Iain Buclaw
Aug 23, 2015
Martin Nowak
Aug 27, 2015
Bruno Medeiros
Aug 27, 2015
Jonathan M Davis
Aug 18, 2015
Vladimir Panteleev
Aug 23, 2015
Vladimir Panteleev
Aug 23, 2015
H. S. Teoh
Aug 23, 2015
Vladimir Panteleev
Aug 23, 2015
H. S. Teoh
Aug 23, 2015
Iain Buclaw
Aug 23, 2015
Joakim
Aug 23, 2015
Walter Bright
Aug 23, 2015
Liam McSherry
Aug 23, 2015
Iain Buclaw
Aug 23, 2015
deadalnix
Aug 23, 2015
Walter Bright
Aug 28, 2015
Shachar Shemesh
Aug 28, 2015
Temtaime
Aug 28, 2015
Dmitry Olshansky
Aug 28, 2015
Temtaime
Aug 28, 2015
Temtaime
Aug 28, 2015
Dmitry Olshansky
Aug 28, 2015
Jack Stouffer
Aug 28, 2015
Adam D. Ruppe
Aug 28, 2015
Dmitry Olshansky
Aug 28, 2015
Walter Bright
Aug 29, 2015
Dmitry Olshansky
Aug 29, 2015
Walter Bright
Aug 29, 2015
Iain Buclaw
Aug 28, 2015
Adam D. Ruppe
Aug 28, 2015
Walter Bright
Aug 28, 2015
H. S. Teoh
Aug 28, 2015
rsw0x
Aug 28, 2015
deadalnix
Aug 28, 2015
Walter Bright
Aug 28, 2015
deadalnix
Aug 29, 2015
rsw0x
Aug 29, 2015
jmh530
Aug 29, 2015
Walter Bright
Aug 29, 2015
Rikki Cattermole
Aug 29, 2015
deadalnix
Aug 29, 2015
Rikki Cattermole
Aug 29, 2015
Walter Bright
Aug 29, 2015
Paolo Invernizzi
Aug 29, 2015
Casual D user
Aug 29, 2015
welkam
Aug 29, 2015
cym13
Aug 29, 2015
Laeeth Isharc
Aug 29, 2015
Laeeth Isharc
Aug 29, 2015
jmh530
Aug 30, 2015
Adam D. Ruppe
Aug 30, 2015
Adam D. Ruppe
Sep 02, 2015
Walter Bright
Sep 03, 2015
Laeeth Isharc
Sep 03, 2015
Adam D. Ruppe
Sep 03, 2015
Walter Bright
Sep 03, 2015
deadalnix
Sep 03, 2015
Iain Buclaw
Sep 03, 2015
deadalnix
Sep 03, 2015
deadalnix
Sep 04, 2015
rsw0x
Sep 04, 2015
rsw0x
Sep 04, 2015
rsw0x
Sep 04, 2015
deadalnix
Sep 05, 2015
Manu
Sep 04, 2015
deadalnix
Sep 04, 2015
Manu
Sep 04, 2015
rsw0x
Sep 04, 2015
Luís Marques
Sep 05, 2015
Walter Bright
Sep 05, 2015
Manu
Sep 05, 2015
Iain Buclaw
Sep 05, 2015
Walter Bright
Sep 05, 2015
Adam D. Ruppe
Sep 05, 2015
Walter Bright
Sep 05, 2015
Manu
Sep 06, 2015
Walter Bright
Sep 06, 2015
Jacob Carlborg
Sep 06, 2015
Manu
Sep 07, 2015
Walter Bright
Sep 06, 2015
Iain Buclaw
Oct 20, 2015
Tobias Müller
Sep 04, 2015
jmh530
Sep 04, 2015
Laeeth Isharc
Sep 03, 2015
Jacob Carlborg
Sep 03, 2015
Adam D. Ruppe
Sep 03, 2015
Adam D. Ruppe
Sep 03, 2015
deadalnix
Sep 04, 2015
Jacob Carlborg
Sep 04, 2015
rsw0x
Sep 04, 2015
Jacob Carlborg
Sep 06, 2015
Kagamin
Sep 07, 2015
Jacob Carlborg
Sep 03, 2015
Manu
Sep 03, 2015
Walter Bright
Aug 30, 2015
Laeeth Isharc
Sep 03, 2015
Laeeth Isharc
Sep 03, 2015
H. S. Teoh
Sep 03, 2015
Walter Bright
Sep 03, 2015
deadalnix
Sep 03, 2015
Walter Bright
Sep 02, 2015
Walter Bright
Sep 02, 2015
Iain Buclaw
Sep 03, 2015
Laeeth Isharc
Sep 03, 2015
Walter Bright
Sep 03, 2015
H. S. Teoh
Sep 03, 2015
Walter Bright
Sep 03, 2015
Walter Bright
Sep 03, 2015
Adam D. Ruppe
Sep 03, 2015
Dmitry Olshansky
Sep 03, 2015
Jacob Carlborg
Sep 03, 2015
Walter Bright
Sep 03, 2015
David Nadlinger
Sep 03, 2015
Walter Bright
Sep 04, 2015
David Nadlinger
Sep 03, 2015
Walter Bright
Sep 02, 2015
Walter Bright
Sep 16, 2015
Bruno Medeiros
Sep 17, 2015
Mike Parker
Sep 17, 2015
Bruno Medeiros
Sep 17, 2015
Bruno Medeiros
Sep 17, 2015
Kagamin
Sep 17, 2015
jmh530
Sep 01, 2015
Kagamin
Sep 01, 2015
Jonathan M Davis
Sep 03, 2015
Laeeth Isharc
Sep 04, 2015
Jonathan M Davis
Sep 04, 2015
Laeeth Isharc
Sep 16, 2015
Bruno Medeiros
Sep 16, 2015
Walter Bright
Sep 17, 2015
Joakim
Sep 17, 2015
Bruno Medeiros
Sep 17, 2015
Laeeth Isharc
Aug 18, 2015
Walter Bright
Aug 18, 2015
Vladimir Panteleev
Aug 18, 2015
Vladimir Panteleev
Aug 18, 2015
Walter Bright
Aug 18, 2015
Walter Bright
Aug 18, 2015
Vladimir Panteleev
Aug 19, 2015
Dmitry Olshansky
Aug 19, 2015
qznc
Aug 19, 2015
rsw0x
Aug 18, 2015
ponce
Aug 18, 2015
Walter Bright
Aug 18, 2015
Ivan Kazmenko
Aug 18, 2015
rsw0x
Aug 18, 2015
rsw0x
Aug 18, 2015
Walter Bright
Aug 18, 2015
Walter Bright
Aug 18, 2015
Walter Bright
Aug 18, 2015
rsw0x
Aug 18, 2015
Meta
Aug 18, 2015
rsw0x
Aug 19, 2015
Meta
Aug 19, 2015
rsw0x
Aug 18, 2015
H. S. Teoh
Aug 19, 2015
Dmitry Olshansky
Aug 19, 2015
Dmitry Olshansky
Aug 19, 2015
Dmitry Olshansky
Aug 19, 2015
ponce
Aug 19, 2015
ponce
Aug 19, 2015
Dmitry Olshansky
Aug 19, 2015
deadalnix
Aug 19, 2015
jmh530
Aug 19, 2015
deadalnix
Aug 21, 2015
deadalnix
Aug 21, 2015
deadalnix
Aug 22, 2015
Walter Bright
Aug 22, 2015
H. S. Teoh
Aug 22, 2015
deadalnix
Aug 22, 2015
Iain Buclaw
Aug 27, 2015
Bruno Medeiros
Aug 27, 2015
John Colvin
Aug 28, 2015
Daniel Murphy
Aug 28, 2015
Bruno Medeiros
Aug 18, 2015
deadalnix
Aug 18, 2015
rsw0x
Aug 19, 2015
anonymous
Aug 19, 2015
Walter Bright
Aug 19, 2015
anonymous
Aug 19, 2015
Walter Bright
Aug 19, 2015
Iain Buclaw
Aug 19, 2015
Walter Bright
Aug 19, 2015
Jacob Carlborg
Aug 19, 2015
Walter Bright
Aug 19, 2015
Paulo Pinto
Aug 19, 2015
deadalnix
Aug 19, 2015
Iain Buclaw
Aug 20, 2015
Jacob Carlborg
Aug 19, 2015
tsbockman
Aug 28, 2015
tsbockman
Aug 29, 2015
H. S. Teoh
Aug 29, 2015
tsbockman
Aug 19, 2015
Timon Gehr
Aug 20, 2015
welkam
Aug 24, 2015
ixid
Aug 24, 2015
jmh530
Aug 24, 2015
ixid
Aug 24, 2015
Isaac Gouy
Aug 24, 2015
ixid
Aug 24, 2015
Isaac Gouy
Aug 29, 2015
Daniel N
Aug 29, 2015
Temtaime
Aug 29, 2015
Adam D. Ruppe
Aug 29, 2015
Temtaime
Aug 29, 2015
David Nadlinger
Aug 29, 2015
H. S. Teoh
Aug 29, 2015
Adam D. Ruppe
Aug 29, 2015
Jonathan M Davis
Aug 29, 2015
Timon Gehr
Aug 30, 2015
Jonathan M Davis
Aug 30, 2015
Adam D. Ruppe
Aug 30, 2015
rsw0x
Aug 30, 2015
Adam D. Ruppe
Aug 30, 2015
Iain Buclaw
Sep 05, 2015
Dmitry Olshansky
Sep 13, 2015
BBasile
Sep 13, 2015
ponce
Sep 13, 2015
Martin Nowak
Sep 13, 2015
BBasile
Sep 13, 2015
Martin Nowak
August 18, 2015
Martin ran some benchmarks recently that showed that ddmd compiled with dmd was about 30% slower than when compiled with gdc/ldc. This seems to be fairly typical.

I'm interested in ways to reduce that gap.

There are 3 broad kinds of optimizations that compilers do:

1. source translations like rewriting x*2 into x<<1, and function inlining

2. instruction selection patterns like should one generate:

    SETC AL
    MOVZ EAX,AL

or:
    SBB EAX
    NEG EAX

3. data flow analysis optimizations like constant propagation, dead code elimination, register allocation, loop invariants, etc.

Modern compilers (including dmd) do all three.

So if you're comparing code generated by dmd/gdc/ldc, and notice something that dmd could do better at (1, 2 or 3), please let me know. Often this sort of thing is low hanging fruit that is fairly easily inserted into the back end.

For example, recently I improved the usage of the SETcc instructions.

https://github.com/D-Programming-Language/dmd/pull/4901
https://github.com/D-Programming-Language/dmd/pull/4904

A while back I improved usage of BT instructions, the way switch statements were implemented, and fixed integer divide by a constant with multiply by its reciprocal.
August 18, 2015
On Tuesday, 18 August 2015 at 10:45:49 UTC, Walter Bright wrote:
> So if you're comparing code generated by dmd/gdc/ldc, and notice something that dmd could do better at (1, 2 or 3), please let me know. Often this sort of thing is low hanging fruit that is fairly easily inserted into the back end.

I think someone mentioned how other compilers unroll loops at more than 2 levels.

Other than that, there was a recent Java vs D thread which showed it orders of magnitude faster on vtable calls. So I think the most amazing feature would be to allow profiling & sampling to compile with samples and select which functions to inline or do some magic around vtable pointers like what Java is doing.

Finally, I'm going to write this down here and haven't had time to look more into it but I've never been able to compile Botan with optimizations on DMD64 Win64 VS2013 (https://github.com/etcimon/botan), it's really strange having a crypto library that you can't optimize, building -O -g also gives me a ccog.c ICE error. I think it might be something about `asm pure` that uses some locals, does that eliminate the function call parameters?
August 18, 2015
On Tuesday, 18 August 2015 at 10:45:49 UTC, Walter Bright wrote:
> So if you're comparing code generated by dmd/gdc/ldc, and notice something that dmd could do better at (1, 2 or 3), please let me know. Often this sort of thing is low hanging fruit that is fairly easily inserted into the back end.

Hi,

From my experience reducing regressions, I have noticed that backend changes in general have a very high chance of introducing code generation regressions. Codegen bugs are nasty: they are occasionally difficult to reduce, and since software is rarely tested with its "release" build, have a habit of sneaking into published releases of otherwise bug-free software.

IIRC, I have had three releases affected by optimization/inlining DMD bugs (two of Digger and one of RABCDAsm). These do not speak well for D when end-users ask me what the cause of the bug is, and I have to say "Yeah, it's a bug in the official D compiler".

I think stability of the DMD backend is a goal of much higher value than the performance of the code it emits. DMD is never going to match the code generation quality of LLVM and GCC, which have had many, many man-years invested in them. Working on DMD optimizations is essentially duplicating this work, and IMHO I think it's not only a waste of time, but harmful to D because of the risk of regressions.

I suggest that we revamp the compiler download page again. The lead should be a "select your compiler" which lists the advantages and disadvantages of each of DMD, LDC and GDC.

August 18, 2015
On Tuesday, 18 August 2015 at 12:32:17 UTC, Etienne Cimon wrote:
> a crypto library that you can't optimize, building -O -g also gives me a ccog.c ICE error. I think it might be something about `asm pure` that uses some locals, does that eliminate the function call parameters?

Sorry that was cgcod.c

Internal error: backend\cgcod.c 2311
FAIL .dub\build\__test__full__-unittest-windows-x86_64-dmd_2068-8073079C502FEEB927744150233D4046\ __test__full__ executa
ble

I'll try and file a bugzilla about this. I think stability should be first concern.
August 18, 2015
On Tuesday, 18 August 2015 at 12:37:37 UTC, Vladimir Panteleev wrote:
> I think stability of the DMD backend is a goal of much higher value than the performance of the code it emits. DMD is never going to match the code generation quality of LLVM and GCC, which have had many, many man-years invested in them. Working on DMD optimizations is essentially duplicating this work, and IMHO I think it's not only a waste of time, but harmful to D because of the risk of regressions.

+1
August 18, 2015
On Tuesday, 18 August 2015 at 10:45:49 UTC, Walter Bright wrote:
> Martin ran some benchmarks recently that showed that ddmd compiled with dmd was about 30% slower than when compiled with gdc/ldc. This seems to be fairly typical.
>
> I'm interested in ways to reduce that gap.
>
> There are 3 broad kinds of optimizations that compilers do:
>
> 1. source translations like rewriting x*2 into x<<1, and function inlining
>
> 2. instruction selection patterns like should one generate:
>
>     SETC AL
>     MOVZ EAX,AL
>
> or:
>     SBB EAX
>     NEG EAX
>
> 3. data flow analysis optimizations like constant propagation, dead code elimination, register allocation, loop invariants, etc.
>
> Modern compilers (including dmd) do all three.
>
> So if you're comparing code generated by dmd/gdc/ldc, and notice something that dmd could do better at (1, 2 or 3), please let me know. Often this sort of thing is low hanging fruit that is fairly easily inserted into the back end.
>
> For example, recently I improved the usage of the SETcc instructions.
>
> https://github.com/D-Programming-Language/dmd/pull/4901
> https://github.com/D-Programming-Language/dmd/pull/4904
>
> A while back I improved usage of BT instructions, the way switch statements were implemented, and fixed integer divide by a constant with multiply by its reciprocal.

I've often looked at the assembly output of ICC.

One thing that was striking to me is that it by and large it doesn't use PUSH, POP, and SETcc. Actually I don't remember such an instruction being emitted by it.

And indeed using PUSH/POP/SETcc in assembly were often slower than the alternative. Which is _way_ different that the old x86 where each of these things would gain speed.

Instead of PUSH/POP it would spill all registers to an RBP-based location the (perhaps taking advantage of the register renamer?).

---------------

That said: I entirely agree with Vladimir about the codegen risk. DMD will always be used anyway because it compiles faster.
August 18, 2015
On Tuesday, 18 August 2015 at 10:45:49 UTC, Walter Bright wrote:
> ...
> 3. data flow analysis optimizations like constant propagation, dead code elimination, register allocation, loop invariants, etc.
>
> Modern compilers (including dmd) do all three.
>
> So if you're comparing code generated by dmd/gdc/ldc, and notice something that dmd could do better at (1, 2 or 3), please let me know. Often this sort of thing is low hanging fruit that is fairly easily inserted into the back end.
> ...

I've once tried to trace the slowdown cause in a simple program and reduced it to https://issues.dlang.org/show_bug.cgi?id=11821, I think if falls under point 3 in your post (redundant instruction in a simple loop).  Despite 1.5 years have passed, the issue still stands with 2.068.0.

That's for -m32.  The -m64 version of the loop does not look as having a redundant instruction to me, but is still longer than the output of GDC or LDC.
August 18, 2015
On Tuesday, 18 August 2015 at 12:37:37 UTC, Vladimir Panteleev wrote:
> I think stability of the DMD backend is a goal of much higher value than the performance of the code it emits. DMD is never going to match the code generation quality of LLVM and GCC, which have had many, many man-years invested in them. Working on DMD optimizations is essentially duplicating this work, and IMHO I think it's not only a waste of time, but harmful to D because of the risk of regressions.

Well, you have to admit that it's pretty impressive that dmd's backend gets within 30% of those monumental backends despite having pretty much only Walter working on it sporadically.  If it's a waste of time to work on compiler optimizations because of existing work, you could have said the same to the llvm devs when they tried to take on gcc.  As ponce said, people are always going to use dmd because of it's speed, no reason not to make its codegen better also.

Also, soon the dmd compiler backend will be the only one written in D. :) No reason to not also make it better. Of course, Walter is the only one who can decide the best use of his time.
August 18, 2015
On Tuesday, 18 August 2015 at 15:22:15 UTC, Joakim wrote:
> Also, soon the dmd compiler backend will be the only one written in D. :)

Soon the front end will be written in D. And the front end is shared among dmd, gdc, ldc. Walter has expressed a desire to port the back end to D, too [1]. But that's not going to happen "soon".

[1] http://forum.dlang.org/post/mohrrs$1pu7$1@digitalmars.com
August 18, 2015
On Tuesday, 18 August 2015 at 15:45:25 UTC, anonymous wrote:
> On Tuesday, 18 August 2015 at 15:22:15 UTC, Joakim wrote:
>> Also, soon the dmd compiler backend will be the only one written in D. :)
>
> Soon the front end will be written in D. And the front end is shared among dmd, gdc, ldc. Walter has expressed a desire to port the back end to D, too [1]. But that's not going to happen "soon".
>
> [1] http://forum.dlang.org/post/mohrrs$1pu7$1@digitalmars.com

Yes, that's why I said the dmd _backend_ will be the only one written in D.  Not sure how you know what the timeline for such a backend port is, seems like he really wants to get everything in D soon.
« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11