Work on ARM backend for DMD started
Walter Bright via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Wed Jul 5 18:21:43 PDT 2017
On 7/5/2017 4:48 PM, H. S. Teoh via Digitalmars-d-announce wrote:
> In particular, it doesn't seem to do code hoisting, as least
> not for this case,
It does not in this case because:
data[0]
is actually:
*data.ptr
i.e. a read through a pointer. Inside the loop, there is also:
data[i * 10] = ...
which is an assignment through a pointer. The assignment through the pointer
makes a read through a pointer not loop invariant. It's only possible to pull
out the assignment to j if loop unrolling is done, which as I said is not done
by DMD.
Loop invariant removal (aka code hoisting) *is* done in the optimizer.
https://github.com/dlang/dmd/blob/master/src/ddmd/backend/gloop.c#L678
> There are two calls to _d_arrayboundsp inside the loop body, along with
branches around them. This seems needless, since one bounds check ought to be
enough to ensure the array lookups are within bounds. Also, there are 2 branches
within the loop body (not counting the end-of-loop branch), whereas it could
have been simplified to one (less branch hazards on the CPU pipeline).
Yes, that's true, I'm not sure why that isn't happening. It should be.
More information about the Digitalmars-d-announce
mailing list