RFR: 8253923: C2 doesn't always run loop opts for compilations that include loops
Roland Westrelin
roland at openjdk.java.net
Mon Oct 5 06:54:45 UTC 2020
On Fri, 2 Oct 2020 07:47:00 GMT, Roland Westrelin <roland at openjdk.org> wrote:
> 8253923: C2 doesn't always run loop opts for compilations that include loops
I noticed that c2 wouldn't always run loop opts when the compilation include loops. Compile::has_loops() is what
controls whether loop opts are executed. It's initially false and then set to true as parsing finds new loops. The flag
is updated with the result ciMethod::has_loops() of inlined methods but:
1. with bimorphic inlining, the has_loops flag is not set based on the methods that are actually inlined but from the
virtual method the call resolve statically to.
2. there's a least one intrinsic that's predicated and falls back to inlining of the method bytecodes, in which case
has_loops is not set.
3. sometimes loops are built manually rather than by parsing bytecodes
4. when the backedge is a branch of a switch or an exception edge, ciMethod::has_loops() doesn't return true
I propose that 1 & 2 be fixed by setting the has_loops flag when parsing of a method starts rather than when a call is
inlined. 3 is fixed by explicitly setting the flag where the loop is built, 4 by extending ciMethod::has_loops() for
switches.
-------------
PR: https://git.openjdk.java.net/jdk/pull/478
More information about the hotspot-compiler-dev
mailing list