JDK-8286197 : C2: Optimize MemorySegment shape in int loop
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19,20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-05-05
  • Updated: 2024-03-26
  • Resolved: 2022-06-10
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 20
20 b02Fixed
Related Reports
Relates :  
Description
The loop body to optimize is:
        for (int i = 0; i < size; i++) {
            long j = i * UNSAFE.ARRAY_INT_INDEX_SCALE;

            j = Objects.checkIndex(j, size * 4);

            if (((base + j) & 3) != 0) {
                throw new RuntimeException();
            }

            v += UNSAFE.getInt(base + j);
        }

loop iv is first scaled, result is then casted to long, range checked and finally address of memory location is computed.
Comments
Changeset: dae4c493 Author: Roland Westrelin <roland@openjdk.org> Date: 2022-06-10 08:17:26 +0000 URL: https://git.openjdk.org/jdk/commit/dae4c493e48b6bb942cf6f629f1ff8839e32e54a
10-06-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8555 Date: 2022-05-05 14:57:11 +0000
05-05-2022