[fpc-devel] Pure function development
jonas at freepascal.org
Wed Apr 29 22:40:25 CEST 2020
On 29/04/2020 22:08, J. Gareth Moreton wrote:
> Constant propagation is only really beneficial for inline functions,
That is incorrect.
> although there is some crossover with pure functions. I was more meaning
> a system of tracking and storing these constants, or rather how they
> manipulate variables throughout a pure function.
That is exactly what -Ooconstprop does, although (as mentioned before),
to a quite limited extent. It doesn't extract the constants from the
nodes, but replaces variables (load nodes) with the constant nodes that
were assigned to them earlier, and then at the end runs the simplify
pass over the resulting node tree. The simplify pass already contains
all support for merging expressions involving only constant nodes into
single constants, so it has no need for storing the constant data in a
separate structure and then duplicate all the constant evaluations for
that extra structure.
More information about the fpc-devel