Missing identity optimization in arithmetic Or

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 26
    • Component/s: hotspot

      While working on test cases for JDK-8373134 I discovered a missing optimisation for arithmetic or. Max node implementations get the Max(A, Max(A, B)) == Max(A, B) optimisation via MaxNode::find_identity_operation. However, this is not present for arithmetic or. E.g.

      ```
          // int c = a * i; is going to optimize to c = a;
          // So this effectively becomes (a | (b | a))
          // Since (a | a) is a, it should be possible to
          // reduce to (a | b)
          private static int test(int b, int a)
          {
              int i;
              for (i = -10; i < 1; i++)
              {
              }
              int c = a * i;
              return a | (b | c);
          }
      ```

      The above results in this IR nodes at the end of gvn. With the optimisation we should expect to find a single Or with 10 and 11.

      ```
       114 OrI === _ 10 11 [[ 115 ]] !jvms: TestIntOr::test @ bci:21 (line 21)
       115 OrI === _ 11 114 [[ 116 ]] !jvms: TestIntOr::test @ bci:22 (line 21)
      ```

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

              Created:
              Updated: