JDK-8300256 : C2: vectorization is sometimes skipped on loops where it would succeed
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,20,21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-01-17
  • Updated: 2023-03-28
  • Resolved: 2023-02-01
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 21
21 b08Fixed
Related Reports
Relates :  
Relates :  
Description
This showed up with some panama benchmarks.
The following code snippet is not vectorized because vectorization is not even attempted after range check eliminations has eliminated all tests in the main loop body:

    public static void test1(byte[] dest, long[] src) {
        for (int i = 0; i < src.length; i++) {
            if ((i < 0) || (8 > sizeBytes - i)) {
                throw new IndexOutOfBoundsException();
            }
            UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + i * 8, src[i]);
        }
    }

Comments
Changeset: 2a8ae2ff Author: Roland Westrelin <roland@openjdk.org> Date: 2023-02-01 09:48:54 +0000 URL: https://git.openjdk.org/jdk/commit/2a8ae2ff1c95cb75f315eb5340bff2b46409d1ae
01-02-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/12116 Date: 2023-01-20 15:15:40 +0000
20-01-2023

ILW = Missed vectorization opportunity in C2, rare?, no workaround = MLH = P4
17-01-2023