JDK-8245714 : "Bad graph detected in build_loop_late" when loads are pinned on loop limit check uncommon branch
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-05-25
  • Updated: 2020-09-30
  • Resolved: 2020-06-02
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 JDK 15
11.0.9-oracleFixed 15 b26Fixed
Description
public class TestBadControlLoopLimitCheck {
    public static void main(String[] args) {
        int[] array = {0, 0};
        for (int i = 0; i < 20_000; i++) {
            test(array, 0, 10, false);
            test_helper(42);
        }
    }

    private static int test(int[] a, int start, int stop, boolean flag) {
        int[] b = new int[2]; // non escaping allocation
        System.arraycopy(a, 0, b, 0, 2); // optimized out
        int v = 1;
        int j = 0;
        for (; j < 10; j++);
        int inc = test_helper(j); // delay transformation to counted loop
        // loop limit check here has loads pinned on unc branch
        for (int i = start; i < stop; i += inc) {
            v *= 2;
        }
        if (flag) {
            v += b[0] + b[1];
        }
        return v;
    }

    static int test_helper(int j) {
        return j == 10 ? 10 : 1;
    }
}

fails with:

java -XX:-BackgroundCompilation -XX:ArrayCopyLoadStoreMaxElem=0 TestBadControlLoopLimitCheck
Comments
11u Fix request: Backporting this patch eliminates a c2 crash that was observed by one our customers. Patch applies cleanly to 11u. New test fails without the product patch, and passes with it. tier1 tests pass with the patch.
08-06-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/755ab9edca97 User: roland Date: 2020-06-02 15:10:57 +0000
02-06-2020