RFR: 8280541: remove self-recursion of ConnectionGraph::find_inst_mem()

Dean Long dlong at openjdk.java.net
Mon Jan 31 23:56:07 UTC 2022


On Mon, 24 Jan 2022 22:57:15 GMT, Xin Liu <xliu at openjdk.org> wrote:

> This is a follow-up task of JDK-8276219.
> 
> ConnectionGraph::find_inst_mem() contains a self-recursion for MergeMemNode.
> It drills down into one input of MergeMemNode and tries to locate the memory node
> which has the exact alias_idx. Once it returns, the result won't change from
> recursion. Therefore, it's not necessary to use recursion in this case. We can
> reset the initial state of this function and respin.
> 
> We can use a collection to remember all MergeMem Nodes and update them after then. 
> 
> This patch also makes a cleanup in MergeMemNode::memory_at(). C is not in use in
> that function.

I don't think it makes sense to remove only self-recursion here.  I think it makes the code less readable (see JDK-8276219).  It's not obvious to me that the code gives the same result.  Normally when converting recursive to iterative, I would expect to see both push and pop operations, but I only see push operations here.  Also, to test the new algorithm, I would suggest to run it in parallel with the old algorithm and compare the results.

-------------

Changes requested by dlong (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/7204


More information about the hotspot-compiler-dev mailing list