<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">Florian Klämpfl <<a href="mailto:florian@freepascal.org">florian@freepascal.org</a>> schrieb am So., 17. Juni 2018, 10:56:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 16.06.2018 um 23:21 schrieb J. Gareth Moreton:<br>
> Note that I speak mostly from an x86_64 perspective, since this is where I have almost universal exposure.<br>
> <br>
> So I've been pondering a few things after researching Florian's prototype patch for optimisations done prior to register <br>
> allocation, when the pre-compiled assembly language utilises imaginary (virtual) registers pretty much everywhere other <br>
> than where distinct registers are required (e.g. function parameters). My question is... how much can be moved to the <br>
> pre-allocation stage? <br>
<br>
A lot, basically everything which reduced register pressure. The only problem is, at this stage, the code contains a lot <br>
of moves (compile with -sr to see how it looks like). So the optimizer must be able to handle this. It might be even <br>
possible to build a generic optimizer pass at this stage. Example:<br>
<br>
A typical sequence FPC often generates is:<br>
<br>
mov %src1,%dest1<br>
add %dest1,%src2,%dest2<br>
<br>
If src1 is no released after mov but dest1 is release, src1 and dest1 still cannot be coalesced as they interfere, so an <br>
extra register is allocated. The move will be remove by the peephole optimizer, but register was allocated and increase <br>
register pressure. Such optimizations could be done generic (for all CPUs): if the destination of a mov is only read <br>
afterwards (this information is already generically available), the mov can be removed and in this case dest1 can be <br>
replaced by src1.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Though only if the type of src1 is the same as that of dest1, right? (e.g. int vs. address register) </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>