vectorization of a simple loop -- not in DMD?

max haughton maxhaton at gmail.com
Mon Jul 11 18:19:41 UTC 2022


On Monday, 11 July 2022 at 18:15:16 UTC, Ivan Kazmenko wrote:
> Hi.
>
> I'm looking at the compiler output of DMD (-O -release), LDC 
> (-O -release), and GDC (-O3) for a simple array operation:
>
> ```
> void add1 (int [] a)
> {
>     foreach (i; 0..a.length)
>         a[i] += 1;
> }
> ```
>
> Here are the outputs: https://godbolt.org/z/GcznbjEaf
>
> From what I gather at the view linked above, DMD does not use 
> XMM registers for speedup, and does not unroll the loop either. 
>  Switching between 32bit and 64bit doesn't help either.  
> However, I recall in the past it was capable of at least some 
> of these optimizations.  So, how do I enable them for such a 
> function?
>
> Ivan Kazmenko.

How long ago is the past? The godbolt.org dmd is quite old.

The dmd backend is ancient, it isn't really capable of these 
kinds of loop optimizations.


More information about the Digitalmars-d-learn mailing list