JDK-8231291 : C2: loop opts before EA should maximally unroll loops
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 14,15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-09-20
  • Updated: 2024-05-24
  • Resolved: 2020-02-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b10Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
This came up in the following email thread:
https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2019-September/035037.html
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/51fb05ec531d User: roland Date: 2020-02-07 13:21:43 +0000
07-02-2020

Possible fix (note that it is missing some checks): diff -r 778fc2dcbdaa -r 128802f27d31 src/hotspot/share/opto/compile.cpp --- a/src/hotspot/share/opto/compile.cpp Wed Sep 18 20:49:13 2019 -0400 +++ b/src/hotspot/share/opto/compile.cpp Thu Sep 19 16:20:51 2019 +0200 @@ -2291,7 +2291,7 @@ if (has_loops()) { // Cleanup graph (remove dead nodes). TracePhase tp("idealLoop", &timers[_t_idealLoop]); - PhaseIdealLoop::optimize(igvn, LoopOptsNone); + PhaseIdealLoop::optimize(igvn, LoopOptsMaxUnroll); if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2); if (failing()) return; } diff -r 778fc2dcbdaa -r 128802f27d31 src/hotspot/share/opto/compile.hpp --- a/src/hotspot/share/opto/compile.hpp Wed Sep 18 20:49:13 2019 -0400 +++ b/src/hotspot/share/opto/compile.hpp Thu Sep 19 16:20:51 2019 +0200 @@ -94,6 +94,7 @@ enum LoopOptsMode { LoopOptsDefault, LoopOptsNone, + LoopOptsMaxUnroll, LoopOptsShenandoahExpand, LoopOptsShenandoahPostExpand, LoopOptsZBarrierInsertion, diff -r 778fc2dcbdaa -r 128802f27d31 src/hotspot/share/opto/loopnode.cpp --- a/src/hotspot/share/opto/loopnode.cpp Wed Sep 18 20:49:13 2019 -0400 +++ b/src/hotspot/share/opto/loopnode.cpp Thu Sep 19 16:20:51 2019 +0200 @@ -2991,6 +2991,28 @@ return; } + if (mode == LoopOptsMaxUnroll) { + for (LoopTreeIterator iter(_ltree_root); !iter.done(); iter.next()) { + IdealLoopTree* lpt = iter.current(); + if (lpt->is_innermost() && lpt->_allow_optimizations && !lpt->_has_call) { + lpt->compute_trip_count(this); + AutoNodeBudget node_budget(this); + if (lpt->policy_maximally_unroll(this)) { + do_maximally_unroll(lpt, worklist); + } + } + } + + C->restore_major_progress(old_progress); + + _igvn.optimize(); + + if (C->log() != NULL) { + log_loop_tree(_ltree_root, _ltree_root, C->log()); + } + return; + } + if (bs->optimize_loops(this, mode, visited, nstack, worklist)) { _igvn.optimize(); if (C->log() != NULL) {
20-09-2019