C2: Eliminate bounds checks for indices produced by fast-range algorithm

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P3
    • tbd
    • Affects Version/s: 11, 14
    • Component/s: hotspot

      The fast-range[1] algorithm:
        https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/

      It describes an efficient way to produce an index which is guaranteed to be inbounds:
        for arbitrary non-negative (int) h and non-negative (int) size N, the ((long) h) * N) >>> 32 is less than N.

      C2 can detect such pattern (by looking at how access index is computed) and skip bounds checks for it.

      Relevant discussion:
          https://mail.openjdk.java.net/pipermail/hotspot-dev/2019-November/040011.html

            Assignee:
            Unassigned
            Reporter:
            Vladimir Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: