Function reduction as part of previous graph optimisation