Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8325520

Vector loads and stores with indices and masks incorrectly compiled

    XMLWordPrintable

Details

    • b25
    • generic
    • generic
    • Verified

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        Using WSL on Windows 11

        java --version
        java 21.0.1 2023-10-17 LTS
        Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29)
        Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)

        A DESCRIPTION OF THE PROBLEM :
        Loading a Vector using an offset map doesn't always work correctly once compiled. The data isn't loaded at all (there is no gather instruction in the outputted assembly), but instead another Vector seems incorrectly aliased.

        After ~110k loop iterations a single buggy iteration is run, and then starting at iteration ~185k a different buggy iteration is switched to.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the program below

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        (no output)
        ACTUAL -
        111142
        [1, 1, 1, 1]
        [1, 1, 1, 1]
        [1, 1, 1, 1]
        184869
        [1, 1, 1, 1]
        [1, 1, 1, 1]
        [0, 0, 0, 0]
        184870
        [1, 1, 1, 1]
        [1, 1, 1, 1]
        [0, 0, 0, 0]
        184871
        [1, 1, 1, 1]
        [1, 1, 1, 1]
        [0, 0, 0, 0]

        ....

        ---------- BEGIN SOURCE ----------
        import jdk.incubator.vector.LongVector;

        class Bug {
          public static void main(String[] args) {
            final long[] storage = new long[8];
            final int[] offsets = new int[]{4, 5, 6, 7};

            final LongVector ones = LongVector.broadcast(LongVector.SPECIES_256, 1);

            for (int i = 0 ; i < (1 << 30); i++) {
              ones.intoArray(storage, 0);
              LongVector a = LongVector.fromArray(LongVector.SPECIES_256, storage, 0, offsets, 0);
              LongVector b = LongVector.fromArray(LongVector.SPECIES_256, storage, 0, offsets, 0);

              if (ones.equals(a) || ones.equals(b)) {
                System.out.println(i);
                System.out.println(ones);
                System.out.println(a);
                System.out.println(b);
              }
            }
          }
        }
        ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

                dfenacci Damon Fenacci
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: