Do you think if statement as expression would be nice to have in D?
max haughton
maxhaton at gmail.com
Tue Jun 7 08:44:27 UTC 2022
On Tuesday, 7 June 2022 at 04:53:36 UTC, bauss wrote:
> On Tuesday, 7 June 2022 at 01:24:07 UTC, Walter Bright wrote:
>>
>> There is a persistent idea that there is something
>> fundamentally wrong with DMD. There isn't. It's just that
>> optimization involves an accumulation of a large number of
>> special cases, and clang has a lot of people adding special
>> cases.
>>
>
> I have only ever used DMD, never bothered using anything else
> and it has never hindered any of my work or mattered in the
> slightest.
>
> Nothing I work with suffers from the difference in optimization
> as I don't have anything that's real-time sensitive.
>
> As long as the work is done in a reasonable amount of time
> (That of course depends on what it is.) then I'm fine with it.
>
> Typically the difference is in the milliseconds, which won't
> matter much for most enterprise work.
Unfortunately the dmd optimizer and inliner are somewhat buggy so
most "enterprise" users actually avoid them like the plague or
have fairly hard-won scars. At least one of our libraries doesn't
work with -O -inline, many others cases have similar issues.
It's not just about performance, even if LLVM and GCC are much
faster.
optimization isn't just about adding special cases, the sheer
amount of optimizations dmd would have to learn on top of an
already horrific codebase in the backend (note that to start with
the register allocator is pretty bad, but isn't easily replaced)
means while it's technically possible it's practically just not
realistic.
The IR used by the backend is also quite annoying to work with.
SSA is utterly dominant in compilers (and has been since the late
90s) for a reason. It's not it's fault because it's so old but
the infrastructure and invariants you get from it are just
nothing even close to being easy to work on versus even GCC
before they realized LLVM was about to completely destroy them
(almost no one does new research with GCC anymore mostly because
LLVM is easier to work on).
This IR and the lack of structure around operations on it is why
dmd has so many bugs wrt things like SIMD code generation. GCC
and LLVM learnt the hard way that you need to segment work into
multiple passes and possibly different data structures entirely
(either artificially, like LCSSA, or using an entirely different
IR like GCC's rtl). These are not cheap things to do but paying
for them also buys you correctness.
dmd should just focus on being the debug compiler i.e. be fast. I
would much rather have the codebase be clean enough that I could
easily get it generating code on my AArch64 Mac than have it
chase after being able to do xyz. I will never actually care
about dmds ability to optimize something.
More information about the Digitalmars-d
mailing list