RFR: 8316396: Endless loop in C2 compilation triggered by AddNode::IdealIL
Roland Westrelin
roland at openjdk.org
Tue Sep 26 13:57:48 UTC 2023
A number of SubI nodes are laid out in a binary tree. There are <100
SubI nodes involved but the tree is fairly deep, and balanced and has
200+ millions of nodes that is the relately small number of SubI nodes
are arranged in a way that they build a 200+ millions node tree.
The `AddNode::IdealIL()` transform:
"(a-b)+(c-d)" into "(a+c)-(b+d)"
is applied at the root of the tree. Because `tranform()` is called on
the resulting a+c and b+d, the same transformation is applied to each
and recursively down the tree. So there's no endless loop but very
slow progress because c2 is busy walking and transforming a large
tree. There's a lot of redundant work done on the way, because the
tree is composed of a relatively small number of nodes. The fix I
proposed is to not call `tranform()` but enqueue a+c and b+d with
igvn. Some subtrees are shared in the large tree of `SubI`
nodes. Calling `tranform()` only causes the node in the tree that
called it to be updated while, when delaying to igvn, all uses of the
subtree are updated with the transformed subtree.
-------------
Commit messages:
- fix & test
Changes: https://git.openjdk.org/jdk/pull/15923/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15923&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8316396
Stats: 65 lines in 2 files changed: 63 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/15923.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/15923/head:pull/15923
PR: https://git.openjdk.org/jdk/pull/15923
More information about the hotspot-compiler-dev
mailing list