Re: D generates large assembly for simple function

2018-01-28 Thread welkam via Digitalmars-d-learn
On Sunday, 28 January 2018 at 14:33:04 UTC, Johan Engelen wrote: Careful with these comparisons guys. Know what you are looking at. Wise words

Re: D generates large assembly for simple function

2018-01-28 Thread Johan Engelen via Digitalmars-d-learn
On 01/27/2018 11:42 AM, Matt wrote: Godbolt link: https://godbolt.org/g/t5S976 Careful with these comparisons guys. Know what you are looking at. Rust does not eliminate setting the framepointer register, and so it looks "bad" [1]. Clang also sets the framepointer for macOS ABI regardless of

Re: D generates large assembly for simple function

2018-01-27 Thread Ali Çehreli via Digitalmars-d-learn
On 01/27/2018 11:42 AM, Matt wrote: Godbolt link: https://godbolt.org/g/t5S976 According to that link D and C++ both produce 4 lines of assembly, Rust 7, and Go 38 (for that function). Ali

Re: D generates large assembly for simple function

2018-01-27 Thread Seb via Digitalmars-d-learn
On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote: On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote: Godbolt link: https://godbolt.org/g/t5S976 The actual code is : imul edi, edi mov eax, edi ret The rest is runtime initialization. which you can remove using an

Re: D generates large assembly for simple function

2018-01-27 Thread Seb via Digitalmars-d-learn
On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote: On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote: Godbolt link: https://godbolt.org/g/t5S976 The actual code is : imul edi, edi mov eax, edi ret The rest is runtime initialization. which you can remove using an

Re: D generates large assembly for simple function

2018-01-27 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jan 27, 2018 at 07:41:21PM +, Matt via Digitalmars-d-learn wrote: > Playing around with Godbolt, D seems to generate an embarassing amount > of assembly for a simple function (50ish for squaring an int vs 4 for > C++ and 7 for Rust). Even Go compiles to less assembly. > > Is there

Re: D generates large assembly for simple function

2018-01-27 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 27 January 2018 at 19:45:35 UTC, Stefan Koch wrote: ah ... -betterC is only for dmd. `-betterC` works from LDC 1.1.0. - Johan

Re: D generates large assembly for simple function

2018-01-27 Thread kdevel via Digitalmars-d-learn
On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote: On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote: Godbolt link: https://godbolt.org/g/t5S976 The actual code is : imul edi, edi mov eax, edi ret Could you please paste the source code? I mean in say 5 years when

Re: D generates large assembly for simple function

2018-01-27 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote: On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote: Godbolt link: https://godbolt.org/g/t5S976 The actual code is : imul edi, edi mov eax, edi ret The rest is runtime initialization. which you can remove using an

Re: D generates large assembly for simple function

2018-01-27 Thread Matt via Digitalmars-d-learn
Godbolt link: https://godbolt.org/g/t5S976

D generates large assembly for simple function

2018-01-27 Thread Matt via Digitalmars-d-learn
Playing around with Godbolt, D seems to generate an embarassing amount of assembly for a simple function (50ish for squaring an int vs 4 for C++ and 7 for Rust). Even Go compiles to less assembly. Is there something I'm missing?

Re: D generates large assembly for simple function

2018-01-27 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote: Godbolt link: https://godbolt.org/g/t5S976 The actual code is : imul edi, edi mov eax, edi ret The rest is runtime initialization. which you can remove using an undocumented -betterC switch.