JDK-8259361 : Bug cause by -XX:+AllowVectorizeOnDemand in array with intersecting ranges
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11.0.9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2020-12-22
  • Updated: 2021-01-08
  • Resolved: 2021-01-07
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Mac OS

A DESCRIPTION OF THE PROBLEM :
The array is set with zeros during the execution of the IntStream.range(0, 0x0010_0000).filter(...).count(); chain

https://stackoverflow.com/questions/65394902/elements-of-int-can-be-inappropriately-set-to-zero-in-an-implemented-method/65415455#65415455

REGRESSION : Last worked in version 8

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
openjdk 11.0.9.1

ACTUAL -
undefined behaviour 

---------- BEGIN SOURCE ----------
class Main {
    private final static int SIZE = 33;

    public static boolean test2(int seed) {
        int[] state = new int[SIZE];
        state[0] = seed;
        for (int i = 1; i < SIZE; i++) {
            state[i] = state[i - 1];
        }
        return seed != state[SIZE - 1];
    }

    public static void main(String[] args) {
        long count = IntStream.range(0, 0x0010_0000).filter(Main::test2).count();
        System.out.println(count);
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
disable the flag AllowVectorizeOnDemand disable 

FREQUENCY : always



Comments
This issue is already fixed by JDK-8251994
07-01-2021