JDK-8301904 : Incorrect post loop vectorization when IV is converted to long
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9,10,11,12,13,14,15,16,17,18,19,20
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: x86,aarch64
  • Submitted: 2023-02-07
  • Updated: 2023-07-17
  • Resolved: 2023-07-17
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.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Description
Recently we find a defect of post loop vectorization from a fuzzer test. After a few investigation, we created below simple case to reproduce it on CPUs with vector mask support (x86 AVX-512 or AArch64 SVE).

public class Foo {
  private static int[] a = new int[100];
  private static long val = 0;

  private static void bar() {
    int i = 0;
    for (i = 3; i < 50; i++)
      a[i] += 1;
    val += i;
  }

  public static void main(String[] strArr) {
    bar();
    System.out.println(val);
  }
} 

$ java Foo
50

$ java -Xcomp -XX:+UnlockDiagnosticVMOptions -XX:CompileOnly=Foo.bar -XX:-TieredCompilation -XX:+UnlockExperimentalVMOptions -XX:+PostLoopMultiversioning Foo
47

In this case, the induction variable `i` is used after the loop and converted and added to a long. The add uses the ConvI2LNode which is not correctly incremented after loop.
Comments
No need to fix this any more since related code has been removed.
17-07-2023

ILW = Wrong execution with post loop vectorization, only single test and with experimental feature, use -XX:-PostLoopMultiversioning = HLL = P4
07-02-2023