By ref and by pointer kills performance.
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Tue Feb 13 03:31:31 UTC 2024
dmd having bad codegen here isn't a surprise, that is to be expected.
Now for ldc:
```d
void fillBP(immutable(uint*) value, uint* dest) {
dest[0] = *value;
dest[1] = *value;
dest[2] = *value;
dest[3] = *value;
}
```
I expected that to not do the extra loads, but it did.
```d
void fillBP(immutable(uint*) value, uint* dest) {
dest[0 .. 4][] = *value;
}
```
And that certainly should not be doing it either.
Even if it wasn't immutable.
For your code, because it is not immutable and therefore can be changed
externally on another thread, the fact that the compiler has to do the
loads is correct. This isn't a bug.
More information about the Digitalmars-d
mailing list