JDK-8193130 : Bad graph when unrolled loop bounds conflicts with range checks
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9,10,11
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-12-06
  • Updated: 2022-12-01
  • Resolved: 2022-06-22
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 11
11 b07Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
public class IterationSplitPredicateInconsistency {
    static volatile int barrier;

    static boolean test1_helper(int start, int stop, double[] array1, double[] array2, int exit) {
        for (int i = start; i < stop; i++) {
            array1[i] = array2[i];
            if (i == exit) {
                return true;
            }
            barrier = 0x42;
        }
        return false;
    }

    static double[] test1(int start, double[] array2, int exit) {
        double[] array1 = new double[10];
        if (test1_helper(start, 5, array1, array2, exit)) {
            return null;
        }
        return array1;
    }
    public static void main(String[] args) {
        double[] array2 = new double[10];
        double[] array3 = new double[1000];
        for (int i = 0; i < 20_000; i++) {
            test1_helper(0, 1000, array3, array3, 998);
            test1(0, array2, 999);
            test1(0, array2, 4);
        }
    }
}

fails with "Bad graph detected in compute_lca_of_uses"
Comments
URL: http://hg.openjdk.java.net/jdk/jdk/rev/bde392011cd8 User: jwilhelm Date: 2018-03-29 19:35:31 +0000
29-03-2018

URL: http://hg.openjdk.java.net/jdk/hs/rev/bde392011cd8 User: kvn Date: 2018-03-23 03:17:04 +0000
23-03-2018

New testing with latest idk/hs passed for http://cr.openjdk.java.net/~roland/8193130/webrev.01/
23-03-2018

I tried Roland's fix webrev.01. It works in both cases! It could be right solution. I will look on it again since I now understand what happens.
22-03-2018

You have to inline test1_helper to trigger failure without predicates: -XX:-UseLoopPredicate -XX:CompileCommand=inline,IterationSplitPredicateInconsistency::test1_helper
22-03-2018

I finally resurrected by C2 debugging skill :) The problem is easy reproduced with provided test case and latest JDK: java -Xbatch -XX:CICompilerCount=1 -XX:+PrintCompilation -XX:-TieredCompilation -XX:LoopUnrollLimit=1000 -XX:LoopStripMiningIter=0 -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:+TraceLoopOpts -XX:+TraceRangeLimitCheck -XX:+TraceLoopPredicate IterationSplitPredicateInconsistency The trouble thing I found that it also fails with predicates off: -XX:-UseLoopPredicate. Originally I thought that RC elimination code would adjust main loop limit and will help avoid the problem. But it is not the case :) I also thought to CastII [0, 10) for init value ('start' parameter) for which we have range check predicate but since it fail without predicate it is not solution. We need to find solution for both cases: with and without predicate.
22-03-2018

I agree. Deferred to 11 according to RDP 1 rules (not new in 10): http://openjdk.java.net/projects/jdk/10/rdp-1
18-01-2018

I am suggesting to defer it to jdk 11 since it is present in jdk 9 (not new in jdk 10) and the fix is not simple. It is just 6 months delay. And we are at the latest phase of jdk 10 release.
17-01-2018

The performance batches are almost done, it looks fine so far.
10-01-2018

Okay, thanks. I'm adding affects version 9 then but we should try to get it fixed in 10.
07-12-2017

~ [thartmann] As I understand, the root cause is present in 9 but the failure is less likely to trigger because 9 doesn't do as much unrolling as 10 does. One workaround would be to limit unrolling.
07-12-2017

[~roland], is this a regression in JDK 10? Is there a workaround? ILW = Verification fails during loop optimizations, reproducible but never showed up "in the wild", disable compilation or loop opts = HMM = P2
07-12-2017