MinL missing identity optimisations

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: hotspot
    • None

      I'm back woking on JDK-8351409, and to make progress with the IR tests, I have patched my work with the fix for JDK-8373134 that I've sent a PR for.

      I've now tried to expand the reassocation logic and IR test from MaxL to also include MinL, and the IR test fails with:

      ```
      Missed Identity optimization:
      Old node:
      dist dump
      ---------------------------------------------
         1 1048 MaxL === _ 124 336 [[ 124 812 374 348 ]] !orig=[300] !jvms: ReductionReassociation::test_2 @ bci:149 (line 38)
         1 336 MinL === _ 324 1000 [[ 348 1048 ]] !orig=[1047] !jvms: Long::min @ bci:2 (line 1961) ReductionReassociation::test_2 @ bci:120 (line 36)
         0 348 MinL === _ 336 1048 [[ 375 812 ]] !jvms: Long::min @ bci:2 (line 1961) ReductionReassociation::test_2 @ bci:128 (line 37)
      New node:
      dist dump
      ---------------------------------------------
         1 1000 LoadL === 998 7 251 [[ 336 ]] @aryptr:long[int:>=0] (java/lang/Cloneable,java/io/Serializable):BotPTR:exact+any,iid=bot, idx=6; #long (does not depend only on test, unknown control) !orig=[253] !jvms: ReductionReassociation::test_2 @ bci:57 (line 31)
         1 324 MinL === _ 312 951 [[ 336 ]] !orig=[1046] !jvms: Long::min @ bci:2 (line 1961) ReductionReassociation::test_2 @ bci:111 (line 35)
         0 336 MinL === _ 324 1000 [[ 348 1048 ]] !orig=[1047] !jvms: Long::min @ bci:2 (line 1961) ReductionReassociation::test_2 @ bci:120 (line 36)
      ```

      The IR test that is failing is this (it assumes reassociation logic is in place):

      ```
        @Test
        @IR(
            counts = {IRNode.MIN_L, "= 4"},
            phase = CompilePhase.AFTER_LOOP_OPTS)
        public Object[] test_2() {
          long result = Integer.MIN_VALUE;
          long result2 = Integer.MIN_VALUE;
          for (int i = 0; i < input_2.length; i += 4) {
            long v0 = input_2[i + 0];
            long v1 = input_2[i + 1];
            long v2 = input_2[i + 2];
            long v3 = input_2[i + 3];
            long u0 = Long.min(v0, result);
            long u1 = Long.min(v1, u0);
            long u2 = Long.min(v2, u1);
            long u3 = Long.min(v3, u2);
            result = u3;
            long t0 = Long.min(v0, v1);
            long t1 = Long.min(v2, t0);
            long t2 = Long.min(v3, t1);
            long t3 = Long.min(result, t2);
            result2 = t3;
          }
          return new Object[] {result, result2};
        }
      ```

      I will try to create a smaller reproducer, and try to understand if the issue should be covered by JDK-8373134 or is a different one.

      I need these optimisations to be processed in order to get commoning to kick in. The reassociation IR tests rely on commoning to make 2 different code shapes equal and get deterministic IR node counts.

            Assignee:
            Galder ZamarreƱo
            Reporter:
            Galder ZamarreƱo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: