[lworld] C2's superword optimization should vectorize flat inline type array accesses

XMLWordPrintable

      The loops in testFill and testCopy are not vectorized if MyValue contains more than one field:

      public class Test {
          static inline class MyValue {
              int x = 42;
              int y = 42;
          }

          public static void testFill(MyValue[] array) {
              for (int i = 0; i < array.length; ++i) {
                  array[i] = new MyValue();
              }
          }
          
          public static void testCopy(MyValue[] array1, MyValue[] array2) {
              for (int i = 0; i < array1.length; ++i) {
                  array1[i] = array2[i];
              }
          }

          public static void main(String[] args) {
              MyValue[] array = new MyValue[100];
              for (int i = 0; i < 100_000; ++i) {
                  testFill(array);
                  testCopy(array, array);
              }
          }
      }

      Update: For JEP 401, flat arrays can only be created via an internal API. For example, via ValueClass.newNullRestrictedNonAtomicArray. Above test would need to be updated accordingly.

            Assignee:
            Unassigned
            Reporter:
            Tobias Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: