Integrated: 8297724: Loop strip mining prevents some empty loops from being eliminated
Roland Westrelin
roland at openjdk.org
Wed Dec 21 14:50:06 UTC 2022
On Thu, 15 Dec 2022 16:43:07 GMT, Roland Westrelin <roland at openjdk.org> wrote:
> When an empty loop is found, it's removed and as a consequence the
> outer strip mine loop and the safepoint that it contains are also
> removed. A counted loop is empty if it has the minimum number of nodes
> that a well formed counted loop contains. In some cases, the loop has
> extra nodes and the safepoint in the outer loop is the only node that
> keeps those extra nodes alive. If the safepoint was to be removed,
> then the counted loop would have the minimum number of nodes and be
> considered empty. But the safepoint can't be removed until the loop is
> considered empty which only happens if it has the minimum of nodes. As
> a result, these loops are not removed. Note that now that the loop
> strip mining loop nest is constructed even if UseCountedLoopSafepoints
> is false, there's a regression where some loops used to be removed as
> empty before but not anymore.
>
> The fix I propose is to extend IdealLoopTree::do_remove_empty_loop()
> so it handles those cases. If it encounters a loop with no flow
> control in the loop body but a number of nodes greater than the
> minimum number of nodes, it starts from the extra nodes in the loop
> body and follows uses until it finds a side effect, ignoring the
> safepoint of the outer loop. If it finds none, then the extra nodes
> can be removed and the loop is empty. This also works if the extra
> nodes are kept alive by the safepoints of 2 different counted loops
> and one can only be proven empty if the other one is as well (and the
> other one proven empty if the first one is) and should work even if
> there are more than 2 nodes involved..
This pull request has now been integrated.
Changeset: 88bfe4d3
Author: Roland Westrelin <roland at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/88bfe4d3bff5504bb6061d1484325dd6a55f06a2
Stats: 304 lines in 3 files changed: 296 ins; 4 del; 4 mod
8297724: Loop strip mining prevents some empty loops from being eliminated
Reviewed-by: kvn, thartmann
-------------
PR: https://git.openjdk.org/jdk/pull/11699
More information about the hotspot-compiler-dev
mailing list