Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8245714

"Bad graph detected in build_loop_late" when loads are pinned on loop limit check uncommon branch

    Details

    • Subcomponent:
    • Resolved In Build:
      b26

      Backports

        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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  roland Roland Westrelin
                  Reporter:
                  roland Roland Westrelin
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: