Optimization of simple properties
bearophileHUGS at lycos.com
Sat Oct 11 13:26:07 PDT 2008
> Is this a bug unique to gdc (or the older gdc build that I have)? Is dmd
> smart enough to avoid this kind of problem?
DMD is usually even less smart than GDC. But it's not a bug, it's a performance miss :-)
Current D compilers aren't much smart regarding optimizations. You will find that in several other things. With time (years) D compilers will become smarter. Java HotSpot is able to perform very complex optimizations, partial or total inlining of virtual methods, etc, etc. To perform some of those optimizations it may be useful to have lot of statistics regarding how the code is actually used, that's why virtual machines sometimes are faster than statically optimized code, even if you use "profile guided optimization" that the last Intel and GCC compilers have.
More information about the Digitalmars-d-learn