How does D cope with aliasing

bearophile bearophileHUGS at lycos.com
Tue Sep 8 14:52:14 PDT 2009


ponce:

>The problem is that I need my audio routines to go at full-speed even in debug mode (with asserts and DbC on). Bound checking make it quite slow since there is so much array access.<

With LDC you can fine-tune the "release", for example disabling just bound checkingbut keeping other asserts. See the LDC command line extended help.


>This is why I use pointers over arrays.<

In D using pointers instead of arrays is usually discouraged, arrays are for most purposes, pointers are for special purposes.
And in release mode with DMD the pointer-based arrays are a bit slower than normal arrays (in LDC they have the same speed), I don't know why.


>But the semantics of pointers and how the compiler consider these as aliased or not is quite unclear. Of course I may have a false view of how D handle these problems.<

Such problems aren't handled yet in D. Another person has told you the same thing.


>I come from a background where pointer aliasing was considered important to efficient code generation.<

D developers are designing large features of the D2 language, so I think they aren't interested in fine optimizations yet. That's why I have told you that in the short term your best hope is to have added a ldc-specific pragma in ldc that works as restrict.

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list