RFR: 8265938: C2's conditional move optimization does not handle top Phi

Hui Shi hshi at openjdk.java.net
Mon Apr 26 08:24:24 UTC 2021

On Mon, 26 Apr 2021 07:59:02 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> C2's CCP optimization sets the type of a PhiNode to TOP because it became dead after loop unrolling. Now since that node is not reachable from the bottom due to an infinite loop at the end of the method, CCP does not enqueue the PhiNode for IGVN. As a result, the dead subgraph is not removed. During loop opts, the conditional move optimization fails on the PhiNode because its type is top. The expected behavior is to simply bail out with "COMPILE SKIPPED: infinite loop (retry at different tier)".
>> I suggest to fix this by simply handling a TOP Phi in the conditional move optimization code.
>> This issue was reported by John Jiang (johnsjiang at tencent.com).
>> Thanks,
>> Tobias
> Thanks for the review, Christian!

@TobiHartmann Thanks for fixing tencent reported bug! Your fix is good.

Could an early check added after ccp GVN? Check if it is compiling a method currently in inifinite loop and abort compilation earlier?

--- a/src/hotspot/share/opto/compile.cpp
+++ b/src/hotspot/share/opto/compile.cpp
@@ -2287,6 +2287,9 @@ void Compile::Optimize() {
     TracePhase tp("iterGVN2", &timers[_t_iterGVN2]);
     igvn = ccp;
+    if (root()->req() == 1) {
+      record_method_not_compilable("trivial infinite loop after phase ccp");
+    }
   print_method(PHASE_ITER_GVN2, 2);


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

More information about the hotspot-compiler-dev mailing list