[fpc-devel] Question about typeconv nodes
J. Gareth Moreton
gareth at moreton-family.com
Tue Apr 5 01:16:55 CEST 2022
Hi everyone,
I've noticed that, in many units, the generated node trees produce a lot
of typeconv nodes with convtype=tc_equal. For example (4th line - this
is generated with DEBUG_NODE_XML):
<statementn pos="53,30">
...<assignn resultdef="$void" pos="53,9">
......<subscriptn resultdef="Double" pos="53,10" flags="nf_write">
.........<typeconvn resultdef="complex" pos="53,9" flags="nf_absolute"
convtype="tc_equal">
............<loadn resultdef="complex" pos="53,10" flags="nf_write">
...............<symbol>result</symbol>
............</loadn>
.........</typeconvn>
.........<field>RE</field>
......</subscriptn>
......<addn resultdef="Double" pos="53,23">
.........<subscriptn resultdef="Double" pos="53,19">
............<loadn resultdef="complex" pos="53,17">
...............<symbol>Z1</symbol>
............</loadn>
............<field>RE</field>
.........</subscriptn>
.........<subscriptn resultdef="Double" pos="53,27">
............<loadn resultdef="complex" pos="53,25">
...............<symbol>Z2</symbol>
............</loadn>
............<field>RE</field>
.........</subscriptn>
......</addn>
...</assignn>
</statementn>
As an experiment, I tried to simplify the node tree on x86_64 by
stripping out typeconv nodes where the convtype=tc_equal,
resultdef=left.resultdef (so it truly is an equal conversion) and the
type is unmanaged (including managed types can sometimes change the
assembly language quite significantly, like how often reference
incrementors or decrementors are called - I figured that playing around
with those is risky). Long story short, it tends to help with producing
more efficient machine code.
Is there something I've missed where such typeconv nodes are necessary?
I figure it's something to do with the "nf_absolute" flag, but I haven't
quite grasped it yet. Any help would be appreciated.
Gareth aka. Kit
P.S. My desire for removing unnecessary typeconv nodes is to help with
vectorisation.
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
More information about the fpc-devel
mailing list