[fpc-devel] Object/Pointer Swap Intrinsic

Sven Barth pascaldragon at googlemail.com
Thu Dec 12 07:21:39 CET 2019

Am 12.12.2019 um 00:34 schrieb J. Gareth Moreton:
> That's true.  Given I specialise in optimisation, I've started to 
> venture towards the node level to see where improvements can be made.
> One question I do have in that regard... are platform-specific nodes 
> allowed? What I mean is, for example, a node's 'simplify' routine may 
> transmute a set of nodes to a platform-specific node that may better 
> benefit, say, vectorisation on an AMD64 processor.  (A swap node will 
> be platform-independent, and if platform-specific assembly isn't 
> available, then to just create the equivalent Pascal code as you laid 
> out below).
Take a look at optloadmodifystore.pas. It looks for code sequences that 
can be converted into load/modify/store instructions. For that purpose 
it converts the nodes to a new tinlinenode with e.g. in_ror_assign_x_y 
which is handled by tcginlinenode.second_AndOrXorShiftRot_assign. This 
method creates platform independent assembly code. For platform specific 
code you'd overwrite e.g. tx8664inlinenode.second_AndOrXorShiftRot_assign.

A similar approach would for the Swap optimization.


More information about the fpc-devel mailing list