Loop optimization

Don nospam at nospam.com
Mon May 17 04:13:43 PDT 2010


Walter Bright wrote:
> Don wrote:
>> bearophile wrote:
>>> kai:
>>>> Any ideas? Am I somehow not hitting a vital compiler optimization?
>>>
>>> DMD compiler doesn't perform many optimizations, especially on 
>>> floating point computations.
>>
>> More precisely:
>> In terms of optimizations performed, DMD isn't too far behind gcc. But 
>> it performs almost no optimization on floating point. Also, the 
>> inliner doesn't yet support the newer D features (this won't be hard 
>> to fix) and the scheduler is based on Pentium1.
> 
> Have to be careful when talking about floating point optimizations. For 
> example,
> 
>    x/c => x * 1/c
> 
> is not done because of roundoff error. Also,
> 
>    0 * x => 0
> 
> is also not done because it is not a correct replacement if x is a NaN.

The most glaring limitation of the FP optimiser is that it seems to 
never keep values in the FP stack. So that it will often do:
FSTP x
FLD x
instead of FST x
Fixing this would probably give a speedup of ~20% on almost all FP code, 
and would unlock the path to further optimisation.


More information about the Digitalmars-d-learn mailing list