1 /*
   2  * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @modules jdk.incubator.vector
  27  * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation LongMaxVectorTests
  28  */
  29 
  30 // -- This file was mechanically generated: Do not edit! -- //
  31 
  32 import jdk.incubator.vector.VectorShape;
  33 import jdk.incubator.vector.VectorSpecies;
  34 import jdk.incubator.vector.VectorShuffle;
  35 import jdk.incubator.vector.VectorMask;
  36 import jdk.incubator.vector.VectorOperators;
  37 import jdk.incubator.vector.Vector;
  38 
  39 import jdk.incubator.vector.LongVector;
  40 
  41 import org.testng.Assert;
  42 import org.testng.annotations.DataProvider;
  43 import org.testng.annotations.Test;
  44 
  45 import java.lang.Integer;
  46 import java.util.List;
  47 import java.util.Arrays;
  48 import java.util.function.BiFunction;
  49 import java.util.function.IntFunction;
  50 import java.util.Objects;
  51 import java.util.stream.Collectors;
  52 import java.util.stream.Stream;
  53 
  54 @Test
  55 public class LongMaxVectorTests extends AbstractVectorTest {
  56 
  57     static final VectorSpecies<Long> SPECIES =
  58                 LongVector.SPECIES_MAX;
  59 
  60     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  61 
  62     static VectorShape getMaxBit() {
  63         return VectorShape.S_Max_BIT;
  64     }
  65 
  66     private static final int Max = 256;  // juts so we can do N/Max
  67 
  68     private static final long CONST_SHIFT = Long.SIZE / 2;
  69 
  70     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
  71 
  72     interface FUnOp {
  73         long apply(long a);
  74     }
  75 
  76     static void assertArraysEquals(long[] r, long[] a, FUnOp f) {
  77         int i = 0;
  78         try {
  79             for (; i < a.length; i++) {
  80                 Assert.assertEquals(r[i], f.apply(a[i]));
  81             }
  82         } catch (AssertionError e) {
  83             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  84         }
  85     }
  86 
  87     interface FUnArrayOp {
  88         long[] apply(long a);
  89     }
  90 
  91     static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) {
  92         int i = 0;
  93         try {
  94             for (; i < a.length; i += SPECIES.length()) {
  95                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
  96                   f.apply(a[i]));
  97             }
  98         } catch (AssertionError e) {
  99             long[] ref = f.apply(a[i]);
 100             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 101             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 102               + ", res: " + Arrays.toString(res)
 103               + "), at index #" + i);
 104         }
 105     }
 106 
 107     static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) {
 108         int i = 0;
 109         try {
 110             for (; i < a.length; i++) {
 111                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
 112             }
 113         } catch (AssertionError e) {
 114             Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
 115         }
 116     }
 117 
 118     interface FReductionOp {
 119         long apply(long[] a, int idx);
 120     }
 121 
 122     interface FReductionAllOp {
 123         long apply(long[] a);
 124     }
 125 
 126     static void assertReductionArraysEquals(long[] r, long rc, long[] a,
 127                                             FReductionOp f, FReductionAllOp fa) {
 128         int i = 0;
 129         try {
 130             Assert.assertEquals(rc, fa.apply(a));
 131             for (; i < a.length; i += SPECIES.length()) {
 132                 Assert.assertEquals(r[i], f.apply(a, i));
 133             }
 134         } catch (AssertionError e) {
 135             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 136             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 137         }
 138     }
 139 
 140     interface FReductionMaskedOp {
 141         long apply(long[] a, int idx, boolean[] mask);
 142     }
 143 
 144     interface FReductionAllMaskedOp {
 145         long apply(long[] a, boolean[] mask);
 146     }
 147 
 148     static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask,
 149                                             FReductionMaskedOp f, FReductionAllMaskedOp fa) {
 150         int i = 0;
 151         try {
 152             Assert.assertEquals(rc, fa.apply(a, mask));
 153             for (; i < a.length; i += SPECIES.length()) {
 154                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 155             }
 156         } catch (AssertionError e) {
 157             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 158             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 159         }
 160     }
 161 
 162 
 163     interface FBoolReductionOp {
 164         boolean apply(boolean[] a, int idx);
 165     }
 166 
 167     static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {
 168         int i = 0;
 169         try {
 170             for (; i < a.length; i += SPECIES.length()) {
 171                 Assert.assertEquals(r[i], f.apply(a, i));
 172             }
 173         } catch (AssertionError e) {
 174             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 175         }
 176     }
 177 
 178     interface FMaskReductionOp {
 179         int apply(boolean[] a, int idx);
 180     }
 181 
 182     static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) {
 183         int i = 0;
 184         try {
 185             for (; i < a.length; i += SPECIES.length()) {
 186                 Assert.assertEquals(r[i], f.apply(a, i));
 187             }
 188         } catch (AssertionError e) {
 189             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 190         }
 191     }
 192 
 193     static void assertInsertArraysEquals(long[] r, long[] a, long element, int index, int start, int end) {
 194         int i = start;
 195         try {
 196             for (; i < end; i += 1) {
 197                 if(i%SPECIES.length() == index) {
 198                     Assert.assertEquals(r[i], element);
 199                 } else {
 200                     Assert.assertEquals(r[i], a[i]);
 201                 }
 202             }
 203         } catch (AssertionError e) {
 204             if (i%SPECIES.length() == index) {
 205                 Assert.assertEquals(r[i], element, "at index #" + i);
 206             } else {
 207                 Assert.assertEquals(r[i], a[i], "at index #" + i);
 208             }
 209         }
 210     }
 211 
 212     static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) {
 213         int i = 0, j = 0;
 214         try {
 215             for (; i < a.length; i += vector_len) {
 216                 for (j = 0; j < vector_len; j++) {
 217                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 218                 }
 219             }
 220         } catch (AssertionError e) {
 221             int idx = i + j;
 222             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 223         }
 224     }
 225 
 226     static void assertcompressArraysEquals(long[] r, long[] a, boolean[] m, int vector_len) {
 227         int i = 0, j = 0, k = 0;
 228         try {
 229             for (; i < a.length; i += vector_len) {
 230                 k = 0;
 231                 for (j = 0; j < vector_len; j++) {
 232                     if (m[(i + j) % SPECIES.length()]) {
 233                         Assert.assertEquals(r[i + k], a[i + j]);
 234                         k++;
 235                     }
 236                 }
 237                 for (; k < vector_len; k++) {
 238                     Assert.assertEquals(r[i + k], (long)0);
 239                 }
 240             }
 241         } catch (AssertionError e) {
 242             int idx = i + k;
 243             if (m[(i + j) % SPECIES.length()]) {
 244                 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
 245             } else {
 246                 Assert.assertEquals(r[idx], (long)0, "at index #" + idx);
 247             }
 248         }
 249     }
 250 
 251     static void assertexpandArraysEquals(long[] r, long[] a, boolean[] m, int vector_len) {
 252         int i = 0, j = 0, k = 0;
 253         try {
 254             for (; i < a.length; i += vector_len) {
 255                 k = 0;
 256                 for (j = 0; j < vector_len; j++) {
 257                     if (m[(i + j) % SPECIES.length()]) {
 258                         Assert.assertEquals(r[i + j], a[i + k]);
 259                         k++;
 260                     } else {
 261                         Assert.assertEquals(r[i + j], (long)0);
 262                     }
 263                 }
 264             }
 265         } catch (AssertionError e) {
 266             int idx = i + j;
 267             if (m[idx % SPECIES.length()]) {
 268                 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
 269             } else {
 270                 Assert.assertEquals(r[idx], (long)0, "at index #" + idx);
 271             }
 272         }
 273     }
 274 
 275     static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) {
 276         int i = 0, j = 0;
 277         try {
 278             for (; i < a.length; i += vector_len) {
 279                 for (j = 0; j < vector_len; j++) {
 280                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 281                 }
 282             }
 283         } catch (AssertionError e) {
 284             int idx = i + j;
 285             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 286         }
 287     }
 288 
 289     static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) {
 290         int i = 0, j = 0;
 291         try {
 292             for (; i < a.length; i += vector_len) {
 293                 for (j = 0; j < vector_len; j++) {
 294                     if (mask[j % SPECIES.length()])
 295                          Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 296                     else
 297                          Assert.assertEquals(r[i+j], (long)0);
 298                 }
 299             }
 300         } catch (AssertionError e) {
 301             int idx = i + j;
 302             if (mask[j % SPECIES.length()])
 303                 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 304             else
 305                 Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 306         }
 307     }
 308 
 309     static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) {
 310         int i = 0, j = 0;
 311         try {
 312             for (; i < a.length; i += vector_len) {
 313                 for (j = 0; j < vector_len; j++) {
 314                     if (mask[j % SPECIES.length()])
 315                          Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 316                     else
 317                          Assert.assertEquals(r[i+j], (long)0);
 318                 }
 319             }
 320         } catch (AssertionError e) {
 321             int idx = i + j;
 322             if (mask[j % SPECIES.length()])
 323                 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 324             else
 325                 Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 326         }
 327     }
 328 
 329     static void assertBroadcastArraysEquals(long[] r, long[] a) {
 330         int i = 0;
 331         for (; i < a.length; i += SPECIES.length()) {
 332             int idx = i;
 333             for (int j = idx; j < (idx + SPECIES.length()); j++)
 334                 a[j]=a[idx];
 335         }
 336 
 337         try {
 338             for (i = 0; i < a.length; i++) {
 339                 Assert.assertEquals(r[i], a[i]);
 340             }
 341         } catch (AssertionError e) {
 342             Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
 343         }
 344     }
 345 
 346     interface FBinOp {
 347         long apply(long a, long b);
 348     }
 349 
 350     interface FBinMaskOp {
 351         long apply(long a, long b, boolean m);
 352 
 353         static FBinMaskOp lift(FBinOp f) {
 354             return (a, b, m) -> m ? f.apply(a, b) : a;
 355         }
 356     }
 357 
 358     static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {
 359         int i = 0;
 360         try {
 361             for (; i < a.length; i++) {
 362                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 363             }
 364         } catch (AssertionError e) {
 365             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 366         }
 367     }
 368 
 369     static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {
 370         int i = 0;
 371         try {
 372             for (; i < a.length; i++) {
 373                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 374             }
 375         } catch (AssertionError e) {
 376             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
 377                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 378         }
 379     }
 380 
 381     static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {
 382         int i = 0;
 383         try {
 384             for (; i < a.length; i++) {
 385                 Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
 386             }
 387         } catch (AssertionError e) {
 388             Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])),
 389                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 390         }
 391     }
 392 
 393     static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
 394         assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 395     }
 396 
 397     static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {
 398         int i = 0;
 399         try {
 400             for (; i < a.length; i++) {
 401                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 402             }
 403         } catch (AssertionError err) {
 404             Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
 405         }
 406     }
 407 
 408     static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
 409         assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 410     }
 411 
 412     static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {
 413         int i = 0;
 414         try {
 415             for (; i < a.length; i++) {
 416                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 417             }
 418         } catch (AssertionError err) {
 419             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 420                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 421                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 422                                 mask[i % SPECIES.length()]);
 423         }
 424     }
 425 
 426     static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
 427         assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 428     }
 429 
 430     static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {
 431         int i = 0;
 432         try {
 433             for (; i < a.length; i++) {
 434                 Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));
 435             }
 436         } catch (AssertionError err) {
 437             Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]),
 438                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 439                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 440                                 mask[i % SPECIES.length()]);
 441         }
 442     }
 443 
 444     static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {
 445         int i = 0;
 446         int j = 0;
 447         try {
 448             for (; j < a.length; j += SPECIES.length()) {
 449                 for (i = 0; i < SPECIES.length(); i++) {
 450                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 451                 }
 452             }
 453         } catch (AssertionError e) {
 454             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 455         }
 456     }
 457 
 458     static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {
 459         assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 460     }
 461 
 462     static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {
 463         int i = 0;
 464         int j = 0;
 465         try {
 466             for (; j < a.length; j += SPECIES.length()) {
 467                 for (i = 0; i < SPECIES.length(); i++) {
 468                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 469                 }
 470             }
 471         } catch (AssertionError err) {
 472             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]);
 473         }
 474     }
 475 
 476     interface FBinConstOp {
 477         long apply(long a);
 478     }
 479 
 480     interface FBinConstMaskOp {
 481         long apply(long a, boolean m);
 482 
 483         static FBinConstMaskOp lift(FBinConstOp f) {
 484             return (a, m) -> m ? f.apply(a) : a;
 485         }
 486     }
 487 
 488     static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) {
 489         int i = 0;
 490         int j = 0;
 491         try {
 492             for (; j < a.length; j += SPECIES.length()) {
 493                 for (i = 0; i < SPECIES.length(); i++) {
 494                     Assert.assertEquals(r[i+j], f.apply(a[i+j]));
 495                 }
 496             }
 497         } catch (AssertionError e) {
 498             Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
 499         }
 500     }
 501 
 502     static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstOp f) {
 503         assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
 504     }
 505 
 506     static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstMaskOp f) {
 507         int i = 0;
 508         int j = 0;
 509         try {
 510             for (; j < a.length; j += SPECIES.length()) {
 511                 for (i = 0; i < SPECIES.length(); i++) {
 512                     Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
 513                 }
 514             }
 515         } catch (AssertionError err) {
 516             Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
 517         }
 518     }
 519 
 520     interface FTernOp {
 521         long apply(long a, long b, long c);
 522     }
 523 
 524     interface FTernMaskOp {
 525         long apply(long a, long b, long c, boolean m);
 526 
 527         static FTernMaskOp lift(FTernOp f) {
 528             return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
 529         }
 530     }
 531 
 532     static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {
 533         int i = 0;
 534         try {
 535             for (; i < a.length; i++) {
 536                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
 537             }
 538         } catch (AssertionError e) {
 539             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 540         }
 541     }
 542 
 543     static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) {
 544         assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 545     }
 546 
 547     static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) {
 548         int i = 0;
 549         try {
 550             for (; i < a.length; i++) {
 551                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
 552             }
 553         } catch (AssertionError err) {
 554             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
 555               + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 556         }
 557     }
 558 
 559     static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {
 560         int i = 0;
 561         try {
 562             for (; i < a.length; i++) {
 563                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));
 564             }
 565         } catch (AssertionError e) {
 566             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +
 567                                 i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +
 568                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 569         }
 570     }
 571 
 572     static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {
 573         int i = 0;
 574         try {
 575             for (; i < a.length; i++) {
 576                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));
 577             }
 578         } catch (AssertionError e) {
 579             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +
 580                                 i + ", input1 = " + a[i] + ", input2 = " +
 581                                 b[(i / SPECIES.length()) * SPECIES.length()] + ",  input3 = " + c[i]);
 582         }
 583     }
 584 
 585     static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
 586                                             FTernOp f) {
 587         assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 588     }
 589 
 590     static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
 591                                             FTernMaskOp f) {
 592         int i = 0;
 593         try {
 594             for (; i < a.length; i++) {
 595                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 596                                     mask[i % SPECIES.length()]));
 597             }
 598         } catch (AssertionError err) {
 599             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 600                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
 601                                 b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 602                                 mask[i % SPECIES.length()]);
 603         }
 604     }
 605 
 606     static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
 607                                             FTernOp f) {
 608         assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 609     }
 610 
 611     static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
 612                                             FTernMaskOp f) {
 613         int i = 0;
 614         try {
 615             for (; i < a.length; i++) {
 616                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 617                                     mask[i % SPECIES.length()]));
 618             }
 619         } catch (AssertionError err) {
 620             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 621                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 622                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 623                                 ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 624         }
 625     }
 626 
 627     static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {
 628         int i = 0;
 629         try {
 630             for (; i < a.length; i++) {
 631                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 632                                     c[(i / SPECIES.length()) * SPECIES.length()]));
 633             }
 634         } catch (AssertionError e) {
 635             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 636                                 c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]
 637                                 + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +
 638                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 639         }
 640     }
 641 
 642     static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
 643                                                   FTernOp f) {
 644         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 645     }
 646 
 647     static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,
 648                                                   FTernMaskOp f) {
 649         int i = 0;
 650         try {
 651             for (; i < a.length; i++) {
 652                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 653                                     c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 654             }
 655         } catch (AssertionError err) {
 656             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 657                                 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"
 658                                 + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 659                                 ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 660                                 mask[i % SPECIES.length()]);
 661         }
 662     }
 663 
 664 
 665 
 666     interface FBinArrayOp {
 667         long apply(long[] a, int b);
 668     }
 669 
 670     static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) {
 671         int i = 0;
 672         try {
 673             for (; i < a.length; i++) {
 674                 Assert.assertEquals(r[i], f.apply(a, i));
 675             }
 676         } catch (AssertionError e) {
 677             Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i);
 678         }
 679     }
 680 
 681     interface FGatherScatterOp {
 682         long[] apply(long[] a, int ix, int[] b, int iy);
 683     }
 684 
 685     static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) {
 686         int i = 0;
 687         try {
 688             for (; i < a.length; i += SPECIES.length()) {
 689                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 690                   f.apply(a, i, b, i));
 691             }
 692         } catch (AssertionError e) {
 693             long[] ref = f.apply(a, i, b, i);
 694             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 695             Assert.assertEquals(res, ref,
 696               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 697               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 698               + ", b: "
 699               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 700               + " at index #" + i);
 701         }
 702     }
 703 
 704     interface FGatherMaskedOp {
 705         long[] apply(long[] a, int ix, boolean[] mask, int[] b, int iy);
 706     }
 707 
 708     interface FScatterMaskedOp {
 709         long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy);
 710     }
 711 
 712     static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {
 713         int i = 0;
 714         try {
 715             for (; i < a.length; i += SPECIES.length()) {
 716                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 717                   f.apply(a, i, mask, b, i));
 718             }
 719         } catch (AssertionError e) {
 720             long[] ref = f.apply(a, i, mask, b, i);
 721             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 722             Assert.assertEquals(res, ref,
 723               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 724               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 725               + ", b: "
 726               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 727               + ", mask: "
 728               + Arrays.toString(mask)
 729               + " at index #" + i);
 730         }
 731     }
 732 
 733     static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {
 734         int i = 0;
 735         try {
 736             for (; i < a.length; i += SPECIES.length()) {
 737                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 738                   f.apply(r, a, i, mask, b, i));
 739             }
 740         } catch (AssertionError e) {
 741             long[] ref = f.apply(r, a, i, mask, b, i);
 742             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 743             Assert.assertEquals(res, ref,
 744               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 745               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 746               + ", b: "
 747               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 748               + ", r: "
 749               + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))
 750               + ", mask: "
 751               + Arrays.toString(mask)
 752               + " at index #" + i);
 753         }
 754     }
 755 
 756     interface FLaneOp {
 757         long[] apply(long[] a, int origin, int idx);
 758     }
 759 
 760     static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) {
 761         int i = 0;
 762         try {
 763             for (; i < a.length; i += SPECIES.length()) {
 764                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 765                   f.apply(a, origin, i));
 766             }
 767         } catch (AssertionError e) {
 768             long[] ref = f.apply(a, origin, i);
 769             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 770             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 771               + ", res: " + Arrays.toString(res)
 772               + "), at index #" + i);
 773         }
 774     }
 775 
 776     interface FLaneBop {
 777         long[] apply(long[] a, long[] b, int origin, int idx);
 778     }
 779 
 780     static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) {
 781         int i = 0;
 782         try {
 783             for (; i < a.length; i += SPECIES.length()) {
 784                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 785                   f.apply(a, b, origin, i));
 786             }
 787         } catch (AssertionError e) {
 788             long[] ref = f.apply(a, b, origin, i);
 789             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 790             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 791               + ", res: " + Arrays.toString(res)
 792               + "), at index #" + i
 793               + ", at origin #" + origin);
 794         }
 795     }
 796 
 797     interface FLaneMaskedBop {
 798         long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx);
 799     }
 800 
 801     static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) {
 802         int i = 0;
 803         try {
 804             for (; i < a.length; i += SPECIES.length()) {
 805                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 806                   f.apply(a, b, origin, mask, i));
 807             }
 808         } catch (AssertionError e) {
 809             long[] ref = f.apply(a, b, origin, mask, i);
 810             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 811             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 812               + ", res: " + Arrays.toString(res)
 813               + "), at index #" + i
 814               + ", at origin #" + origin);
 815         }
 816     }
 817 
 818     interface FLanePartBop {
 819         long[] apply(long[] a, long[] b, int origin, int part, int idx);
 820     }
 821 
 822     static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) {
 823         int i = 0;
 824         try {
 825             for (; i < a.length; i += SPECIES.length()) {
 826                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 827                   f.apply(a, b, origin, part, i));
 828             }
 829         } catch (AssertionError e) {
 830             long[] ref = f.apply(a, b, origin, part, i);
 831             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 832             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 833               + ", res: " + Arrays.toString(res)
 834               + "), at index #" + i
 835               + ", at origin #" + origin
 836               + ", with part #" + part);
 837         }
 838     }
 839 
 840     interface FLanePartMaskedBop {
 841         long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx);
 842     }
 843 
 844     static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {
 845         int i = 0;
 846         try {
 847             for (; i < a.length; i += SPECIES.length()) {
 848                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 849                   f.apply(a, b, origin, part, mask, i));
 850             }
 851         } catch (AssertionError e) {
 852             long[] ref = f.apply(a, b, origin, part, mask, i);
 853             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 854             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 855               + ", res: " + Arrays.toString(res)
 856               + "), at index #" + i
 857               + ", at origin #" + origin
 858               + ", with part #" + part);
 859         }
 860     }
 861 
 862     static int intCornerCaseValue(int i) {
 863         switch(i % 5) {
 864             case 0:
 865                 return Integer.MAX_VALUE;
 866             case 1:
 867                 return Integer.MIN_VALUE;
 868             case 2:
 869                 return Integer.MIN_VALUE;
 870             case 3:
 871                 return Integer.MAX_VALUE;
 872             default:
 873                 return (int)0;
 874         }
 875     }
 876 
 877     static final List<IntFunction<long[]>> INT_LONG_GENERATORS = List.of(
 878             withToString("long[-i * 5]", (int s) -> {
 879                 return fill(s * BUFFER_REPS,
 880                             i -> (long)(-i * 5));
 881             }),
 882             withToString("long[i * 5]", (int s) -> {
 883                 return fill(s * BUFFER_REPS,
 884                             i -> (long)(i * 5));
 885             }),
 886             withToString("long[i + 1]", (int s) -> {
 887                 return fill(s * BUFFER_REPS,
 888                             i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1)));
 889             }),
 890             withToString("long[intCornerCaseValue(i)]", (int s) -> {
 891                 return fill(s * BUFFER_REPS,
 892                             i -> (long)intCornerCaseValue(i));
 893             })
 894     );
 895 
 896     static void assertArraysEquals(int[] r, long[] a, int offs) {
 897         int i = 0;
 898         try {
 899             for (; i < r.length; i++) {
 900                 Assert.assertEquals(r[i], (int)(a[i+offs]));
 901             }
 902         } catch (AssertionError e) {
 903             Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 904         }
 905     }
 906 
 907 
 908 
 909     static void assertArraysEquals(long[] r, long[] a, int offs) {
 910         int i = 0;
 911         try {
 912             for (; i < r.length; i++) {
 913                 Assert.assertEquals(r[i], (long)(a[i+offs]));
 914             }
 915         } catch (AssertionError e) {
 916             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 917         }
 918     }
 919 
 920     static void assertArraysEquals(double[] r, long[] a, int offs) {
 921         int i = 0;
 922         try {
 923             for (; i < r.length; i++) {
 924                 Assert.assertEquals(r[i], (double)(a[i+offs]));
 925             }
 926         } catch (AssertionError e) {
 927             Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 928         }
 929     }
 930 
 931     static long bits(long e) {
 932         return  e;
 933     }
 934 
 935     static final List<IntFunction<long[]>> LONG_GENERATORS = List.of(
 936             withToString("long[-i * 5]", (int s) -> {
 937                 return fill(s * BUFFER_REPS,
 938                             i -> (long)(-i * 5));
 939             }),
 940             withToString("long[i * 5]", (int s) -> {
 941                 return fill(s * BUFFER_REPS,
 942                             i -> (long)(i * 5));
 943             }),
 944             withToString("long[i + 1]", (int s) -> {
 945                 return fill(s * BUFFER_REPS,
 946                             i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1)));
 947             }),
 948             withToString("long[cornerCaseValue(i)]", (int s) -> {
 949                 return fill(s * BUFFER_REPS,
 950                             i -> cornerCaseValue(i));
 951             })
 952     );
 953 
 954     // Create combinations of pairs
 955     // @@@ Might be sensitive to order e.g. div by 0
 956     static final List<List<IntFunction<long[]>>> LONG_GENERATOR_PAIRS =
 957         Stream.of(LONG_GENERATORS.get(0)).
 958                 flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
 959                 collect(Collectors.toList());
 960 
 961     @DataProvider
 962     public Object[][] boolUnaryOpProvider() {
 963         return BOOL_ARRAY_GENERATORS.stream().
 964                 map(f -> new Object[]{f}).
 965                 toArray(Object[][]::new);
 966     }
 967 
 968     static final List<List<IntFunction<long[]>>> LONG_GENERATOR_TRIPLES =
 969         LONG_GENERATOR_PAIRS.stream().
 970                 flatMap(pair -> LONG_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
 971                 collect(Collectors.toList());
 972 
 973     @DataProvider
 974     public Object[][] longBinaryOpProvider() {
 975         return LONG_GENERATOR_PAIRS.stream().map(List::toArray).
 976                 toArray(Object[][]::new);
 977     }
 978 
 979     @DataProvider
 980     public Object[][] longIndexedOpProvider() {
 981         return LONG_GENERATOR_PAIRS.stream().map(List::toArray).
 982                 toArray(Object[][]::new);
 983     }
 984 
 985     @DataProvider
 986     public Object[][] longBinaryOpMaskProvider() {
 987         return BOOLEAN_MASK_GENERATORS.stream().
 988                 flatMap(fm -> LONG_GENERATOR_PAIRS.stream().map(lfa -> {
 989                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 990                 })).
 991                 toArray(Object[][]::new);
 992     }
 993 
 994     @DataProvider
 995     public Object[][] longTernaryOpProvider() {
 996         return LONG_GENERATOR_TRIPLES.stream().map(List::toArray).
 997                 toArray(Object[][]::new);
 998     }
 999 
1000     @DataProvider
1001     public Object[][] longTernaryOpMaskProvider() {
1002         return BOOLEAN_MASK_GENERATORS.stream().
1003                 flatMap(fm -> LONG_GENERATOR_TRIPLES.stream().map(lfa -> {
1004                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1005                 })).
1006                 toArray(Object[][]::new);
1007     }
1008 
1009     @DataProvider
1010     public Object[][] longUnaryOpProvider() {
1011         return LONG_GENERATORS.stream().
1012                 map(f -> new Object[]{f}).
1013                 toArray(Object[][]::new);
1014     }
1015 
1016     @DataProvider
1017     public Object[][] longUnaryOpMaskProvider() {
1018         return BOOLEAN_MASK_GENERATORS.stream().
1019                 flatMap(fm -> LONG_GENERATORS.stream().map(fa -> {
1020                     return new Object[] {fa, fm};
1021                 })).
1022                 toArray(Object[][]::new);
1023     }
1024 
1025     @DataProvider
1026     public Object[][] longtoIntUnaryOpProvider() {
1027         return INT_LONG_GENERATORS.stream().
1028                 map(f -> new Object[]{f}).
1029                 toArray(Object[][]::new);
1030     }
1031 
1032     @DataProvider
1033     public Object[][] maskProvider() {
1034         return BOOLEAN_MASK_GENERATORS.stream().
1035                 map(f -> new Object[]{f}).
1036                 toArray(Object[][]::new);
1037     }
1038 
1039     @DataProvider
1040     public Object[][] maskCompareOpProvider() {
1041         return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1042                 toArray(Object[][]::new);
1043     }
1044 
1045     @DataProvider
1046     public Object[][] shuffleProvider() {
1047         return INT_SHUFFLE_GENERATORS.stream().
1048                 map(f -> new Object[]{f}).
1049                 toArray(Object[][]::new);
1050     }
1051 
1052     @DataProvider
1053     public Object[][] shuffleCompareOpProvider() {
1054         return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1055                 toArray(Object[][]::new);
1056     }
1057 
1058     @DataProvider
1059     public Object[][] longUnaryOpShuffleProvider() {
1060         return INT_SHUFFLE_GENERATORS.stream().
1061                 flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
1062                     return new Object[] {fa, fs};
1063                 })).
1064                 toArray(Object[][]::new);
1065     }
1066 
1067     @DataProvider
1068     public Object[][] longUnaryOpShuffleMaskProvider() {
1069         return BOOLEAN_MASK_GENERATORS.stream().
1070                 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1071                     flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
1072                         return new Object[] {fa, fs, fm};
1073                 }))).
1074                 toArray(Object[][]::new);
1075     }
1076 
1077     static final List<BiFunction<Integer,Integer,long[]>> LONG_SHUFFLE_GENERATORS = List.of(
1078             withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
1079                 long[] a = new long[l];
1080                 int upper = m;
1081                 for (int i = 0; i < 1; i++) {
1082                     a[i] = (long)RAND.nextInt(upper);
1083                 }
1084                 return a;
1085             })
1086     );
1087 
1088     @DataProvider
1089     public Object[][] longUnaryOpSelectFromProvider() {
1090         return LONG_SHUFFLE_GENERATORS.stream().
1091                 flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
1092                     return new Object[] {fa, fs};
1093                 })).
1094                 toArray(Object[][]::new);
1095     }
1096 
1097     @DataProvider
1098     public Object[][] longUnaryOpSelectFromMaskProvider() {
1099         return BOOLEAN_MASK_GENERATORS.stream().
1100                 flatMap(fm -> LONG_SHUFFLE_GENERATORS.stream().
1101                     flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
1102                         return new Object[] {fa, fs, fm};
1103                 }))).
1104                 toArray(Object[][]::new);
1105     }
1106 
1107     static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(
1108             withToString("long[i]", (int s) -> {
1109                 return fill(s * BUFFER_REPS,
1110                             i -> (long)i);
1111             }),
1112             withToString("long[i - length / 2]", (int s) -> {
1113                 return fill(s * BUFFER_REPS,
1114                             i -> (long)(i - (s * BUFFER_REPS / 2)));
1115             }),
1116             withToString("long[i + 1]", (int s) -> {
1117                 return fill(s * BUFFER_REPS,
1118                             i -> (long)(i + 1));
1119             }),
1120             withToString("long[i - 2]", (int s) -> {
1121                 return fill(s * BUFFER_REPS,
1122                             i -> (long)(i - 2));
1123             }),
1124             withToString("long[zigZag(i)]", (int s) -> {
1125                 return fill(s * BUFFER_REPS,
1126                             i -> i%3 == 0 ? (long)i : (i%3 == 1 ? (long)(i + 1) : (long)(i - 2)));
1127             }),
1128             withToString("long[cornerCaseValue(i)]", (int s) -> {
1129                 return fill(s * BUFFER_REPS,
1130                             i -> cornerCaseValue(i));
1131             })
1132     );
1133 
1134     static final List<List<IntFunction<long[]>>> LONG_TEST_GENERATOR_ARGS =
1135         LONG_COMPARE_GENERATORS.stream().
1136                 map(fa -> List.of(fa)).
1137                 collect(Collectors.toList());
1138 
1139     @DataProvider
1140     public Object[][] longTestOpProvider() {
1141         return LONG_TEST_GENERATOR_ARGS.stream().map(List::toArray).
1142                 toArray(Object[][]::new);
1143     }
1144 
1145     @DataProvider
1146     public Object[][] longTestOpMaskProvider() {
1147         return BOOLEAN_MASK_GENERATORS.stream().
1148                 flatMap(fm -> LONG_TEST_GENERATOR_ARGS.stream().map(lfa -> {
1149                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1150                 })).
1151                 toArray(Object[][]::new);
1152     }
1153 
1154     static final List<List<IntFunction<long[]>>> LONG_COMPARE_GENERATOR_PAIRS =
1155         LONG_COMPARE_GENERATORS.stream().
1156                 flatMap(fa -> LONG_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
1157                 collect(Collectors.toList());
1158 
1159     @DataProvider
1160     public Object[][] longCompareOpProvider() {
1161         return LONG_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1162                 toArray(Object[][]::new);
1163     }
1164 
1165     @DataProvider
1166     public Object[][] longCompareOpMaskProvider() {
1167         return BOOLEAN_MASK_GENERATORS.stream().
1168                 flatMap(fm -> LONG_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {
1169                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1170                 })).
1171                 toArray(Object[][]::new);
1172     }
1173 
1174     interface ToLongF {
1175         long apply(int i);
1176     }
1177 
1178     static long[] fill(int s , ToLongF f) {
1179         return fill(new long[s], f);
1180     }
1181 
1182     static long[] fill(long[] a, ToLongF f) {
1183         for (int i = 0; i < a.length; i++) {
1184             a[i] = f.apply(i);
1185         }
1186         return a;
1187     }
1188 
1189     static long cornerCaseValue(int i) {
1190         switch(i % 5) {
1191             case 0:
1192                 return Long.MAX_VALUE;
1193             case 1:
1194                 return Long.MIN_VALUE;
1195             case 2:
1196                 return Long.MIN_VALUE;
1197             case 3:
1198                 return Long.MAX_VALUE;
1199             default:
1200                 return (long)0;
1201         }
1202     }
1203 
1204     static long get(long[] a, int i) {
1205         return (long) a[i];
1206     }
1207 
1208     static final IntFunction<long[]> fr = (vl) -> {
1209         int length = BUFFER_REPS * vl;
1210         return new long[length];
1211     };
1212 
1213     static final IntFunction<boolean[]> fmr = (vl) -> {
1214         int length = BUFFER_REPS * vl;
1215         return new boolean[length];
1216     };
1217 
1218     static void replaceZero(long[] a, long v) {
1219         for (int i = 0; i < a.length; i++) {
1220             if (a[i] == 0) {
1221                 a[i] = v;
1222             }
1223         }
1224     }
1225 
1226     static void replaceZero(long[] a, boolean[] mask, long v) {
1227         for (int i = 0; i < a.length; i++) {
1228             if (mask[i % mask.length] && a[i] == 0) {
1229                 a[i] = v;
1230             }
1231         }
1232     }
1233 
1234     static long ROL_scalar(long a, long b) {
1235         return Long.rotateLeft(a, ((int)b));
1236     }
1237 
1238     static long ROR_scalar(long a, long b) {
1239         return Long.rotateRight(a, ((int)b));
1240     }
1241 
1242     static long TRAILING_ZEROS_COUNT_scalar(long a) {
1243         return Long.numberOfTrailingZeros(a);
1244     }
1245 
1246     static long LEADING_ZEROS_COUNT_scalar(long a) {
1247         return Long.numberOfLeadingZeros(a);
1248     }
1249 
1250     static long REVERSE_scalar(long a) {
1251         return Long.reverse(a);
1252     }
1253 
1254     static boolean eq(long a, long b) {
1255         return a == b;
1256     }
1257 
1258     static boolean neq(long a, long b) {
1259         return a != b;
1260     }
1261 
1262     static boolean lt(long a, long b) {
1263         return a < b;
1264     }
1265 
1266     static boolean le(long a, long b) {
1267         return a <= b;
1268     }
1269 
1270     static boolean gt(long a, long b) {
1271         return a > b;
1272     }
1273 
1274     static boolean ge(long a, long b) {
1275         return a >= b;
1276     }
1277 
1278     static boolean ult(long a, long b) {
1279         return Long.compareUnsigned(a, b) < 0;
1280     }
1281 
1282     static boolean ule(long a, long b) {
1283         return Long.compareUnsigned(a, b) <= 0;
1284     }
1285 
1286     static boolean ugt(long a, long b) {
1287         return Long.compareUnsigned(a, b) > 0;
1288     }
1289 
1290     static boolean uge(long a, long b) {
1291         return Long.compareUnsigned(a, b) >= 0;
1292     }
1293 
1294     static long firstNonZero(long a, long b) {
1295         return Long.compare(a, (long) 0) != 0 ? a : b;
1296     }
1297 
1298     @Test
1299     static void smokeTest1() {
1300         LongVector three = LongVector.broadcast(SPECIES, (byte)-3);
1301         LongVector three2 = (LongVector) SPECIES.broadcast(-3);
1302         assert(three.eq(three2).allTrue());
1303         LongVector three3 = three2.broadcast(1).broadcast(-3);
1304         assert(three.eq(three3).allTrue());
1305         int scale = 2;
1306         Class<?> ETYPE = long.class;
1307         if (ETYPE == double.class || ETYPE == long.class)
1308             scale = 1000000;
1309         else if (ETYPE == byte.class && SPECIES.length() >= 64)
1310             scale = 1;
1311         LongVector higher = three.addIndex(scale);
1312         VectorMask<Long> m = three.compare(VectorOperators.LE, higher);
1313         assert(m.allTrue());
1314         m = higher.min((long)-1).test(VectorOperators.IS_NEGATIVE);
1315         assert(m.allTrue());
1316         long max = higher.reduceLanes(VectorOperators.MAX);
1317         assert(max == -3 + scale * (SPECIES.length()-1));
1318     }
1319 
1320     private static long[]
1321     bothToArray(LongVector a, LongVector b) {
1322         long[] r = new long[a.length() + b.length()];
1323         a.intoArray(r, 0);
1324         b.intoArray(r, a.length());
1325         return r;
1326     }
1327 
1328     @Test
1329     static void smokeTest2() {
1330         // Do some zipping and shuffling.
1331         LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1);
1332         LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
1333         Assert.assertEquals(io, io2);
1334         LongVector a = io.add((long)1); //[1,2]
1335         LongVector b = a.neg();  //[-1,-2]
1336         long[] abValues = bothToArray(a,b); //[1,2,-1,-2]
1337         VectorShuffle<Long> zip0 = VectorShuffle.makeZip(SPECIES, 0);
1338         VectorShuffle<Long> zip1 = VectorShuffle.makeZip(SPECIES, 1);
1339         LongVector zab0 = a.rearrange(zip0,b); //[1,-1]
1340         LongVector zab1 = a.rearrange(zip1,b); //[2,-2]
1341         long[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
1342         // manually zip
1343         long[] manual = new long[zabValues.length];
1344         for (int i = 0; i < manual.length; i += 2) {
1345             manual[i+0] = abValues[i/2];
1346             manual[i+1] = abValues[a.length() + i/2];
1347         }
1348         Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
1349         VectorShuffle<Long> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
1350         VectorShuffle<Long> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
1351         LongVector uab0 = zab0.rearrange(unz0,zab1);
1352         LongVector uab1 = zab0.rearrange(unz1,zab1);
1353         long[] abValues1 = bothToArray(uab0, uab1);
1354         Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
1355     }
1356 
1357     static void iotaShuffle() {
1358         LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1);
1359         LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
1360         Assert.assertEquals(io, io2);
1361     }
1362 
1363     @Test
1364     // Test all shuffle related operations.
1365     static void shuffleTest() {
1366         // To test backend instructions, make sure that C2 is used.
1367         for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
1368             iotaShuffle();
1369         }
1370     }
1371 
1372     @Test
1373     void viewAsIntegeralLanesTest() {
1374         Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
1375         Assert.assertEquals(asIntegral.species(), SPECIES);
1376     }
1377 
1378     @Test
1379     void viewAsFloatingLanesTest() {
1380         Vector<?> asFloating = SPECIES.zero().viewAsFloatingLanes();
1381         VectorSpecies<?> asFloatingSpecies = asFloating.species();
1382         Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType());
1383         Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape());
1384         Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length());
1385         Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES);
1386     }
1387 
1388     @Test
1389     // Test div by 0.
1390     static void bitwiseDivByZeroSmokeTest() {
1391         try {
1392             LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1);
1393             LongVector b = (LongVector) SPECIES.broadcast(0);
1394             a.div(b);
1395             Assert.fail();
1396         } catch (ArithmeticException e) {
1397         }
1398 
1399         try {
1400             LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1);
1401             LongVector b = (LongVector) SPECIES.broadcast(0);
1402             VectorMask<Long> m = a.lt((long) 1);
1403             a.div(b, m);
1404             Assert.fail();
1405         } catch (ArithmeticException e) {
1406         }
1407     }
1408 
1409     static long ADD(long a, long b) {
1410         return (long)(a + b);
1411     }
1412 
1413     @Test(dataProvider = "longBinaryOpProvider")
1414     static void ADDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1415         long[] a = fa.apply(SPECIES.length());
1416         long[] b = fb.apply(SPECIES.length());
1417         long[] r = fr.apply(SPECIES.length());
1418 
1419         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1420             for (int i = 0; i < a.length; i += SPECIES.length()) {
1421                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1422                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1423                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1424             }
1425         }
1426 
1427         assertArraysEquals(r, a, b, LongMaxVectorTests::ADD);
1428     }
1429 
1430     static long add(long a, long b) {
1431         return (long)(a + b);
1432     }
1433 
1434     @Test(dataProvider = "longBinaryOpProvider")
1435     static void addLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1436         long[] a = fa.apply(SPECIES.length());
1437         long[] b = fb.apply(SPECIES.length());
1438         long[] r = fr.apply(SPECIES.length());
1439 
1440         for (int i = 0; i < a.length; i += SPECIES.length()) {
1441             LongVector av = LongVector.fromArray(SPECIES, a, i);
1442             LongVector bv = LongVector.fromArray(SPECIES, b, i);
1443             av.add(bv).intoArray(r, i);
1444         }
1445 
1446         assertArraysEquals(r, a, b, LongMaxVectorTests::add);
1447     }
1448 
1449     @Test(dataProvider = "longBinaryOpMaskProvider")
1450     static void ADDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1451                                           IntFunction<boolean[]> fm) {
1452         long[] a = fa.apply(SPECIES.length());
1453         long[] b = fb.apply(SPECIES.length());
1454         long[] r = fr.apply(SPECIES.length());
1455         boolean[] mask = fm.apply(SPECIES.length());
1456         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1457 
1458         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1459             for (int i = 0; i < a.length; i += SPECIES.length()) {
1460                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1461                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1462                 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
1463             }
1464         }
1465 
1466         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ADD);
1467     }
1468 
1469     @Test(dataProvider = "longBinaryOpMaskProvider")
1470     static void addLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1471                                           IntFunction<boolean[]> fm) {
1472         long[] a = fa.apply(SPECIES.length());
1473         long[] b = fb.apply(SPECIES.length());
1474         long[] r = fr.apply(SPECIES.length());
1475         boolean[] mask = fm.apply(SPECIES.length());
1476         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1477 
1478         for (int i = 0; i < a.length; i += SPECIES.length()) {
1479             LongVector av = LongVector.fromArray(SPECIES, a, i);
1480             LongVector bv = LongVector.fromArray(SPECIES, b, i);
1481             av.add(bv, vmask).intoArray(r, i);
1482         }
1483 
1484         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::add);
1485     }
1486 
1487     static long SUB(long a, long b) {
1488         return (long)(a - b);
1489     }
1490 
1491     @Test(dataProvider = "longBinaryOpProvider")
1492     static void SUBLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1493         long[] a = fa.apply(SPECIES.length());
1494         long[] b = fb.apply(SPECIES.length());
1495         long[] r = fr.apply(SPECIES.length());
1496 
1497         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1498             for (int i = 0; i < a.length; i += SPECIES.length()) {
1499                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1500                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1501                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1502             }
1503         }
1504 
1505         assertArraysEquals(r, a, b, LongMaxVectorTests::SUB);
1506     }
1507 
1508     static long sub(long a, long b) {
1509         return (long)(a - b);
1510     }
1511 
1512     @Test(dataProvider = "longBinaryOpProvider")
1513     static void subLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1514         long[] a = fa.apply(SPECIES.length());
1515         long[] b = fb.apply(SPECIES.length());
1516         long[] r = fr.apply(SPECIES.length());
1517 
1518         for (int i = 0; i < a.length; i += SPECIES.length()) {
1519             LongVector av = LongVector.fromArray(SPECIES, a, i);
1520             LongVector bv = LongVector.fromArray(SPECIES, b, i);
1521             av.sub(bv).intoArray(r, i);
1522         }
1523 
1524         assertArraysEquals(r, a, b, LongMaxVectorTests::sub);
1525     }
1526 
1527     @Test(dataProvider = "longBinaryOpMaskProvider")
1528     static void SUBLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1529                                           IntFunction<boolean[]> fm) {
1530         long[] a = fa.apply(SPECIES.length());
1531         long[] b = fb.apply(SPECIES.length());
1532         long[] r = fr.apply(SPECIES.length());
1533         boolean[] mask = fm.apply(SPECIES.length());
1534         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1535 
1536         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1537             for (int i = 0; i < a.length; i += SPECIES.length()) {
1538                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1539                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1540                 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1541             }
1542         }
1543 
1544         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUB);
1545     }
1546 
1547     @Test(dataProvider = "longBinaryOpMaskProvider")
1548     static void subLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1549                                           IntFunction<boolean[]> fm) {
1550         long[] a = fa.apply(SPECIES.length());
1551         long[] b = fb.apply(SPECIES.length());
1552         long[] r = fr.apply(SPECIES.length());
1553         boolean[] mask = fm.apply(SPECIES.length());
1554         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1555 
1556         for (int i = 0; i < a.length; i += SPECIES.length()) {
1557             LongVector av = LongVector.fromArray(SPECIES, a, i);
1558             LongVector bv = LongVector.fromArray(SPECIES, b, i);
1559             av.sub(bv, vmask).intoArray(r, i);
1560         }
1561 
1562         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::sub);
1563     }
1564 
1565     static long MUL(long a, long b) {
1566         return (long)(a * b);
1567     }
1568 
1569     @Test(dataProvider = "longBinaryOpProvider")
1570     static void MULLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1571         long[] a = fa.apply(SPECIES.length());
1572         long[] b = fb.apply(SPECIES.length());
1573         long[] r = fr.apply(SPECIES.length());
1574 
1575         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1576             for (int i = 0; i < a.length; i += SPECIES.length()) {
1577                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1578                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1579                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1580             }
1581         }
1582 
1583         assertArraysEquals(r, a, b, LongMaxVectorTests::MUL);
1584     }
1585 
1586     static long mul(long a, long b) {
1587         return (long)(a * b);
1588     }
1589 
1590     @Test(dataProvider = "longBinaryOpProvider")
1591     static void mulLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1592         long[] a = fa.apply(SPECIES.length());
1593         long[] b = fb.apply(SPECIES.length());
1594         long[] r = fr.apply(SPECIES.length());
1595 
1596         for (int i = 0; i < a.length; i += SPECIES.length()) {
1597             LongVector av = LongVector.fromArray(SPECIES, a, i);
1598             LongVector bv = LongVector.fromArray(SPECIES, b, i);
1599             av.mul(bv).intoArray(r, i);
1600         }
1601 
1602         assertArraysEquals(r, a, b, LongMaxVectorTests::mul);
1603     }
1604 
1605     @Test(dataProvider = "longBinaryOpMaskProvider")
1606     static void MULLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1607                                           IntFunction<boolean[]> fm) {
1608         long[] a = fa.apply(SPECIES.length());
1609         long[] b = fb.apply(SPECIES.length());
1610         long[] r = fr.apply(SPECIES.length());
1611         boolean[] mask = fm.apply(SPECIES.length());
1612         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1613 
1614         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1615             for (int i = 0; i < a.length; i += SPECIES.length()) {
1616                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1617                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1618                 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1619             }
1620         }
1621 
1622         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::MUL);
1623     }
1624 
1625     @Test(dataProvider = "longBinaryOpMaskProvider")
1626     static void mulLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1627                                           IntFunction<boolean[]> fm) {
1628         long[] a = fa.apply(SPECIES.length());
1629         long[] b = fb.apply(SPECIES.length());
1630         long[] r = fr.apply(SPECIES.length());
1631         boolean[] mask = fm.apply(SPECIES.length());
1632         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1633 
1634         for (int i = 0; i < a.length; i += SPECIES.length()) {
1635             LongVector av = LongVector.fromArray(SPECIES, a, i);
1636             LongVector bv = LongVector.fromArray(SPECIES, b, i);
1637             av.mul(bv, vmask).intoArray(r, i);
1638         }
1639 
1640         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::mul);
1641     }
1642 
1643     static long DIV(long a, long b) {
1644         return (long)(a / b);
1645     }
1646 
1647     @Test(dataProvider = "longBinaryOpProvider")
1648     static void DIVLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1649         long[] a = fa.apply(SPECIES.length());
1650         long[] b = fb.apply(SPECIES.length());
1651         long[] r = fr.apply(SPECIES.length());
1652 
1653         replaceZero(b, (long) 1);
1654 
1655         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1656             for (int i = 0; i < a.length; i += SPECIES.length()) {
1657                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1658                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1659                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1660             }
1661         }
1662 
1663         assertArraysEquals(r, a, b, LongMaxVectorTests::DIV);
1664     }
1665 
1666     static long div(long a, long b) {
1667         return (long)(a / b);
1668     }
1669 
1670     @Test(dataProvider = "longBinaryOpProvider")
1671     static void divLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1672         long[] a = fa.apply(SPECIES.length());
1673         long[] b = fb.apply(SPECIES.length());
1674         long[] r = fr.apply(SPECIES.length());
1675 
1676         replaceZero(b, (long) 1);
1677 
1678         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1679             for (int i = 0; i < a.length; i += SPECIES.length()) {
1680                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1681                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1682                 av.div(bv).intoArray(r, i);
1683             }
1684         }
1685 
1686         assertArraysEquals(r, a, b, LongMaxVectorTests::div);
1687     }
1688 
1689     @Test(dataProvider = "longBinaryOpMaskProvider")
1690     static void DIVLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1691                                           IntFunction<boolean[]> fm) {
1692         long[] a = fa.apply(SPECIES.length());
1693         long[] b = fb.apply(SPECIES.length());
1694         long[] r = fr.apply(SPECIES.length());
1695         boolean[] mask = fm.apply(SPECIES.length());
1696         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1697 
1698         replaceZero(b, mask, (long) 1);
1699 
1700         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1701             for (int i = 0; i < a.length; i += SPECIES.length()) {
1702                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1703                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1704                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1705             }
1706         }
1707 
1708         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::DIV);
1709     }
1710 
1711     @Test(dataProvider = "longBinaryOpMaskProvider")
1712     static void divLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1713                                           IntFunction<boolean[]> fm) {
1714         long[] a = fa.apply(SPECIES.length());
1715         long[] b = fb.apply(SPECIES.length());
1716         long[] r = fr.apply(SPECIES.length());
1717         boolean[] mask = fm.apply(SPECIES.length());
1718         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1719 
1720         replaceZero(b, mask, (long) 1);
1721 
1722         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1723             for (int i = 0; i < a.length; i += SPECIES.length()) {
1724                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1725                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1726                 av.div(bv, vmask).intoArray(r, i);
1727             }
1728         }
1729 
1730         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::div);
1731     }
1732 
1733     static long FIRST_NONZERO(long a, long b) {
1734         return (long)((a)!=0?a:b);
1735     }
1736 
1737     @Test(dataProvider = "longBinaryOpProvider")
1738     static void FIRST_NONZEROLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1739         long[] a = fa.apply(SPECIES.length());
1740         long[] b = fb.apply(SPECIES.length());
1741         long[] r = fr.apply(SPECIES.length());
1742 
1743         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1744             for (int i = 0; i < a.length; i += SPECIES.length()) {
1745                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1746                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1747                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1748             }
1749         }
1750 
1751         assertArraysEquals(r, a, b, LongMaxVectorTests::FIRST_NONZERO);
1752     }
1753 
1754     @Test(dataProvider = "longBinaryOpMaskProvider")
1755     static void FIRST_NONZEROLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1756                                           IntFunction<boolean[]> fm) {
1757         long[] a = fa.apply(SPECIES.length());
1758         long[] b = fb.apply(SPECIES.length());
1759         long[] r = fr.apply(SPECIES.length());
1760         boolean[] mask = fm.apply(SPECIES.length());
1761         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1762 
1763         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1764             for (int i = 0; i < a.length; i += SPECIES.length()) {
1765                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1766                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1767                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1768             }
1769         }
1770 
1771         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::FIRST_NONZERO);
1772     }
1773 
1774     static long AND(long a, long b) {
1775         return (long)(a & b);
1776     }
1777 
1778     @Test(dataProvider = "longBinaryOpProvider")
1779     static void ANDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1780         long[] a = fa.apply(SPECIES.length());
1781         long[] b = fb.apply(SPECIES.length());
1782         long[] r = fr.apply(SPECIES.length());
1783 
1784         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1785             for (int i = 0; i < a.length; i += SPECIES.length()) {
1786                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1787                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1788                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1789             }
1790         }
1791 
1792         assertArraysEquals(r, a, b, LongMaxVectorTests::AND);
1793     }
1794 
1795     static long and(long a, long b) {
1796         return (long)(a & b);
1797     }
1798 
1799     @Test(dataProvider = "longBinaryOpProvider")
1800     static void andLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1801         long[] a = fa.apply(SPECIES.length());
1802         long[] b = fb.apply(SPECIES.length());
1803         long[] r = fr.apply(SPECIES.length());
1804 
1805         for (int i = 0; i < a.length; i += SPECIES.length()) {
1806             LongVector av = LongVector.fromArray(SPECIES, a, i);
1807             LongVector bv = LongVector.fromArray(SPECIES, b, i);
1808             av.and(bv).intoArray(r, i);
1809         }
1810 
1811         assertArraysEquals(r, a, b, LongMaxVectorTests::and);
1812     }
1813 
1814     @Test(dataProvider = "longBinaryOpMaskProvider")
1815     static void ANDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1816                                           IntFunction<boolean[]> fm) {
1817         long[] a = fa.apply(SPECIES.length());
1818         long[] b = fb.apply(SPECIES.length());
1819         long[] r = fr.apply(SPECIES.length());
1820         boolean[] mask = fm.apply(SPECIES.length());
1821         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1822 
1823         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1824             for (int i = 0; i < a.length; i += SPECIES.length()) {
1825                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1826                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1827                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1828             }
1829         }
1830 
1831         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::AND);
1832     }
1833 
1834     static long AND_NOT(long a, long b) {
1835         return (long)(a & ~b);
1836     }
1837 
1838     @Test(dataProvider = "longBinaryOpProvider")
1839     static void AND_NOTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1840         long[] a = fa.apply(SPECIES.length());
1841         long[] b = fb.apply(SPECIES.length());
1842         long[] r = fr.apply(SPECIES.length());
1843 
1844         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1845             for (int i = 0; i < a.length; i += SPECIES.length()) {
1846                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1847                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1848                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1849             }
1850         }
1851 
1852         assertArraysEquals(r, a, b, LongMaxVectorTests::AND_NOT);
1853     }
1854 
1855     @Test(dataProvider = "longBinaryOpMaskProvider")
1856     static void AND_NOTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1857                                           IntFunction<boolean[]> fm) {
1858         long[] a = fa.apply(SPECIES.length());
1859         long[] b = fb.apply(SPECIES.length());
1860         long[] r = fr.apply(SPECIES.length());
1861         boolean[] mask = fm.apply(SPECIES.length());
1862         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1863 
1864         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1865             for (int i = 0; i < a.length; i += SPECIES.length()) {
1866                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1867                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1868                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1869             }
1870         }
1871 
1872         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::AND_NOT);
1873     }
1874 
1875     static long OR(long a, long b) {
1876         return (long)(a | b);
1877     }
1878 
1879     @Test(dataProvider = "longBinaryOpProvider")
1880     static void ORLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1881         long[] a = fa.apply(SPECIES.length());
1882         long[] b = fb.apply(SPECIES.length());
1883         long[] r = fr.apply(SPECIES.length());
1884 
1885         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1886             for (int i = 0; i < a.length; i += SPECIES.length()) {
1887                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1888                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1889                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1890             }
1891         }
1892 
1893         assertArraysEquals(r, a, b, LongMaxVectorTests::OR);
1894     }
1895 
1896     static long or(long a, long b) {
1897         return (long)(a | b);
1898     }
1899 
1900     @Test(dataProvider = "longBinaryOpProvider")
1901     static void orLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1902         long[] a = fa.apply(SPECIES.length());
1903         long[] b = fb.apply(SPECIES.length());
1904         long[] r = fr.apply(SPECIES.length());
1905 
1906         for (int i = 0; i < a.length; i += SPECIES.length()) {
1907             LongVector av = LongVector.fromArray(SPECIES, a, i);
1908             LongVector bv = LongVector.fromArray(SPECIES, b, i);
1909             av.or(bv).intoArray(r, i);
1910         }
1911 
1912         assertArraysEquals(r, a, b, LongMaxVectorTests::or);
1913     }
1914 
1915     @Test(dataProvider = "longBinaryOpMaskProvider")
1916     static void ORLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1917                                           IntFunction<boolean[]> fm) {
1918         long[] a = fa.apply(SPECIES.length());
1919         long[] b = fb.apply(SPECIES.length());
1920         long[] r = fr.apply(SPECIES.length());
1921         boolean[] mask = fm.apply(SPECIES.length());
1922         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1923 
1924         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1925             for (int i = 0; i < a.length; i += SPECIES.length()) {
1926                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1927                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1928                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1929             }
1930         }
1931 
1932         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::OR);
1933     }
1934 
1935     static long XOR(long a, long b) {
1936         return (long)(a ^ b);
1937     }
1938 
1939     @Test(dataProvider = "longBinaryOpProvider")
1940     static void XORLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1941         long[] a = fa.apply(SPECIES.length());
1942         long[] b = fb.apply(SPECIES.length());
1943         long[] r = fr.apply(SPECIES.length());
1944 
1945         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1946             for (int i = 0; i < a.length; i += SPECIES.length()) {
1947                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1948                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1949                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1950             }
1951         }
1952 
1953         assertArraysEquals(r, a, b, LongMaxVectorTests::XOR);
1954     }
1955 
1956     @Test(dataProvider = "longBinaryOpMaskProvider")
1957     static void XORLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1958                                           IntFunction<boolean[]> fm) {
1959         long[] a = fa.apply(SPECIES.length());
1960         long[] b = fb.apply(SPECIES.length());
1961         long[] r = fr.apply(SPECIES.length());
1962         boolean[] mask = fm.apply(SPECIES.length());
1963         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1964 
1965         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1966             for (int i = 0; i < a.length; i += SPECIES.length()) {
1967                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1968                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1969                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1970             }
1971         }
1972 
1973         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::XOR);
1974     }
1975 
1976     static long COMPRESS_BITS(long a, long b) {
1977         return (long)(Long.compress(a, b));
1978     }
1979 
1980     @Test(dataProvider = "longBinaryOpProvider")
1981     static void COMPRESS_BITSLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1982         long[] a = fa.apply(SPECIES.length());
1983         long[] b = fb.apply(SPECIES.length());
1984         long[] r = fr.apply(SPECIES.length());
1985 
1986         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1987             for (int i = 0; i < a.length; i += SPECIES.length()) {
1988                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1989                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1990                 av.lanewise(VectorOperators.COMPRESS_BITS, bv).intoArray(r, i);
1991             }
1992         }
1993 
1994         assertArraysEquals(r, a, b, LongMaxVectorTests::COMPRESS_BITS);
1995     }
1996 
1997     @Test(dataProvider = "longBinaryOpMaskProvider")
1998     static void COMPRESS_BITSLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
1999                                           IntFunction<boolean[]> fm) {
2000         long[] a = fa.apply(SPECIES.length());
2001         long[] b = fb.apply(SPECIES.length());
2002         long[] r = fr.apply(SPECIES.length());
2003         boolean[] mask = fm.apply(SPECIES.length());
2004         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2005 
2006         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2007             for (int i = 0; i < a.length; i += SPECIES.length()) {
2008                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2009                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2010                 av.lanewise(VectorOperators.COMPRESS_BITS, bv, vmask).intoArray(r, i);
2011             }
2012         }
2013 
2014         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::COMPRESS_BITS);
2015     }
2016 
2017     static long EXPAND_BITS(long a, long b) {
2018         return (long)(Long.expand(a, b));
2019     }
2020 
2021     @Test(dataProvider = "longBinaryOpProvider")
2022     static void EXPAND_BITSLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2023         long[] a = fa.apply(SPECIES.length());
2024         long[] b = fb.apply(SPECIES.length());
2025         long[] r = fr.apply(SPECIES.length());
2026 
2027         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2028             for (int i = 0; i < a.length; i += SPECIES.length()) {
2029                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2030                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2031                 av.lanewise(VectorOperators.EXPAND_BITS, bv).intoArray(r, i);
2032             }
2033         }
2034 
2035         assertArraysEquals(r, a, b, LongMaxVectorTests::EXPAND_BITS);
2036     }
2037 
2038     @Test(dataProvider = "longBinaryOpMaskProvider")
2039     static void EXPAND_BITSLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2040                                           IntFunction<boolean[]> fm) {
2041         long[] a = fa.apply(SPECIES.length());
2042         long[] b = fb.apply(SPECIES.length());
2043         long[] r = fr.apply(SPECIES.length());
2044         boolean[] mask = fm.apply(SPECIES.length());
2045         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2046 
2047         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2048             for (int i = 0; i < a.length; i += SPECIES.length()) {
2049                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2050                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2051                 av.lanewise(VectorOperators.EXPAND_BITS, bv, vmask).intoArray(r, i);
2052             }
2053         }
2054 
2055         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::EXPAND_BITS);
2056     }
2057 
2058     @Test(dataProvider = "longBinaryOpProvider")
2059     static void addLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2060         long[] a = fa.apply(SPECIES.length());
2061         long[] b = fb.apply(SPECIES.length());
2062         long[] r = fr.apply(SPECIES.length());
2063 
2064         for (int i = 0; i < a.length; i += SPECIES.length()) {
2065             LongVector av = LongVector.fromArray(SPECIES, a, i);
2066             av.add(b[i]).intoArray(r, i);
2067         }
2068 
2069         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::add);
2070     }
2071 
2072     @Test(dataProvider = "longBinaryOpMaskProvider")
2073     static void addLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2074                                           IntFunction<boolean[]> fm) {
2075         long[] a = fa.apply(SPECIES.length());
2076         long[] b = fb.apply(SPECIES.length());
2077         long[] r = fr.apply(SPECIES.length());
2078         boolean[] mask = fm.apply(SPECIES.length());
2079         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2080 
2081         for (int i = 0; i < a.length; i += SPECIES.length()) {
2082             LongVector av = LongVector.fromArray(SPECIES, a, i);
2083             av.add(b[i], vmask).intoArray(r, i);
2084         }
2085 
2086         assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::add);
2087     }
2088 
2089     @Test(dataProvider = "longBinaryOpProvider")
2090     static void subLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2091         long[] a = fa.apply(SPECIES.length());
2092         long[] b = fb.apply(SPECIES.length());
2093         long[] r = fr.apply(SPECIES.length());
2094 
2095         for (int i = 0; i < a.length; i += SPECIES.length()) {
2096             LongVector av = LongVector.fromArray(SPECIES, a, i);
2097             av.sub(b[i]).intoArray(r, i);
2098         }
2099 
2100         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::sub);
2101     }
2102 
2103     @Test(dataProvider = "longBinaryOpMaskProvider")
2104     static void subLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2105                                           IntFunction<boolean[]> fm) {
2106         long[] a = fa.apply(SPECIES.length());
2107         long[] b = fb.apply(SPECIES.length());
2108         long[] r = fr.apply(SPECIES.length());
2109         boolean[] mask = fm.apply(SPECIES.length());
2110         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2111 
2112         for (int i = 0; i < a.length; i += SPECIES.length()) {
2113             LongVector av = LongVector.fromArray(SPECIES, a, i);
2114             av.sub(b[i], vmask).intoArray(r, i);
2115         }
2116 
2117         assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::sub);
2118     }
2119 
2120     @Test(dataProvider = "longBinaryOpProvider")
2121     static void mulLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2122         long[] a = fa.apply(SPECIES.length());
2123         long[] b = fb.apply(SPECIES.length());
2124         long[] r = fr.apply(SPECIES.length());
2125 
2126         for (int i = 0; i < a.length; i += SPECIES.length()) {
2127             LongVector av = LongVector.fromArray(SPECIES, a, i);
2128             av.mul(b[i]).intoArray(r, i);
2129         }
2130 
2131         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::mul);
2132     }
2133 
2134     @Test(dataProvider = "longBinaryOpMaskProvider")
2135     static void mulLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2136                                           IntFunction<boolean[]> fm) {
2137         long[] a = fa.apply(SPECIES.length());
2138         long[] b = fb.apply(SPECIES.length());
2139         long[] r = fr.apply(SPECIES.length());
2140         boolean[] mask = fm.apply(SPECIES.length());
2141         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2142 
2143         for (int i = 0; i < a.length; i += SPECIES.length()) {
2144             LongVector av = LongVector.fromArray(SPECIES, a, i);
2145             av.mul(b[i], vmask).intoArray(r, i);
2146         }
2147 
2148         assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::mul);
2149     }
2150 
2151     @Test(dataProvider = "longBinaryOpProvider")
2152     static void divLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2153         long[] a = fa.apply(SPECIES.length());
2154         long[] b = fb.apply(SPECIES.length());
2155         long[] r = fr.apply(SPECIES.length());
2156 
2157         replaceZero(b, (long) 1);
2158 
2159         for (int i = 0; i < a.length; i += SPECIES.length()) {
2160             LongVector av = LongVector.fromArray(SPECIES, a, i);
2161             av.div(b[i]).intoArray(r, i);
2162         }
2163 
2164         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::div);
2165     }
2166 
2167     @Test(dataProvider = "longBinaryOpMaskProvider")
2168     static void divLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2169                                           IntFunction<boolean[]> fm) {
2170         long[] a = fa.apply(SPECIES.length());
2171         long[] b = fb.apply(SPECIES.length());
2172         long[] r = fr.apply(SPECIES.length());
2173         boolean[] mask = fm.apply(SPECIES.length());
2174         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2175 
2176         replaceZero(b, (long) 1);
2177 
2178         for (int i = 0; i < a.length; i += SPECIES.length()) {
2179             LongVector av = LongVector.fromArray(SPECIES, a, i);
2180             av.div(b[i], vmask).intoArray(r, i);
2181         }
2182 
2183         assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::div);
2184     }
2185 
2186     @Test(dataProvider = "longBinaryOpProvider")
2187     static void ORLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2188         long[] a = fa.apply(SPECIES.length());
2189         long[] b = fb.apply(SPECIES.length());
2190         long[] r = fr.apply(SPECIES.length());
2191 
2192         for (int i = 0; i < a.length; i += SPECIES.length()) {
2193             LongVector av = LongVector.fromArray(SPECIES, a, i);
2194             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2195         }
2196 
2197         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::OR);
2198     }
2199 
2200     @Test(dataProvider = "longBinaryOpProvider")
2201     static void orLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2202         long[] a = fa.apply(SPECIES.length());
2203         long[] b = fb.apply(SPECIES.length());
2204         long[] r = fr.apply(SPECIES.length());
2205 
2206         for (int i = 0; i < a.length; i += SPECIES.length()) {
2207             LongVector av = LongVector.fromArray(SPECIES, a, i);
2208             av.or(b[i]).intoArray(r, i);
2209         }
2210 
2211         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::or);
2212     }
2213 
2214     @Test(dataProvider = "longBinaryOpMaskProvider")
2215     static void ORLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2216                                           IntFunction<boolean[]> fm) {
2217         long[] a = fa.apply(SPECIES.length());
2218         long[] b = fb.apply(SPECIES.length());
2219         long[] r = fr.apply(SPECIES.length());
2220         boolean[] mask = fm.apply(SPECIES.length());
2221         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2222 
2223         for (int i = 0; i < a.length; i += SPECIES.length()) {
2224             LongVector av = LongVector.fromArray(SPECIES, a, i);
2225             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2226         }
2227 
2228         assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::OR);
2229     }
2230 
2231     @Test(dataProvider = "longBinaryOpProvider")
2232     static void ANDLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2233         long[] a = fa.apply(SPECIES.length());
2234         long[] b = fb.apply(SPECIES.length());
2235         long[] r = fr.apply(SPECIES.length());
2236 
2237         for (int i = 0; i < a.length; i += SPECIES.length()) {
2238             LongVector av = LongVector.fromArray(SPECIES, a, i);
2239             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2240         }
2241 
2242         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::AND);
2243     }
2244 
2245     @Test(dataProvider = "longBinaryOpProvider")
2246     static void andLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2247         long[] a = fa.apply(SPECIES.length());
2248         long[] b = fb.apply(SPECIES.length());
2249         long[] r = fr.apply(SPECIES.length());
2250 
2251         for (int i = 0; i < a.length; i += SPECIES.length()) {
2252             LongVector av = LongVector.fromArray(SPECIES, a, i);
2253             av.and(b[i]).intoArray(r, i);
2254         }
2255 
2256         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::and);
2257     }
2258 
2259     @Test(dataProvider = "longBinaryOpMaskProvider")
2260     static void ANDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2261                                           IntFunction<boolean[]> fm) {
2262         long[] a = fa.apply(SPECIES.length());
2263         long[] b = fb.apply(SPECIES.length());
2264         long[] r = fr.apply(SPECIES.length());
2265         boolean[] mask = fm.apply(SPECIES.length());
2266         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2267 
2268         for (int i = 0; i < a.length; i += SPECIES.length()) {
2269             LongVector av = LongVector.fromArray(SPECIES, a, i);
2270             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2271         }
2272 
2273         assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::AND);
2274     }
2275 
2276     @Test(dataProvider = "longBinaryOpProvider")
2277     static void ORLongMaxVectorTestsBroadcastLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2278         long[] a = fa.apply(SPECIES.length());
2279         long[] b = fb.apply(SPECIES.length());
2280         long[] r = fr.apply(SPECIES.length());
2281 
2282         for (int i = 0; i < a.length; i += SPECIES.length()) {
2283             LongVector av = LongVector.fromArray(SPECIES, a, i);
2284             av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2285         }
2286 
2287         assertBroadcastLongArraysEquals(r, a, b, LongMaxVectorTests::OR);
2288     }
2289 
2290     @Test(dataProvider = "longBinaryOpMaskProvider")
2291     static void ORLongMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2292                                           IntFunction<boolean[]> fm) {
2293         long[] a = fa.apply(SPECIES.length());
2294         long[] b = fb.apply(SPECIES.length());
2295         long[] r = fr.apply(SPECIES.length());
2296         boolean[] mask = fm.apply(SPECIES.length());
2297         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2298 
2299         for (int i = 0; i < a.length; i += SPECIES.length()) {
2300             LongVector av = LongVector.fromArray(SPECIES, a, i);
2301             av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2302         }
2303 
2304         assertBroadcastLongArraysEquals(r, a, b, mask, LongMaxVectorTests::OR);
2305     }
2306 
2307     @Test(dataProvider = "longBinaryOpProvider")
2308     static void ADDLongMaxVectorTestsBroadcastLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2309         long[] a = fa.apply(SPECIES.length());
2310         long[] b = fb.apply(SPECIES.length());
2311         long[] r = fr.apply(SPECIES.length());
2312 
2313         for (int i = 0; i < a.length; i += SPECIES.length()) {
2314             LongVector av = LongVector.fromArray(SPECIES, a, i);
2315             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2316         }
2317 
2318         assertBroadcastLongArraysEquals(r, a, b, LongMaxVectorTests::ADD);
2319     }
2320 
2321     @Test(dataProvider = "longBinaryOpMaskProvider")
2322     static void ADDLongMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
2323                                           IntFunction<boolean[]> fm) {
2324         long[] a = fa.apply(SPECIES.length());
2325         long[] b = fb.apply(SPECIES.length());
2326         long[] r = fr.apply(SPECIES.length());
2327         boolean[] mask = fm.apply(SPECIES.length());
2328         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2329 
2330         for (int i = 0; i < a.length; i += SPECIES.length()) {
2331             LongVector av = LongVector.fromArray(SPECIES, a, i);
2332             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2333         }
2334 
2335         assertBroadcastLongArraysEquals(r, a, b, mask, LongMaxVectorTests::ADD);
2336     }
2337 
2338     static long LSHL(long a, long b) {
2339         return (long)((a << b));
2340     }
2341 
2342     @Test(dataProvider = "longBinaryOpProvider")
2343     static void LSHLLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2344         long[] a = fa.apply(SPECIES.length());
2345         long[] b = fb.apply(SPECIES.length());
2346         long[] r = fr.apply(SPECIES.length());
2347 
2348         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2349             for (int i = 0; i < a.length; i += SPECIES.length()) {
2350                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2351                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2352                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2353             }
2354         }
2355 
2356         assertArraysEquals(r, a, b, LongMaxVectorTests::LSHL);
2357     }
2358 
2359     @Test(dataProvider = "longBinaryOpMaskProvider")
2360     static void LSHLLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2361                                           IntFunction<boolean[]> fm) {
2362         long[] a = fa.apply(SPECIES.length());
2363         long[] b = fb.apply(SPECIES.length());
2364         long[] r = fr.apply(SPECIES.length());
2365         boolean[] mask = fm.apply(SPECIES.length());
2366         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2367 
2368         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2369             for (int i = 0; i < a.length; i += SPECIES.length()) {
2370                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2371                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2372                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2373             }
2374         }
2375 
2376         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHL);
2377     }
2378 
2379     static long ASHR(long a, long b) {
2380         return (long)((a >> b));
2381     }
2382 
2383     @Test(dataProvider = "longBinaryOpProvider")
2384     static void ASHRLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2385         long[] a = fa.apply(SPECIES.length());
2386         long[] b = fb.apply(SPECIES.length());
2387         long[] r = fr.apply(SPECIES.length());
2388 
2389         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2390             for (int i = 0; i < a.length; i += SPECIES.length()) {
2391                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2392                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2393                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2394             }
2395         }
2396 
2397         assertArraysEquals(r, a, b, LongMaxVectorTests::ASHR);
2398     }
2399 
2400     @Test(dataProvider = "longBinaryOpMaskProvider")
2401     static void ASHRLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2402                                           IntFunction<boolean[]> fm) {
2403         long[] a = fa.apply(SPECIES.length());
2404         long[] b = fb.apply(SPECIES.length());
2405         long[] r = fr.apply(SPECIES.length());
2406         boolean[] mask = fm.apply(SPECIES.length());
2407         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2408 
2409         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2410             for (int i = 0; i < a.length; i += SPECIES.length()) {
2411                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2412                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2413                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2414             }
2415         }
2416 
2417         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ASHR);
2418     }
2419 
2420     static long LSHR(long a, long b) {
2421         return (long)((a >>> b));
2422     }
2423 
2424     @Test(dataProvider = "longBinaryOpProvider")
2425     static void LSHRLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2426         long[] a = fa.apply(SPECIES.length());
2427         long[] b = fb.apply(SPECIES.length());
2428         long[] r = fr.apply(SPECIES.length());
2429 
2430         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2431             for (int i = 0; i < a.length; i += SPECIES.length()) {
2432                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2433                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2434                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2435             }
2436         }
2437 
2438         assertArraysEquals(r, a, b, LongMaxVectorTests::LSHR);
2439     }
2440 
2441     @Test(dataProvider = "longBinaryOpMaskProvider")
2442     static void LSHRLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2443                                           IntFunction<boolean[]> fm) {
2444         long[] a = fa.apply(SPECIES.length());
2445         long[] b = fb.apply(SPECIES.length());
2446         long[] r = fr.apply(SPECIES.length());
2447         boolean[] mask = fm.apply(SPECIES.length());
2448         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2449 
2450         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2451             for (int i = 0; i < a.length; i += SPECIES.length()) {
2452                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2453                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2454                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2455             }
2456         }
2457 
2458         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHR);
2459     }
2460 
2461     static long LSHL_unary(long a, long b) {
2462         return (long)((a << b));
2463     }
2464 
2465     @Test(dataProvider = "longBinaryOpProvider")
2466     static void LSHLLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2467         long[] a = fa.apply(SPECIES.length());
2468         long[] b = fb.apply(SPECIES.length());
2469         long[] r = fr.apply(SPECIES.length());
2470 
2471         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2472             for (int i = 0; i < a.length; i += SPECIES.length()) {
2473                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2474                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2475             }
2476         }
2477 
2478         assertShiftArraysEquals(r, a, b, LongMaxVectorTests::LSHL_unary);
2479     }
2480 
2481     @Test(dataProvider = "longBinaryOpMaskProvider")
2482     static void LSHLLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2483                                           IntFunction<boolean[]> fm) {
2484         long[] a = fa.apply(SPECIES.length());
2485         long[] b = fb.apply(SPECIES.length());
2486         long[] r = fr.apply(SPECIES.length());
2487         boolean[] mask = fm.apply(SPECIES.length());
2488         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2489 
2490         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2491             for (int i = 0; i < a.length; i += SPECIES.length()) {
2492                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2493                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2494             }
2495         }
2496 
2497         assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHL_unary);
2498     }
2499 
2500     static long LSHR_unary(long a, long b) {
2501         return (long)((a >>> b));
2502     }
2503 
2504     @Test(dataProvider = "longBinaryOpProvider")
2505     static void LSHRLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2506         long[] a = fa.apply(SPECIES.length());
2507         long[] b = fb.apply(SPECIES.length());
2508         long[] r = fr.apply(SPECIES.length());
2509 
2510         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2511             for (int i = 0; i < a.length; i += SPECIES.length()) {
2512                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2513                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2514             }
2515         }
2516 
2517         assertShiftArraysEquals(r, a, b, LongMaxVectorTests::LSHR_unary);
2518     }
2519 
2520     @Test(dataProvider = "longBinaryOpMaskProvider")
2521     static void LSHRLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2522                                           IntFunction<boolean[]> fm) {
2523         long[] a = fa.apply(SPECIES.length());
2524         long[] b = fb.apply(SPECIES.length());
2525         long[] r = fr.apply(SPECIES.length());
2526         boolean[] mask = fm.apply(SPECIES.length());
2527         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2528 
2529         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2530             for (int i = 0; i < a.length; i += SPECIES.length()) {
2531                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2532                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2533             }
2534         }
2535 
2536         assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHR_unary);
2537     }
2538 
2539     static long ASHR_unary(long a, long b) {
2540         return (long)((a >> b));
2541     }
2542 
2543     @Test(dataProvider = "longBinaryOpProvider")
2544     static void ASHRLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2545         long[] a = fa.apply(SPECIES.length());
2546         long[] b = fb.apply(SPECIES.length());
2547         long[] r = fr.apply(SPECIES.length());
2548 
2549         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2550             for (int i = 0; i < a.length; i += SPECIES.length()) {
2551                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2552                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2553             }
2554         }
2555 
2556         assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ASHR_unary);
2557     }
2558 
2559     @Test(dataProvider = "longBinaryOpMaskProvider")
2560     static void ASHRLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2561                                           IntFunction<boolean[]> fm) {
2562         long[] a = fa.apply(SPECIES.length());
2563         long[] b = fb.apply(SPECIES.length());
2564         long[] r = fr.apply(SPECIES.length());
2565         boolean[] mask = fm.apply(SPECIES.length());
2566         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2567 
2568         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2569             for (int i = 0; i < a.length; i += SPECIES.length()) {
2570                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2571                 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2572             }
2573         }
2574 
2575         assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ASHR_unary);
2576     }
2577 
2578     static long ROR(long a, long b) {
2579         return (long)(ROR_scalar(a,b));
2580     }
2581 
2582     @Test(dataProvider = "longBinaryOpProvider")
2583     static void RORLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2584         long[] a = fa.apply(SPECIES.length());
2585         long[] b = fb.apply(SPECIES.length());
2586         long[] r = fr.apply(SPECIES.length());
2587 
2588         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2589             for (int i = 0; i < a.length; i += SPECIES.length()) {
2590                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2591                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2592                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2593             }
2594         }
2595 
2596         assertArraysEquals(r, a, b, LongMaxVectorTests::ROR);
2597     }
2598 
2599     @Test(dataProvider = "longBinaryOpMaskProvider")
2600     static void RORLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2601                                           IntFunction<boolean[]> fm) {
2602         long[] a = fa.apply(SPECIES.length());
2603         long[] b = fb.apply(SPECIES.length());
2604         long[] r = fr.apply(SPECIES.length());
2605         boolean[] mask = fm.apply(SPECIES.length());
2606         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2607 
2608         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2609             for (int i = 0; i < a.length; i += SPECIES.length()) {
2610                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2611                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2612                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2613             }
2614         }
2615 
2616         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ROR);
2617     }
2618 
2619     static long ROL(long a, long b) {
2620         return (long)(ROL_scalar(a,b));
2621     }
2622 
2623     @Test(dataProvider = "longBinaryOpProvider")
2624     static void ROLLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2625         long[] a = fa.apply(SPECIES.length());
2626         long[] b = fb.apply(SPECIES.length());
2627         long[] r = fr.apply(SPECIES.length());
2628 
2629         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2630             for (int i = 0; i < a.length; i += SPECIES.length()) {
2631                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2632                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2633                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2634             }
2635         }
2636 
2637         assertArraysEquals(r, a, b, LongMaxVectorTests::ROL);
2638     }
2639 
2640     @Test(dataProvider = "longBinaryOpMaskProvider")
2641     static void ROLLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2642                                           IntFunction<boolean[]> fm) {
2643         long[] a = fa.apply(SPECIES.length());
2644         long[] b = fb.apply(SPECIES.length());
2645         long[] r = fr.apply(SPECIES.length());
2646         boolean[] mask = fm.apply(SPECIES.length());
2647         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2648 
2649         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2650             for (int i = 0; i < a.length; i += SPECIES.length()) {
2651                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2652                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2653                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2654             }
2655         }
2656 
2657         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ROL);
2658     }
2659 
2660     static long ROR_unary(long a, long b) {
2661         return (long)(ROR_scalar(a, b));
2662     }
2663 
2664     @Test(dataProvider = "longBinaryOpProvider")
2665     static void RORLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2666         long[] a = fa.apply(SPECIES.length());
2667         long[] b = fb.apply(SPECIES.length());
2668         long[] r = fr.apply(SPECIES.length());
2669 
2670         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2671             for (int i = 0; i < a.length; i += SPECIES.length()) {
2672                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2673                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2674             }
2675         }
2676 
2677         assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ROR_unary);
2678     }
2679 
2680     @Test(dataProvider = "longBinaryOpMaskProvider")
2681     static void RORLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2682                                           IntFunction<boolean[]> fm) {
2683         long[] a = fa.apply(SPECIES.length());
2684         long[] b = fb.apply(SPECIES.length());
2685         long[] r = fr.apply(SPECIES.length());
2686         boolean[] mask = fm.apply(SPECIES.length());
2687         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2688 
2689         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2690             for (int i = 0; i < a.length; i += SPECIES.length()) {
2691                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2692                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2693             }
2694         }
2695 
2696         assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ROR_unary);
2697     }
2698 
2699     static long ROL_unary(long a, long b) {
2700         return (long)(ROL_scalar(a, b));
2701     }
2702 
2703     @Test(dataProvider = "longBinaryOpProvider")
2704     static void ROLLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2705         long[] a = fa.apply(SPECIES.length());
2706         long[] b = fb.apply(SPECIES.length());
2707         long[] r = fr.apply(SPECIES.length());
2708 
2709         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2710             for (int i = 0; i < a.length; i += SPECIES.length()) {
2711                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2712                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2713             }
2714         }
2715 
2716         assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ROL_unary);
2717     }
2718 
2719     @Test(dataProvider = "longBinaryOpMaskProvider")
2720     static void ROLLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
2721                                           IntFunction<boolean[]> fm) {
2722         long[] a = fa.apply(SPECIES.length());
2723         long[] b = fb.apply(SPECIES.length());
2724         long[] r = fr.apply(SPECIES.length());
2725         boolean[] mask = fm.apply(SPECIES.length());
2726         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2727 
2728         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2729             for (int i = 0; i < a.length; i += SPECIES.length()) {
2730                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2731                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2732             }
2733         }
2734 
2735         assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ROL_unary);
2736     }
2737     static long LSHR_binary_const(long a) {
2738         return (long)((a >>> CONST_SHIFT));
2739     }
2740 
2741     @Test(dataProvider = "longUnaryOpProvider")
2742     static void LSHRLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
2743         long[] a = fa.apply(SPECIES.length());
2744         long[] r = fr.apply(SPECIES.length());
2745 
2746         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2747             for (int i = 0; i < a.length; i += SPECIES.length()) {
2748                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2749                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2750             }
2751         }
2752 
2753         assertShiftConstEquals(r, a, LongMaxVectorTests::LSHR_binary_const);
2754     }
2755 
2756     @Test(dataProvider = "longUnaryOpMaskProvider")
2757     static void LSHRLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa,
2758                                           IntFunction<boolean[]> fm) {
2759         long[] a = fa.apply(SPECIES.length());
2760         long[] r = fr.apply(SPECIES.length());
2761         boolean[] mask = fm.apply(SPECIES.length());
2762         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2763 
2764         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2765             for (int i = 0; i < a.length; i += SPECIES.length()) {
2766                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2767                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2768             }
2769         }
2770 
2771         assertShiftConstEquals(r, a, mask, LongMaxVectorTests::LSHR_binary_const);
2772     }
2773 
2774     static long LSHL_binary_const(long a) {
2775         return (long)((a << CONST_SHIFT));
2776     }
2777 
2778     @Test(dataProvider = "longUnaryOpProvider")
2779     static void LSHLLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
2780         long[] a = fa.apply(SPECIES.length());
2781         long[] r = fr.apply(SPECIES.length());
2782 
2783         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2784             for (int i = 0; i < a.length; i += SPECIES.length()) {
2785                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2786                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2787             }
2788         }
2789 
2790         assertShiftConstEquals(r, a, LongMaxVectorTests::LSHL_binary_const);
2791     }
2792 
2793     @Test(dataProvider = "longUnaryOpMaskProvider")
2794     static void LSHLLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa,
2795                                           IntFunction<boolean[]> fm) {
2796         long[] a = fa.apply(SPECIES.length());
2797         long[] r = fr.apply(SPECIES.length());
2798         boolean[] mask = fm.apply(SPECIES.length());
2799         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2800 
2801         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2802             for (int i = 0; i < a.length; i += SPECIES.length()) {
2803                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2804                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2805             }
2806         }
2807 
2808         assertShiftConstEquals(r, a, mask, LongMaxVectorTests::LSHL_binary_const);
2809     }
2810 
2811     static long ASHR_binary_const(long a) {
2812         return (long)((a >> CONST_SHIFT));
2813     }
2814 
2815     @Test(dataProvider = "longUnaryOpProvider")
2816     static void ASHRLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
2817         long[] a = fa.apply(SPECIES.length());
2818         long[] r = fr.apply(SPECIES.length());
2819 
2820         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2821             for (int i = 0; i < a.length; i += SPECIES.length()) {
2822                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2823                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2824             }
2825         }
2826 
2827         assertShiftConstEquals(r, a, LongMaxVectorTests::ASHR_binary_const);
2828     }
2829 
2830     @Test(dataProvider = "longUnaryOpMaskProvider")
2831     static void ASHRLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa,
2832                                           IntFunction<boolean[]> fm) {
2833         long[] a = fa.apply(SPECIES.length());
2834         long[] r = fr.apply(SPECIES.length());
2835         boolean[] mask = fm.apply(SPECIES.length());
2836         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2837 
2838         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2839             for (int i = 0; i < a.length; i += SPECIES.length()) {
2840                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2841                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2842             }
2843         }
2844 
2845         assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ASHR_binary_const);
2846     }
2847 
2848     static long ROR_binary_const(long a) {
2849         return (long)(ROR_scalar(a, CONST_SHIFT));
2850     }
2851 
2852     @Test(dataProvider = "longUnaryOpProvider")
2853     static void RORLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
2854         long[] a = fa.apply(SPECIES.length());
2855         long[] r = fr.apply(SPECIES.length());
2856 
2857         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2858             for (int i = 0; i < a.length; i += SPECIES.length()) {
2859                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2860                 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2861             }
2862         }
2863 
2864         assertShiftConstEquals(r, a, LongMaxVectorTests::ROR_binary_const);
2865     }
2866 
2867     @Test(dataProvider = "longUnaryOpMaskProvider")
2868     static void RORLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa,
2869                                           IntFunction<boolean[]> fm) {
2870         long[] a = fa.apply(SPECIES.length());
2871         long[] r = fr.apply(SPECIES.length());
2872         boolean[] mask = fm.apply(SPECIES.length());
2873         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2874 
2875         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2876             for (int i = 0; i < a.length; i += SPECIES.length()) {
2877                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2878                 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2879             }
2880         }
2881 
2882         assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ROR_binary_const);
2883     }
2884 
2885     static long ROL_binary_const(long a) {
2886         return (long)(ROL_scalar(a, CONST_SHIFT));
2887     }
2888 
2889     @Test(dataProvider = "longUnaryOpProvider")
2890     static void ROLLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) {
2891         long[] a = fa.apply(SPECIES.length());
2892         long[] r = fr.apply(SPECIES.length());
2893 
2894         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2895             for (int i = 0; i < a.length; i += SPECIES.length()) {
2896                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2897                 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
2898             }
2899         }
2900 
2901         assertShiftConstEquals(r, a, LongMaxVectorTests::ROL_binary_const);
2902     }
2903 
2904     @Test(dataProvider = "longUnaryOpMaskProvider")
2905     static void ROLLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa,
2906                                           IntFunction<boolean[]> fm) {
2907         long[] a = fa.apply(SPECIES.length());
2908         long[] r = fr.apply(SPECIES.length());
2909         boolean[] mask = fm.apply(SPECIES.length());
2910         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2911 
2912         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2913             for (int i = 0; i < a.length; i += SPECIES.length()) {
2914                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2915                 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
2916             }
2917         }
2918 
2919         assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ROL_binary_const);
2920     }
2921 
2922 
2923     static long MIN(long a, long b) {
2924         return (long)(Math.min(a, b));
2925     }
2926 
2927     @Test(dataProvider = "longBinaryOpProvider")
2928     static void MINLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2929         long[] a = fa.apply(SPECIES.length());
2930         long[] b = fb.apply(SPECIES.length());
2931         long[] r = fr.apply(SPECIES.length());
2932 
2933         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2934             for (int i = 0; i < a.length; i += SPECIES.length()) {
2935                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2936                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2937                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2938             }
2939         }
2940 
2941         assertArraysEquals(r, a, b, LongMaxVectorTests::MIN);
2942     }
2943 
2944     static long min(long a, long b) {
2945         return (long)(Math.min(a, b));
2946     }
2947 
2948     @Test(dataProvider = "longBinaryOpProvider")
2949     static void minLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2950         long[] a = fa.apply(SPECIES.length());
2951         long[] b = fb.apply(SPECIES.length());
2952         long[] r = fr.apply(SPECIES.length());
2953 
2954         for (int i = 0; i < a.length; i += SPECIES.length()) {
2955             LongVector av = LongVector.fromArray(SPECIES, a, i);
2956             LongVector bv = LongVector.fromArray(SPECIES, b, i);
2957             av.min(bv).intoArray(r, i);
2958         }
2959 
2960         assertArraysEquals(r, a, b, LongMaxVectorTests::min);
2961     }
2962 
2963     static long MAX(long a, long b) {
2964         return (long)(Math.max(a, b));
2965     }
2966 
2967     @Test(dataProvider = "longBinaryOpProvider")
2968     static void MAXLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2969         long[] a = fa.apply(SPECIES.length());
2970         long[] b = fb.apply(SPECIES.length());
2971         long[] r = fr.apply(SPECIES.length());
2972 
2973         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2974             for (int i = 0; i < a.length; i += SPECIES.length()) {
2975                 LongVector av = LongVector.fromArray(SPECIES, a, i);
2976                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
2977                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2978             }
2979         }
2980 
2981         assertArraysEquals(r, a, b, LongMaxVectorTests::MAX);
2982     }
2983 
2984     static long max(long a, long b) {
2985         return (long)(Math.max(a, b));
2986     }
2987 
2988     @Test(dataProvider = "longBinaryOpProvider")
2989     static void maxLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
2990         long[] a = fa.apply(SPECIES.length());
2991         long[] b = fb.apply(SPECIES.length());
2992         long[] r = fr.apply(SPECIES.length());
2993 
2994         for (int i = 0; i < a.length; i += SPECIES.length()) {
2995             LongVector av = LongVector.fromArray(SPECIES, a, i);
2996             LongVector bv = LongVector.fromArray(SPECIES, b, i);
2997             av.max(bv).intoArray(r, i);
2998         }
2999 
3000         assertArraysEquals(r, a, b, LongMaxVectorTests::max);
3001     }
3002 
3003     @Test(dataProvider = "longBinaryOpProvider")
3004     static void MINLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3005         long[] a = fa.apply(SPECIES.length());
3006         long[] b = fb.apply(SPECIES.length());
3007         long[] r = fr.apply(SPECIES.length());
3008 
3009         for (int i = 0; i < a.length; i += SPECIES.length()) {
3010             LongVector av = LongVector.fromArray(SPECIES, a, i);
3011             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
3012         }
3013 
3014         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::MIN);
3015     }
3016 
3017     @Test(dataProvider = "longBinaryOpProvider")
3018     static void minLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3019         long[] a = fa.apply(SPECIES.length());
3020         long[] b = fb.apply(SPECIES.length());
3021         long[] r = fr.apply(SPECIES.length());
3022 
3023         for (int i = 0; i < a.length; i += SPECIES.length()) {
3024             LongVector av = LongVector.fromArray(SPECIES, a, i);
3025             av.min(b[i]).intoArray(r, i);
3026         }
3027 
3028         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::min);
3029     }
3030 
3031     @Test(dataProvider = "longBinaryOpProvider")
3032     static void MAXLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3033         long[] a = fa.apply(SPECIES.length());
3034         long[] b = fb.apply(SPECIES.length());
3035         long[] r = fr.apply(SPECIES.length());
3036 
3037         for (int i = 0; i < a.length; i += SPECIES.length()) {
3038             LongVector av = LongVector.fromArray(SPECIES, a, i);
3039             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
3040         }
3041 
3042         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::MAX);
3043     }
3044 
3045     @Test(dataProvider = "longBinaryOpProvider")
3046     static void maxLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3047         long[] a = fa.apply(SPECIES.length());
3048         long[] b = fb.apply(SPECIES.length());
3049         long[] r = fr.apply(SPECIES.length());
3050 
3051         for (int i = 0; i < a.length; i += SPECIES.length()) {
3052             LongVector av = LongVector.fromArray(SPECIES, a, i);
3053             av.max(b[i]).intoArray(r, i);
3054         }
3055 
3056         assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::max);
3057     }
3058 
3059     static long ANDReduce(long[] a, int idx) {
3060         long res = -1;
3061         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3062             res &= a[i];
3063         }
3064 
3065         return res;
3066     }
3067 
3068     static long ANDReduceAll(long[] a) {
3069         long res = -1;
3070         for (int i = 0; i < a.length; i += SPECIES.length()) {
3071             res &= ANDReduce(a, i);
3072         }
3073 
3074         return res;
3075     }
3076 
3077     @Test(dataProvider = "longUnaryOpProvider")
3078     static void ANDReduceLongMaxVectorTests(IntFunction<long[]> fa) {
3079         long[] a = fa.apply(SPECIES.length());
3080         long[] r = fr.apply(SPECIES.length());
3081         long ra = -1;
3082 
3083         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3084             for (int i = 0; i < a.length; i += SPECIES.length()) {
3085                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3086                 r[i] = av.reduceLanes(VectorOperators.AND);
3087             }
3088         }
3089 
3090         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3091             ra = -1;
3092             for (int i = 0; i < a.length; i += SPECIES.length()) {
3093                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3094                 ra &= av.reduceLanes(VectorOperators.AND);
3095             }
3096         }
3097 
3098         assertReductionArraysEquals(r, ra, a,
3099                 LongMaxVectorTests::ANDReduce, LongMaxVectorTests::ANDReduceAll);
3100     }
3101 
3102     static long ANDReduceMasked(long[] a, int idx, boolean[] mask) {
3103         long res = -1;
3104         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3105             if (mask[i % SPECIES.length()])
3106                 res &= a[i];
3107         }
3108 
3109         return res;
3110     }
3111 
3112     static long ANDReduceAllMasked(long[] a, boolean[] mask) {
3113         long res = -1;
3114         for (int i = 0; i < a.length; i += SPECIES.length()) {
3115             res &= ANDReduceMasked(a, i, mask);
3116         }
3117 
3118         return res;
3119     }
3120 
3121     @Test(dataProvider = "longUnaryOpMaskProvider")
3122     static void ANDReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3123         long[] a = fa.apply(SPECIES.length());
3124         long[] r = fr.apply(SPECIES.length());
3125         boolean[] mask = fm.apply(SPECIES.length());
3126         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3127         long ra = -1;
3128 
3129         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3130             for (int i = 0; i < a.length; i += SPECIES.length()) {
3131                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3132                 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3133             }
3134         }
3135 
3136         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3137             ra = -1;
3138             for (int i = 0; i < a.length; i += SPECIES.length()) {
3139                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3140                 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3141             }
3142         }
3143 
3144         assertReductionArraysEqualsMasked(r, ra, a, mask,
3145                 LongMaxVectorTests::ANDReduceMasked, LongMaxVectorTests::ANDReduceAllMasked);
3146     }
3147 
3148     static long ORReduce(long[] a, int idx) {
3149         long res = 0;
3150         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3151             res |= a[i];
3152         }
3153 
3154         return res;
3155     }
3156 
3157     static long ORReduceAll(long[] a) {
3158         long res = 0;
3159         for (int i = 0; i < a.length; i += SPECIES.length()) {
3160             res |= ORReduce(a, i);
3161         }
3162 
3163         return res;
3164     }
3165 
3166     @Test(dataProvider = "longUnaryOpProvider")
3167     static void ORReduceLongMaxVectorTests(IntFunction<long[]> fa) {
3168         long[] a = fa.apply(SPECIES.length());
3169         long[] r = fr.apply(SPECIES.length());
3170         long ra = 0;
3171 
3172         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3173             for (int i = 0; i < a.length; i += SPECIES.length()) {
3174                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3175                 r[i] = av.reduceLanes(VectorOperators.OR);
3176             }
3177         }
3178 
3179         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3180             ra = 0;
3181             for (int i = 0; i < a.length; i += SPECIES.length()) {
3182                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3183                 ra |= av.reduceLanes(VectorOperators.OR);
3184             }
3185         }
3186 
3187         assertReductionArraysEquals(r, ra, a,
3188                 LongMaxVectorTests::ORReduce, LongMaxVectorTests::ORReduceAll);
3189     }
3190 
3191     static long ORReduceMasked(long[] a, int idx, boolean[] mask) {
3192         long res = 0;
3193         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3194             if (mask[i % SPECIES.length()])
3195                 res |= a[i];
3196         }
3197 
3198         return res;
3199     }
3200 
3201     static long ORReduceAllMasked(long[] a, boolean[] mask) {
3202         long res = 0;
3203         for (int i = 0; i < a.length; i += SPECIES.length()) {
3204             res |= ORReduceMasked(a, i, mask);
3205         }
3206 
3207         return res;
3208     }
3209 
3210     @Test(dataProvider = "longUnaryOpMaskProvider")
3211     static void ORReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3212         long[] a = fa.apply(SPECIES.length());
3213         long[] r = fr.apply(SPECIES.length());
3214         boolean[] mask = fm.apply(SPECIES.length());
3215         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3216         long ra = 0;
3217 
3218         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3219             for (int i = 0; i < a.length; i += SPECIES.length()) {
3220                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3221                 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3222             }
3223         }
3224 
3225         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3226             ra = 0;
3227             for (int i = 0; i < a.length; i += SPECIES.length()) {
3228                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3229                 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3230             }
3231         }
3232 
3233         assertReductionArraysEqualsMasked(r, ra, a, mask,
3234                 LongMaxVectorTests::ORReduceMasked, LongMaxVectorTests::ORReduceAllMasked);
3235     }
3236 
3237     static long XORReduce(long[] a, int idx) {
3238         long res = 0;
3239         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3240             res ^= a[i];
3241         }
3242 
3243         return res;
3244     }
3245 
3246     static long XORReduceAll(long[] a) {
3247         long res = 0;
3248         for (int i = 0; i < a.length; i += SPECIES.length()) {
3249             res ^= XORReduce(a, i);
3250         }
3251 
3252         return res;
3253     }
3254 
3255     @Test(dataProvider = "longUnaryOpProvider")
3256     static void XORReduceLongMaxVectorTests(IntFunction<long[]> fa) {
3257         long[] a = fa.apply(SPECIES.length());
3258         long[] r = fr.apply(SPECIES.length());
3259         long ra = 0;
3260 
3261         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3262             for (int i = 0; i < a.length; i += SPECIES.length()) {
3263                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3264                 r[i] = av.reduceLanes(VectorOperators.XOR);
3265             }
3266         }
3267 
3268         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3269             ra = 0;
3270             for (int i = 0; i < a.length; i += SPECIES.length()) {
3271                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3272                 ra ^= av.reduceLanes(VectorOperators.XOR);
3273             }
3274         }
3275 
3276         assertReductionArraysEquals(r, ra, a,
3277                 LongMaxVectorTests::XORReduce, LongMaxVectorTests::XORReduceAll);
3278     }
3279 
3280     static long XORReduceMasked(long[] a, int idx, boolean[] mask) {
3281         long res = 0;
3282         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3283             if (mask[i % SPECIES.length()])
3284                 res ^= a[i];
3285         }
3286 
3287         return res;
3288     }
3289 
3290     static long XORReduceAllMasked(long[] a, boolean[] mask) {
3291         long res = 0;
3292         for (int i = 0; i < a.length; i += SPECIES.length()) {
3293             res ^= XORReduceMasked(a, i, mask);
3294         }
3295 
3296         return res;
3297     }
3298 
3299     @Test(dataProvider = "longUnaryOpMaskProvider")
3300     static void XORReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3301         long[] a = fa.apply(SPECIES.length());
3302         long[] r = fr.apply(SPECIES.length());
3303         boolean[] mask = fm.apply(SPECIES.length());
3304         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3305         long ra = 0;
3306 
3307         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3308             for (int i = 0; i < a.length; i += SPECIES.length()) {
3309                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3310                 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3311             }
3312         }
3313 
3314         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3315             ra = 0;
3316             for (int i = 0; i < a.length; i += SPECIES.length()) {
3317                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3318                 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
3319             }
3320         }
3321 
3322         assertReductionArraysEqualsMasked(r, ra, a, mask,
3323                 LongMaxVectorTests::XORReduceMasked, LongMaxVectorTests::XORReduceAllMasked);
3324     }
3325 
3326     static long ADDReduce(long[] a, int idx) {
3327         long res = 0;
3328         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3329             res += a[i];
3330         }
3331 
3332         return res;
3333     }
3334 
3335     static long ADDReduceAll(long[] a) {
3336         long res = 0;
3337         for (int i = 0; i < a.length; i += SPECIES.length()) {
3338             res += ADDReduce(a, i);
3339         }
3340 
3341         return res;
3342     }
3343 
3344     @Test(dataProvider = "longUnaryOpProvider")
3345     static void ADDReduceLongMaxVectorTests(IntFunction<long[]> fa) {
3346         long[] a = fa.apply(SPECIES.length());
3347         long[] r = fr.apply(SPECIES.length());
3348         long ra = 0;
3349 
3350         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3351             for (int i = 0; i < a.length; i += SPECIES.length()) {
3352                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3353                 r[i] = av.reduceLanes(VectorOperators.ADD);
3354             }
3355         }
3356 
3357         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3358             ra = 0;
3359             for (int i = 0; i < a.length; i += SPECIES.length()) {
3360                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3361                 ra += av.reduceLanes(VectorOperators.ADD);
3362             }
3363         }
3364 
3365         assertReductionArraysEquals(r, ra, a,
3366                 LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll);
3367     }
3368 
3369     static long ADDReduceMasked(long[] a, int idx, boolean[] mask) {
3370         long res = 0;
3371         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3372             if (mask[i % SPECIES.length()])
3373                 res += a[i];
3374         }
3375 
3376         return res;
3377     }
3378 
3379     static long ADDReduceAllMasked(long[] a, boolean[] mask) {
3380         long res = 0;
3381         for (int i = 0; i < a.length; i += SPECIES.length()) {
3382             res += ADDReduceMasked(a, i, mask);
3383         }
3384 
3385         return res;
3386     }
3387 
3388     @Test(dataProvider = "longUnaryOpMaskProvider")
3389     static void ADDReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3390         long[] a = fa.apply(SPECIES.length());
3391         long[] r = fr.apply(SPECIES.length());
3392         boolean[] mask = fm.apply(SPECIES.length());
3393         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3394         long ra = 0;
3395 
3396         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3397             for (int i = 0; i < a.length; i += SPECIES.length()) {
3398                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3399                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3400             }
3401         }
3402 
3403         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3404             ra = 0;
3405             for (int i = 0; i < a.length; i += SPECIES.length()) {
3406                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3407                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3408             }
3409         }
3410 
3411         assertReductionArraysEqualsMasked(r, ra, a, mask,
3412                 LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked);
3413     }
3414 
3415     static long MULReduce(long[] a, int idx) {
3416         long res = 1;
3417         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3418             res *= a[i];
3419         }
3420 
3421         return res;
3422     }
3423 
3424     static long MULReduceAll(long[] a) {
3425         long res = 1;
3426         for (int i = 0; i < a.length; i += SPECIES.length()) {
3427             res *= MULReduce(a, i);
3428         }
3429 
3430         return res;
3431     }
3432 
3433     @Test(dataProvider = "longUnaryOpProvider")
3434     static void MULReduceLongMaxVectorTests(IntFunction<long[]> fa) {
3435         long[] a = fa.apply(SPECIES.length());
3436         long[] r = fr.apply(SPECIES.length());
3437         long ra = 1;
3438 
3439         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3440             for (int i = 0; i < a.length; i += SPECIES.length()) {
3441                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3442                 r[i] = av.reduceLanes(VectorOperators.MUL);
3443             }
3444         }
3445 
3446         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3447             ra = 1;
3448             for (int i = 0; i < a.length; i += SPECIES.length()) {
3449                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3450                 ra *= av.reduceLanes(VectorOperators.MUL);
3451             }
3452         }
3453 
3454         assertReductionArraysEquals(r, ra, a,
3455                 LongMaxVectorTests::MULReduce, LongMaxVectorTests::MULReduceAll);
3456     }
3457 
3458     static long MULReduceMasked(long[] a, int idx, boolean[] mask) {
3459         long res = 1;
3460         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3461             if (mask[i % SPECIES.length()])
3462                 res *= a[i];
3463         }
3464 
3465         return res;
3466     }
3467 
3468     static long MULReduceAllMasked(long[] a, boolean[] mask) {
3469         long res = 1;
3470         for (int i = 0; i < a.length; i += SPECIES.length()) {
3471             res *= MULReduceMasked(a, i, mask);
3472         }
3473 
3474         return res;
3475     }
3476 
3477     @Test(dataProvider = "longUnaryOpMaskProvider")
3478     static void MULReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3479         long[] a = fa.apply(SPECIES.length());
3480         long[] r = fr.apply(SPECIES.length());
3481         boolean[] mask = fm.apply(SPECIES.length());
3482         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3483         long ra = 1;
3484 
3485         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3486             for (int i = 0; i < a.length; i += SPECIES.length()) {
3487                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3488                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3489             }
3490         }
3491 
3492         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3493             ra = 1;
3494             for (int i = 0; i < a.length; i += SPECIES.length()) {
3495                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3496                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3497             }
3498         }
3499 
3500         assertReductionArraysEqualsMasked(r, ra, a, mask,
3501                 LongMaxVectorTests::MULReduceMasked, LongMaxVectorTests::MULReduceAllMasked);
3502     }
3503 
3504     static long MINReduce(long[] a, int idx) {
3505         long res = Long.MAX_VALUE;
3506         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3507             res = (long) Math.min(res, a[i]);
3508         }
3509 
3510         return res;
3511     }
3512 
3513     static long MINReduceAll(long[] a) {
3514         long res = Long.MAX_VALUE;
3515         for (int i = 0; i < a.length; i += SPECIES.length()) {
3516             res = (long) Math.min(res, MINReduce(a, i));
3517         }
3518 
3519         return res;
3520     }
3521 
3522     @Test(dataProvider = "longUnaryOpProvider")
3523     static void MINReduceLongMaxVectorTests(IntFunction<long[]> fa) {
3524         long[] a = fa.apply(SPECIES.length());
3525         long[] r = fr.apply(SPECIES.length());
3526         long ra = Long.MAX_VALUE;
3527 
3528         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3529             for (int i = 0; i < a.length; i += SPECIES.length()) {
3530                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3531                 r[i] = av.reduceLanes(VectorOperators.MIN);
3532             }
3533         }
3534 
3535         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3536             ra = Long.MAX_VALUE;
3537             for (int i = 0; i < a.length; i += SPECIES.length()) {
3538                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3539                 ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3540             }
3541         }
3542 
3543         assertReductionArraysEquals(r, ra, a,
3544                 LongMaxVectorTests::MINReduce, LongMaxVectorTests::MINReduceAll);
3545     }
3546 
3547     static long MINReduceMasked(long[] a, int idx, boolean[] mask) {
3548         long res = Long.MAX_VALUE;
3549         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3550             if (mask[i % SPECIES.length()])
3551                 res = (long) Math.min(res, a[i]);
3552         }
3553 
3554         return res;
3555     }
3556 
3557     static long MINReduceAllMasked(long[] a, boolean[] mask) {
3558         long res = Long.MAX_VALUE;
3559         for (int i = 0; i < a.length; i += SPECIES.length()) {
3560             res = (long) Math.min(res, MINReduceMasked(a, i, mask));
3561         }
3562 
3563         return res;
3564     }
3565 
3566     @Test(dataProvider = "longUnaryOpMaskProvider")
3567     static void MINReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3568         long[] a = fa.apply(SPECIES.length());
3569         long[] r = fr.apply(SPECIES.length());
3570         boolean[] mask = fm.apply(SPECIES.length());
3571         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3572         long ra = Long.MAX_VALUE;
3573 
3574         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3575             for (int i = 0; i < a.length; i += SPECIES.length()) {
3576                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3577                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3578             }
3579         }
3580 
3581         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3582             ra = Long.MAX_VALUE;
3583             for (int i = 0; i < a.length; i += SPECIES.length()) {
3584                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3585                 ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3586             }
3587         }
3588 
3589         assertReductionArraysEqualsMasked(r, ra, a, mask,
3590                 LongMaxVectorTests::MINReduceMasked, LongMaxVectorTests::MINReduceAllMasked);
3591     }
3592 
3593     static long MAXReduce(long[] a, int idx) {
3594         long res = Long.MIN_VALUE;
3595         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3596             res = (long) Math.max(res, a[i]);
3597         }
3598 
3599         return res;
3600     }
3601 
3602     static long MAXReduceAll(long[] a) {
3603         long res = Long.MIN_VALUE;
3604         for (int i = 0; i < a.length; i += SPECIES.length()) {
3605             res = (long) Math.max(res, MAXReduce(a, i));
3606         }
3607 
3608         return res;
3609     }
3610 
3611     @Test(dataProvider = "longUnaryOpProvider")
3612     static void MAXReduceLongMaxVectorTests(IntFunction<long[]> fa) {
3613         long[] a = fa.apply(SPECIES.length());
3614         long[] r = fr.apply(SPECIES.length());
3615         long ra = Long.MIN_VALUE;
3616 
3617         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3618             for (int i = 0; i < a.length; i += SPECIES.length()) {
3619                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3620                 r[i] = av.reduceLanes(VectorOperators.MAX);
3621             }
3622         }
3623 
3624         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3625             ra = Long.MIN_VALUE;
3626             for (int i = 0; i < a.length; i += SPECIES.length()) {
3627                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3628                 ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3629             }
3630         }
3631 
3632         assertReductionArraysEquals(r, ra, a,
3633                 LongMaxVectorTests::MAXReduce, LongMaxVectorTests::MAXReduceAll);
3634     }
3635 
3636     static long MAXReduceMasked(long[] a, int idx, boolean[] mask) {
3637         long res = Long.MIN_VALUE;
3638         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3639             if (mask[i % SPECIES.length()])
3640                 res = (long) Math.max(res, a[i]);
3641         }
3642 
3643         return res;
3644     }
3645 
3646     static long MAXReduceAllMasked(long[] a, boolean[] mask) {
3647         long res = Long.MIN_VALUE;
3648         for (int i = 0; i < a.length; i += SPECIES.length()) {
3649             res = (long) Math.max(res, MAXReduceMasked(a, i, mask));
3650         }
3651 
3652         return res;
3653     }
3654 
3655     @Test(dataProvider = "longUnaryOpMaskProvider")
3656     static void MAXReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3657         long[] a = fa.apply(SPECIES.length());
3658         long[] r = fr.apply(SPECIES.length());
3659         boolean[] mask = fm.apply(SPECIES.length());
3660         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3661         long ra = Long.MIN_VALUE;
3662 
3663         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3664             for (int i = 0; i < a.length; i += SPECIES.length()) {
3665                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3666                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3667             }
3668         }
3669 
3670         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3671             ra = Long.MIN_VALUE;
3672             for (int i = 0; i < a.length; i += SPECIES.length()) {
3673                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3674                 ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3675             }
3676         }
3677 
3678         assertReductionArraysEqualsMasked(r, ra, a, mask,
3679                 LongMaxVectorTests::MAXReduceMasked, LongMaxVectorTests::MAXReduceAllMasked);
3680     }
3681 
3682     static long FIRST_NONZEROReduce(long[] a, int idx) {
3683         long res = (long) 0;
3684         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3685             res = firstNonZero(res, a[i]);
3686         }
3687 
3688         return res;
3689     }
3690 
3691     static long FIRST_NONZEROReduceAll(long[] a) {
3692         long res = (long) 0;
3693         for (int i = 0; i < a.length; i += SPECIES.length()) {
3694             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
3695         }
3696 
3697         return res;
3698     }
3699 
3700     @Test(dataProvider = "longUnaryOpProvider")
3701     static void FIRST_NONZEROReduceLongMaxVectorTests(IntFunction<long[]> fa) {
3702         long[] a = fa.apply(SPECIES.length());
3703         long[] r = fr.apply(SPECIES.length());
3704         long ra = (long) 0;
3705 
3706         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3707             for (int i = 0; i < a.length; i += SPECIES.length()) {
3708                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3709                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
3710             }
3711         }
3712 
3713         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3714             ra = (long) 0;
3715             for (int i = 0; i < a.length; i += SPECIES.length()) {
3716                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3717                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
3718             }
3719         }
3720 
3721         assertReductionArraysEquals(r, ra, a,
3722                 LongMaxVectorTests::FIRST_NONZEROReduce, LongMaxVectorTests::FIRST_NONZEROReduceAll);
3723     }
3724 
3725     static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) {
3726         long res = (long) 0;
3727         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3728             if (mask[i % SPECIES.length()])
3729                 res = firstNonZero(res, a[i]);
3730         }
3731 
3732         return res;
3733     }
3734 
3735     static long FIRST_NONZEROReduceAllMasked(long[] a, boolean[] mask) {
3736         long res = (long) 0;
3737         for (int i = 0; i < a.length; i += SPECIES.length()) {
3738             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
3739         }
3740 
3741         return res;
3742     }
3743 
3744     @Test(dataProvider = "longUnaryOpMaskProvider")
3745     static void FIRST_NONZEROReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
3746         long[] a = fa.apply(SPECIES.length());
3747         long[] r = fr.apply(SPECIES.length());
3748         boolean[] mask = fm.apply(SPECIES.length());
3749         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3750         long ra = (long) 0;
3751 
3752         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3753             for (int i = 0; i < a.length; i += SPECIES.length()) {
3754                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3755                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
3756             }
3757         }
3758 
3759         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3760             ra = (long) 0;
3761             for (int i = 0; i < a.length; i += SPECIES.length()) {
3762                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3763                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
3764             }
3765         }
3766 
3767         assertReductionArraysEqualsMasked(r, ra, a, mask,
3768                 LongMaxVectorTests::FIRST_NONZEROReduceMasked, LongMaxVectorTests::FIRST_NONZEROReduceAllMasked);
3769     }
3770 
3771     static boolean anyTrue(boolean[] a, int idx) {
3772         boolean res = false;
3773         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3774             res |= a[i];
3775         }
3776 
3777         return res;
3778     }
3779 
3780     @Test(dataProvider = "boolUnaryOpProvider")
3781     static void anyTrueLongMaxVectorTests(IntFunction<boolean[]> fm) {
3782         boolean[] mask = fm.apply(SPECIES.length());
3783         boolean[] r = fmr.apply(SPECIES.length());
3784 
3785         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3786             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3787                 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
3788                 r[i] = vmask.anyTrue();
3789             }
3790         }
3791 
3792         assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::anyTrue);
3793     }
3794 
3795     static boolean allTrue(boolean[] a, int idx) {
3796         boolean res = true;
3797         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3798             res &= a[i];
3799         }
3800 
3801         return res;
3802     }
3803 
3804     @Test(dataProvider = "boolUnaryOpProvider")
3805     static void allTrueLongMaxVectorTests(IntFunction<boolean[]> fm) {
3806         boolean[] mask = fm.apply(SPECIES.length());
3807         boolean[] r = fmr.apply(SPECIES.length());
3808 
3809         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3810             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3811                 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
3812                 r[i] = vmask.allTrue();
3813             }
3814         }
3815 
3816         assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::allTrue);
3817     }
3818 
3819     @Test(dataProvider = "longUnaryOpProvider")
3820     static void withLongMaxVectorTests(IntFunction<long []> fa) {
3821         long[] a = fa.apply(SPECIES.length());
3822         long[] r = fr.apply(SPECIES.length());
3823 
3824         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3825             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3826                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3827                 av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i);
3828             }
3829         }
3830 
3831 
3832         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3833             assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3834         }
3835     }
3836 
3837     static boolean testIS_DEFAULT(long a) {
3838         return bits(a)==0;
3839     }
3840 
3841     @Test(dataProvider = "longTestOpProvider")
3842     static void IS_DEFAULTLongMaxVectorTests(IntFunction<long[]> fa) {
3843         long[] a = fa.apply(SPECIES.length());
3844 
3845         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3846             for (int i = 0; i < a.length; i += SPECIES.length()) {
3847                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3848                 VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT);
3849 
3850                 // Check results as part of computation.
3851                 for (int j = 0; j < SPECIES.length(); j++) {
3852                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3853                 }
3854             }
3855         }
3856     }
3857 
3858     @Test(dataProvider = "longTestOpMaskProvider")
3859     static void IS_DEFAULTMaskedLongMaxVectorTests(IntFunction<long[]> fa,
3860                                           IntFunction<boolean[]> fm) {
3861         long[] a = fa.apply(SPECIES.length());
3862         boolean[] mask = fm.apply(SPECIES.length());
3863         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3864 
3865         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3866             for (int i = 0; i < a.length; i += SPECIES.length()) {
3867                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3868                 VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3869 
3870                 // Check results as part of computation.
3871                 for (int j = 0; j < SPECIES.length(); j++) {
3872                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3873                 }
3874             }
3875         }
3876     }
3877 
3878     static boolean testIS_NEGATIVE(long a) {
3879         return bits(a)<0;
3880     }
3881 
3882     @Test(dataProvider = "longTestOpProvider")
3883     static void IS_NEGATIVELongMaxVectorTests(IntFunction<long[]> fa) {
3884         long[] a = fa.apply(SPECIES.length());
3885 
3886         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3887             for (int i = 0; i < a.length; i += SPECIES.length()) {
3888                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3889                 VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE);
3890 
3891                 // Check results as part of computation.
3892                 for (int j = 0; j < SPECIES.length(); j++) {
3893                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3894                 }
3895             }
3896         }
3897     }
3898 
3899     @Test(dataProvider = "longTestOpMaskProvider")
3900     static void IS_NEGATIVEMaskedLongMaxVectorTests(IntFunction<long[]> fa,
3901                                           IntFunction<boolean[]> fm) {
3902         long[] a = fa.apply(SPECIES.length());
3903         boolean[] mask = fm.apply(SPECIES.length());
3904         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3905 
3906         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3907             for (int i = 0; i < a.length; i += SPECIES.length()) {
3908                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3909                 VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3910 
3911                 // Check results as part of computation.
3912                 for (int j = 0; j < SPECIES.length(); j++) {
3913                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3914                 }
3915             }
3916         }
3917     }
3918 
3919     @Test(dataProvider = "longCompareOpProvider")
3920     static void LTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3921         long[] a = fa.apply(SPECIES.length());
3922         long[] b = fb.apply(SPECIES.length());
3923 
3924         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3925             for (int i = 0; i < a.length; i += SPECIES.length()) {
3926                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3927                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3928                 VectorMask<Long> mv = av.compare(VectorOperators.LT, bv);
3929 
3930                 // Check results as part of computation.
3931                 for (int j = 0; j < SPECIES.length(); j++) {
3932                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3933                 }
3934             }
3935         }
3936     }
3937 
3938     @Test(dataProvider = "longCompareOpProvider")
3939     static void ltLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3940         long[] a = fa.apply(SPECIES.length());
3941         long[] b = fb.apply(SPECIES.length());
3942 
3943         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3944             for (int i = 0; i < a.length; i += SPECIES.length()) {
3945                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3946                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3947                 VectorMask<Long> mv = av.lt(bv);
3948 
3949                 // Check results as part of computation.
3950                 for (int j = 0; j < SPECIES.length(); j++) {
3951                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3952                 }
3953             }
3954         }
3955     }
3956 
3957     @Test(dataProvider = "longCompareOpMaskProvider")
3958     static void LTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3959                                                 IntFunction<boolean[]> fm) {
3960         long[] a = fa.apply(SPECIES.length());
3961         long[] b = fb.apply(SPECIES.length());
3962         boolean[] mask = fm.apply(SPECIES.length());
3963 
3964         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3965 
3966         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3967             for (int i = 0; i < a.length; i += SPECIES.length()) {
3968                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3969                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3970                 VectorMask<Long> mv = av.compare(VectorOperators.LT, bv, vmask);
3971 
3972                 // Check results as part of computation.
3973                 for (int j = 0; j < SPECIES.length(); j++) {
3974                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3975                 }
3976             }
3977         }
3978     }
3979 
3980     @Test(dataProvider = "longCompareOpProvider")
3981     static void GTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3982         long[] a = fa.apply(SPECIES.length());
3983         long[] b = fb.apply(SPECIES.length());
3984 
3985         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3986             for (int i = 0; i < a.length; i += SPECIES.length()) {
3987                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3988                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3989                 VectorMask<Long> mv = av.compare(VectorOperators.GT, bv);
3990 
3991                 // Check results as part of computation.
3992                 for (int j = 0; j < SPECIES.length(); j++) {
3993                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3994                 }
3995             }
3996         }
3997     }
3998 
3999     @Test(dataProvider = "longCompareOpMaskProvider")
4000     static void GTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4001                                                 IntFunction<boolean[]> fm) {
4002         long[] a = fa.apply(SPECIES.length());
4003         long[] b = fb.apply(SPECIES.length());
4004         boolean[] mask = fm.apply(SPECIES.length());
4005 
4006         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4007 
4008         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4009             for (int i = 0; i < a.length; i += SPECIES.length()) {
4010                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4011                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4012                 VectorMask<Long> mv = av.compare(VectorOperators.GT, bv, vmask);
4013 
4014                 // Check results as part of computation.
4015                 for (int j = 0; j < SPECIES.length(); j++) {
4016                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
4017                 }
4018             }
4019         }
4020     }
4021 
4022     @Test(dataProvider = "longCompareOpProvider")
4023     static void EQLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4024         long[] a = fa.apply(SPECIES.length());
4025         long[] b = fb.apply(SPECIES.length());
4026 
4027         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4028             for (int i = 0; i < a.length; i += SPECIES.length()) {
4029                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4030                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4031                 VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv);
4032 
4033                 // Check results as part of computation.
4034                 for (int j = 0; j < SPECIES.length(); j++) {
4035                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4036                 }
4037             }
4038         }
4039     }
4040 
4041     @Test(dataProvider = "longCompareOpProvider")
4042     static void eqLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4043         long[] a = fa.apply(SPECIES.length());
4044         long[] b = fb.apply(SPECIES.length());
4045 
4046         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4047             for (int i = 0; i < a.length; i += SPECIES.length()) {
4048                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4049                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4050                 VectorMask<Long> mv = av.eq(bv);
4051 
4052                 // Check results as part of computation.
4053                 for (int j = 0; j < SPECIES.length(); j++) {
4054                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4055                 }
4056             }
4057         }
4058     }
4059 
4060     @Test(dataProvider = "longCompareOpMaskProvider")
4061     static void EQLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4062                                                 IntFunction<boolean[]> fm) {
4063         long[] a = fa.apply(SPECIES.length());
4064         long[] b = fb.apply(SPECIES.length());
4065         boolean[] mask = fm.apply(SPECIES.length());
4066 
4067         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4068 
4069         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4070             for (int i = 0; i < a.length; i += SPECIES.length()) {
4071                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4072                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4073                 VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv, vmask);
4074 
4075                 // Check results as part of computation.
4076                 for (int j = 0; j < SPECIES.length(); j++) {
4077                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4078                 }
4079             }
4080         }
4081     }
4082 
4083     @Test(dataProvider = "longCompareOpProvider")
4084     static void NELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4085         long[] a = fa.apply(SPECIES.length());
4086         long[] b = fb.apply(SPECIES.length());
4087 
4088         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4089             for (int i = 0; i < a.length; i += SPECIES.length()) {
4090                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4091                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4092                 VectorMask<Long> mv = av.compare(VectorOperators.NE, bv);
4093 
4094                 // Check results as part of computation.
4095                 for (int j = 0; j < SPECIES.length(); j++) {
4096                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4097                 }
4098             }
4099         }
4100     }
4101 
4102     @Test(dataProvider = "longCompareOpMaskProvider")
4103     static void NELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4104                                                 IntFunction<boolean[]> fm) {
4105         long[] a = fa.apply(SPECIES.length());
4106         long[] b = fb.apply(SPECIES.length());
4107         boolean[] mask = fm.apply(SPECIES.length());
4108 
4109         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4110 
4111         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4112             for (int i = 0; i < a.length; i += SPECIES.length()) {
4113                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4114                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4115                 VectorMask<Long> mv = av.compare(VectorOperators.NE, bv, vmask);
4116 
4117                 // Check results as part of computation.
4118                 for (int j = 0; j < SPECIES.length(); j++) {
4119                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4120                 }
4121             }
4122         }
4123     }
4124 
4125     @Test(dataProvider = "longCompareOpProvider")
4126     static void LELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4127         long[] a = fa.apply(SPECIES.length());
4128         long[] b = fb.apply(SPECIES.length());
4129 
4130         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4131             for (int i = 0; i < a.length; i += SPECIES.length()) {
4132                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4133                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4134                 VectorMask<Long> mv = av.compare(VectorOperators.LE, bv);
4135 
4136                 // Check results as part of computation.
4137                 for (int j = 0; j < SPECIES.length(); j++) {
4138                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4139                 }
4140             }
4141         }
4142     }
4143 
4144     @Test(dataProvider = "longCompareOpMaskProvider")
4145     static void LELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4146                                                 IntFunction<boolean[]> fm) {
4147         long[] a = fa.apply(SPECIES.length());
4148         long[] b = fb.apply(SPECIES.length());
4149         boolean[] mask = fm.apply(SPECIES.length());
4150 
4151         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4152 
4153         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4154             for (int i = 0; i < a.length; i += SPECIES.length()) {
4155                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4156                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4157                 VectorMask<Long> mv = av.compare(VectorOperators.LE, bv, vmask);
4158 
4159                 // Check results as part of computation.
4160                 for (int j = 0; j < SPECIES.length(); j++) {
4161                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4162                 }
4163             }
4164         }
4165     }
4166 
4167     @Test(dataProvider = "longCompareOpProvider")
4168     static void GELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4169         long[] a = fa.apply(SPECIES.length());
4170         long[] b = fb.apply(SPECIES.length());
4171 
4172         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4173             for (int i = 0; i < a.length; i += SPECIES.length()) {
4174                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4175                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4176                 VectorMask<Long> mv = av.compare(VectorOperators.GE, bv);
4177 
4178                 // Check results as part of computation.
4179                 for (int j = 0; j < SPECIES.length(); j++) {
4180                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4181                 }
4182             }
4183         }
4184     }
4185 
4186     @Test(dataProvider = "longCompareOpMaskProvider")
4187     static void GELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4188                                                 IntFunction<boolean[]> fm) {
4189         long[] a = fa.apply(SPECIES.length());
4190         long[] b = fb.apply(SPECIES.length());
4191         boolean[] mask = fm.apply(SPECIES.length());
4192 
4193         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4194 
4195         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4196             for (int i = 0; i < a.length; i += SPECIES.length()) {
4197                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4198                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4199                 VectorMask<Long> mv = av.compare(VectorOperators.GE, bv, vmask);
4200 
4201                 // Check results as part of computation.
4202                 for (int j = 0; j < SPECIES.length(); j++) {
4203                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4204                 }
4205             }
4206         }
4207     }
4208 
4209     @Test(dataProvider = "longCompareOpProvider")
4210     static void UNSIGNED_LTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4211         long[] a = fa.apply(SPECIES.length());
4212         long[] b = fb.apply(SPECIES.length());
4213 
4214         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4215             for (int i = 0; i < a.length; i += SPECIES.length()) {
4216                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4217                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4218                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
4219 
4220                 // Check results as part of computation.
4221                 for (int j = 0; j < SPECIES.length(); j++) {
4222                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4223                 }
4224             }
4225         }
4226     }
4227 
4228     @Test(dataProvider = "longCompareOpMaskProvider")
4229     static void UNSIGNED_LTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4230                                                 IntFunction<boolean[]> fm) {
4231         long[] a = fa.apply(SPECIES.length());
4232         long[] b = fb.apply(SPECIES.length());
4233         boolean[] mask = fm.apply(SPECIES.length());
4234 
4235         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4236 
4237         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4238             for (int i = 0; i < a.length; i += SPECIES.length()) {
4239                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4240                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4241                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
4242 
4243                 // Check results as part of computation.
4244                 for (int j = 0; j < SPECIES.length(); j++) {
4245                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
4246                 }
4247             }
4248         }
4249     }
4250 
4251     @Test(dataProvider = "longCompareOpProvider")
4252     static void UNSIGNED_GTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4253         long[] a = fa.apply(SPECIES.length());
4254         long[] b = fb.apply(SPECIES.length());
4255 
4256         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4257             for (int i = 0; i < a.length; i += SPECIES.length()) {
4258                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4259                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4260                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
4261 
4262                 // Check results as part of computation.
4263                 for (int j = 0; j < SPECIES.length(); j++) {
4264                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
4265                 }
4266             }
4267         }
4268     }
4269 
4270     @Test(dataProvider = "longCompareOpMaskProvider")
4271     static void UNSIGNED_GTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4272                                                 IntFunction<boolean[]> fm) {
4273         long[] a = fa.apply(SPECIES.length());
4274         long[] b = fb.apply(SPECIES.length());
4275         boolean[] mask = fm.apply(SPECIES.length());
4276 
4277         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4278 
4279         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4280             for (int i = 0; i < a.length; i += SPECIES.length()) {
4281                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4282                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4283                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
4284 
4285                 // Check results as part of computation.
4286                 for (int j = 0; j < SPECIES.length(); j++) {
4287                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
4288                 }
4289             }
4290         }
4291     }
4292 
4293     @Test(dataProvider = "longCompareOpProvider")
4294     static void UNSIGNED_LELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4295         long[] a = fa.apply(SPECIES.length());
4296         long[] b = fb.apply(SPECIES.length());
4297 
4298         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4299             for (int i = 0; i < a.length; i += SPECIES.length()) {
4300                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4301                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4302                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
4303 
4304                 // Check results as part of computation.
4305                 for (int j = 0; j < SPECIES.length(); j++) {
4306                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
4307                 }
4308             }
4309         }
4310     }
4311 
4312     @Test(dataProvider = "longCompareOpMaskProvider")
4313     static void UNSIGNED_LELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4314                                                 IntFunction<boolean[]> fm) {
4315         long[] a = fa.apply(SPECIES.length());
4316         long[] b = fb.apply(SPECIES.length());
4317         boolean[] mask = fm.apply(SPECIES.length());
4318 
4319         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4320 
4321         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4322             for (int i = 0; i < a.length; i += SPECIES.length()) {
4323                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4324                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4325                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
4326 
4327                 // Check results as part of computation.
4328                 for (int j = 0; j < SPECIES.length(); j++) {
4329                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
4330                 }
4331             }
4332         }
4333     }
4334 
4335     @Test(dataProvider = "longCompareOpProvider")
4336     static void UNSIGNED_GELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4337         long[] a = fa.apply(SPECIES.length());
4338         long[] b = fb.apply(SPECIES.length());
4339 
4340         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4341             for (int i = 0; i < a.length; i += SPECIES.length()) {
4342                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4343                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4344                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
4345 
4346                 // Check results as part of computation.
4347                 for (int j = 0; j < SPECIES.length(); j++) {
4348                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4349                 }
4350             }
4351         }
4352     }
4353 
4354     @Test(dataProvider = "longCompareOpMaskProvider")
4355     static void UNSIGNED_GELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4356                                                 IntFunction<boolean[]> fm) {
4357         long[] a = fa.apply(SPECIES.length());
4358         long[] b = fb.apply(SPECIES.length());
4359         boolean[] mask = fm.apply(SPECIES.length());
4360 
4361         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4362 
4363         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4364             for (int i = 0; i < a.length; i += SPECIES.length()) {
4365                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4366                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4367                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4368 
4369                 // Check results as part of computation.
4370                 for (int j = 0; j < SPECIES.length(); j++) {
4371                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4372                 }
4373             }
4374         }
4375     }
4376 
4377     @Test(dataProvider = "longCompareOpProvider")
4378     static void LTLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4379         long[] a = fa.apply(SPECIES.length());
4380         long[] b = fb.apply(SPECIES.length());
4381 
4382         for (int i = 0; i < a.length; i += SPECIES.length()) {
4383             LongVector av = LongVector.fromArray(SPECIES, a, i);
4384             VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i]);
4385 
4386             // Check results as part of computation.
4387             for (int j = 0; j < SPECIES.length(); j++) {
4388                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4389             }
4390         }
4391     }
4392 
4393     @Test(dataProvider = "longCompareOpMaskProvider")
4394     static void LTLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,
4395                                 IntFunction<long[]> fb, IntFunction<boolean[]> fm) {
4396         long[] a = fa.apply(SPECIES.length());
4397         long[] b = fb.apply(SPECIES.length());
4398         boolean[] mask = fm.apply(SPECIES.length());
4399 
4400         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4401 
4402         for (int i = 0; i < a.length; i += SPECIES.length()) {
4403             LongVector av = LongVector.fromArray(SPECIES, a, i);
4404             VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i], vmask);
4405 
4406             // Check results as part of computation.
4407             for (int j = 0; j < SPECIES.length(); j++) {
4408                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4409             }
4410         }
4411     }
4412 
4413 
4414     @Test(dataProvider = "longCompareOpProvider")
4415     static void EQLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4416         long[] a = fa.apply(SPECIES.length());
4417         long[] b = fb.apply(SPECIES.length());
4418 
4419         for (int i = 0; i < a.length; i += SPECIES.length()) {
4420             LongVector av = LongVector.fromArray(SPECIES, a, i);
4421             VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i]);
4422 
4423             // Check results as part of computation.
4424             for (int j = 0; j < SPECIES.length(); j++) {
4425                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4426             }
4427         }
4428     }
4429 
4430     @Test(dataProvider = "longCompareOpMaskProvider")
4431     static void EQLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,
4432                                 IntFunction<long[]> fb, IntFunction<boolean[]> fm) {
4433         long[] a = fa.apply(SPECIES.length());
4434         long[] b = fb.apply(SPECIES.length());
4435         boolean[] mask = fm.apply(SPECIES.length());
4436 
4437         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4438 
4439         for (int i = 0; i < a.length; i += SPECIES.length()) {
4440             LongVector av = LongVector.fromArray(SPECIES, a, i);
4441             VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4442 
4443             // Check results as part of computation.
4444             for (int j = 0; j < SPECIES.length(); j++) {
4445                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4446             }
4447         }
4448     }
4449 
4450 
4451     static long blend(long a, long b, boolean mask) {
4452         return mask ? b : a;
4453     }
4454 
4455     @Test(dataProvider = "longBinaryOpMaskProvider")
4456     static void blendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
4457                                           IntFunction<boolean[]> fm) {
4458         long[] a = fa.apply(SPECIES.length());
4459         long[] b = fb.apply(SPECIES.length());
4460         long[] r = fr.apply(SPECIES.length());
4461         boolean[] mask = fm.apply(SPECIES.length());
4462         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4463 
4464         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4465             for (int i = 0; i < a.length; i += SPECIES.length()) {
4466                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4467                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4468                 av.blend(bv, vmask).intoArray(r, i);
4469             }
4470         }
4471 
4472         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::blend);
4473     }
4474 
4475     @Test(dataProvider = "longUnaryOpShuffleProvider")
4476     static void RearrangeLongMaxVectorTests(IntFunction<long[]> fa,
4477                                            BiFunction<Integer,Integer,int[]> fs) {
4478         long[] a = fa.apply(SPECIES.length());
4479         int[] order = fs.apply(a.length, SPECIES.length());
4480         long[] r = fr.apply(SPECIES.length());
4481 
4482         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4483             for (int i = 0; i < a.length; i += SPECIES.length()) {
4484                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4485                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
4486             }
4487         }
4488 
4489         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4490     }
4491 
4492     @Test(dataProvider = "longUnaryOpShuffleMaskProvider")
4493     static void RearrangeLongMaxVectorTestsMaskedSmokeTest(IntFunction<long[]> fa,
4494                                                           BiFunction<Integer,Integer,int[]> fs,
4495                                                           IntFunction<boolean[]> fm) {
4496         long[] a = fa.apply(SPECIES.length());
4497         int[] order = fs.apply(a.length, SPECIES.length());
4498         long[] r = fr.apply(SPECIES.length());
4499         boolean[] mask = fm.apply(SPECIES.length());
4500         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4501 
4502         for (int i = 0; i < a.length; i += SPECIES.length()) {
4503             LongVector av = LongVector.fromArray(SPECIES, a, i);
4504             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4505         }
4506 
4507         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4508     }
4509 
4510     @Test(dataProvider = "longUnaryOpMaskProvider")
4511     static void compressLongMaxVectorTests(IntFunction<long[]> fa,
4512                                                 IntFunction<boolean[]> fm) {
4513         long[] a = fa.apply(SPECIES.length());
4514         long[] r = fr.apply(SPECIES.length());
4515         boolean[] mask = fm.apply(SPECIES.length());
4516         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4517 
4518         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4519             for (int i = 0; i < a.length; i += SPECIES.length()) {
4520                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4521                 av.compress(vmask).intoArray(r, i);
4522             }
4523         }
4524 
4525         assertcompressArraysEquals(r, a, mask, SPECIES.length());
4526     }
4527 
4528     @Test(dataProvider = "longUnaryOpMaskProvider")
4529     static void expandLongMaxVectorTests(IntFunction<long[]> fa,
4530                                                 IntFunction<boolean[]> fm) {
4531         long[] a = fa.apply(SPECIES.length());
4532         long[] r = fr.apply(SPECIES.length());
4533         boolean[] mask = fm.apply(SPECIES.length());
4534         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4535 
4536         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4537             for (int i = 0; i < a.length; i += SPECIES.length()) {
4538                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4539                 av.expand(vmask).intoArray(r, i);
4540             }
4541         }
4542 
4543         assertexpandArraysEquals(r, a, mask, SPECIES.length());
4544     }
4545 
4546     @Test(dataProvider = "longUnaryOpProvider")
4547     static void getLongMaxVectorTests(IntFunction<long[]> fa) {
4548         long[] a = fa.apply(SPECIES.length());
4549         long[] r = fr.apply(SPECIES.length());
4550 
4551         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4552             for (int i = 0; i < a.length; i += SPECIES.length()) {
4553                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4554                 int num_lanes = SPECIES.length();
4555                 // Manually unroll because full unroll happens after intrinsification.
4556                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4557                 if (num_lanes == 1) {
4558                     r[i]=av.lane(0);
4559                 } else if (num_lanes == 2) {
4560                     r[i]=av.lane(0);
4561                     r[i+1]=av.lane(1);
4562                 } else if (num_lanes == 4) {
4563                     r[i]=av.lane(0);
4564                     r[i+1]=av.lane(1);
4565                     r[i+2]=av.lane(2);
4566                     r[i+3]=av.lane(3);
4567                 } else if (num_lanes == 8) {
4568                     r[i]=av.lane(0);
4569                     r[i+1]=av.lane(1);
4570                     r[i+2]=av.lane(2);
4571                     r[i+3]=av.lane(3);
4572                     r[i+4]=av.lane(4);
4573                     r[i+5]=av.lane(5);
4574                     r[i+6]=av.lane(6);
4575                     r[i+7]=av.lane(7);
4576                 } else if (num_lanes == 16) {
4577                     r[i]=av.lane(0);
4578                     r[i+1]=av.lane(1);
4579                     r[i+2]=av.lane(2);
4580                     r[i+3]=av.lane(3);
4581                     r[i+4]=av.lane(4);
4582                     r[i+5]=av.lane(5);
4583                     r[i+6]=av.lane(6);
4584                     r[i+7]=av.lane(7);
4585                     r[i+8]=av.lane(8);
4586                     r[i+9]=av.lane(9);
4587                     r[i+10]=av.lane(10);
4588                     r[i+11]=av.lane(11);
4589                     r[i+12]=av.lane(12);
4590                     r[i+13]=av.lane(13);
4591                     r[i+14]=av.lane(14);
4592                     r[i+15]=av.lane(15);
4593                 } else if (num_lanes == 32) {
4594                     r[i]=av.lane(0);
4595                     r[i+1]=av.lane(1);
4596                     r[i+2]=av.lane(2);
4597                     r[i+3]=av.lane(3);
4598                     r[i+4]=av.lane(4);
4599                     r[i+5]=av.lane(5);
4600                     r[i+6]=av.lane(6);
4601                     r[i+7]=av.lane(7);
4602                     r[i+8]=av.lane(8);
4603                     r[i+9]=av.lane(9);
4604                     r[i+10]=av.lane(10);
4605                     r[i+11]=av.lane(11);
4606                     r[i+12]=av.lane(12);
4607                     r[i+13]=av.lane(13);
4608                     r[i+14]=av.lane(14);
4609                     r[i+15]=av.lane(15);
4610                     r[i+16]=av.lane(16);
4611                     r[i+17]=av.lane(17);
4612                     r[i+18]=av.lane(18);
4613                     r[i+19]=av.lane(19);
4614                     r[i+20]=av.lane(20);
4615                     r[i+21]=av.lane(21);
4616                     r[i+22]=av.lane(22);
4617                     r[i+23]=av.lane(23);
4618                     r[i+24]=av.lane(24);
4619                     r[i+25]=av.lane(25);
4620                     r[i+26]=av.lane(26);
4621                     r[i+27]=av.lane(27);
4622                     r[i+28]=av.lane(28);
4623                     r[i+29]=av.lane(29);
4624                     r[i+30]=av.lane(30);
4625                     r[i+31]=av.lane(31);
4626                 } else if (num_lanes == 64) {
4627                     r[i]=av.lane(0);
4628                     r[i+1]=av.lane(1);
4629                     r[i+2]=av.lane(2);
4630                     r[i+3]=av.lane(3);
4631                     r[i+4]=av.lane(4);
4632                     r[i+5]=av.lane(5);
4633                     r[i+6]=av.lane(6);
4634                     r[i+7]=av.lane(7);
4635                     r[i+8]=av.lane(8);
4636                     r[i+9]=av.lane(9);
4637                     r[i+10]=av.lane(10);
4638                     r[i+11]=av.lane(11);
4639                     r[i+12]=av.lane(12);
4640                     r[i+13]=av.lane(13);
4641                     r[i+14]=av.lane(14);
4642                     r[i+15]=av.lane(15);
4643                     r[i+16]=av.lane(16);
4644                     r[i+17]=av.lane(17);
4645                     r[i+18]=av.lane(18);
4646                     r[i+19]=av.lane(19);
4647                     r[i+20]=av.lane(20);
4648                     r[i+21]=av.lane(21);
4649                     r[i+22]=av.lane(22);
4650                     r[i+23]=av.lane(23);
4651                     r[i+24]=av.lane(24);
4652                     r[i+25]=av.lane(25);
4653                     r[i+26]=av.lane(26);
4654                     r[i+27]=av.lane(27);
4655                     r[i+28]=av.lane(28);
4656                     r[i+29]=av.lane(29);
4657                     r[i+30]=av.lane(30);
4658                     r[i+31]=av.lane(31);
4659                     r[i+32]=av.lane(32);
4660                     r[i+33]=av.lane(33);
4661                     r[i+34]=av.lane(34);
4662                     r[i+35]=av.lane(35);
4663                     r[i+36]=av.lane(36);
4664                     r[i+37]=av.lane(37);
4665                     r[i+38]=av.lane(38);
4666                     r[i+39]=av.lane(39);
4667                     r[i+40]=av.lane(40);
4668                     r[i+41]=av.lane(41);
4669                     r[i+42]=av.lane(42);
4670                     r[i+43]=av.lane(43);
4671                     r[i+44]=av.lane(44);
4672                     r[i+45]=av.lane(45);
4673                     r[i+46]=av.lane(46);
4674                     r[i+47]=av.lane(47);
4675                     r[i+48]=av.lane(48);
4676                     r[i+49]=av.lane(49);
4677                     r[i+50]=av.lane(50);
4678                     r[i+51]=av.lane(51);
4679                     r[i+52]=av.lane(52);
4680                     r[i+53]=av.lane(53);
4681                     r[i+54]=av.lane(54);
4682                     r[i+55]=av.lane(55);
4683                     r[i+56]=av.lane(56);
4684                     r[i+57]=av.lane(57);
4685                     r[i+58]=av.lane(58);
4686                     r[i+59]=av.lane(59);
4687                     r[i+60]=av.lane(60);
4688                     r[i+61]=av.lane(61);
4689                     r[i+62]=av.lane(62);
4690                     r[i+63]=av.lane(63);
4691                 } else {
4692                     for (int j = 0; j < SPECIES.length(); j++) {
4693                         r[i+j]=av.lane(j);
4694                     }
4695                 }
4696             }
4697         }
4698 
4699         assertArraysEquals(r, a, LongMaxVectorTests::get);
4700     }
4701 
4702     @Test(dataProvider = "longUnaryOpProvider")
4703     static void BroadcastLongMaxVectorTests(IntFunction<long[]> fa) {
4704         long[] a = fa.apply(SPECIES.length());
4705         long[] r = new long[a.length];
4706 
4707         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4708             for (int i = 0; i < a.length; i += SPECIES.length()) {
4709                 LongVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4710             }
4711         }
4712 
4713         assertBroadcastArraysEquals(r, a);
4714     }
4715 
4716     @Test(dataProvider = "longUnaryOpProvider")
4717     static void ZeroLongMaxVectorTests(IntFunction<long[]> fa) {
4718         long[] a = fa.apply(SPECIES.length());
4719         long[] r = new long[a.length];
4720 
4721         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4722             for (int i = 0; i < a.length; i += SPECIES.length()) {
4723                 LongVector.zero(SPECIES).intoArray(a, i);
4724             }
4725         }
4726 
4727         Assert.assertEquals(a, r);
4728     }
4729 
4730     static long[] sliceUnary(long[] a, int origin, int idx) {
4731         long[] res = new long[SPECIES.length()];
4732         for (int i = 0; i < SPECIES.length(); i++){
4733             if(i+origin < SPECIES.length())
4734                 res[i] = a[idx+i+origin];
4735             else
4736                 res[i] = (long)0;
4737         }
4738         return res;
4739     }
4740 
4741     @Test(dataProvider = "longUnaryOpProvider")
4742     static void sliceUnaryLongMaxVectorTests(IntFunction<long[]> fa) {
4743         long[] a = fa.apply(SPECIES.length());
4744         long[] r = new long[a.length];
4745         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4746         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4747             for (int i = 0; i < a.length; i += SPECIES.length()) {
4748                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4749                 av.slice(origin).intoArray(r, i);
4750             }
4751         }
4752 
4753         assertArraysEquals(r, a, origin, LongMaxVectorTests::sliceUnary);
4754     }
4755 
4756     static long[] sliceBinary(long[] a, long[] b, int origin, int idx) {
4757         long[] res = new long[SPECIES.length()];
4758         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4759             if(i+origin < SPECIES.length())
4760                 res[i] = a[idx+i+origin];
4761             else {
4762                 res[i] = b[idx+j];
4763                 j++;
4764             }
4765         }
4766         return res;
4767     }
4768 
4769     @Test(dataProvider = "longBinaryOpProvider")
4770     static void sliceBinaryLongMaxVectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4771         long[] a = fa.apply(SPECIES.length());
4772         long[] b = fb.apply(SPECIES.length());
4773         long[] r = new long[a.length];
4774         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4775         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4776             for (int i = 0; i < a.length; i += SPECIES.length()) {
4777                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4778                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4779                 av.slice(origin, bv).intoArray(r, i);
4780             }
4781         }
4782 
4783         assertArraysEquals(r, a, b, origin, LongMaxVectorTests::sliceBinary);
4784     }
4785 
4786     static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) {
4787         long[] res = new long[SPECIES.length()];
4788         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4789             if(i+origin < SPECIES.length())
4790                 res[i] = mask[i] ? a[idx+i+origin] : (long)0;
4791             else {
4792                 res[i] = mask[i] ? b[idx+j] : (long)0;
4793                 j++;
4794             }
4795         }
4796         return res;
4797     }
4798 
4799     @Test(dataProvider = "longBinaryOpMaskProvider")
4800     static void sliceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4801     IntFunction<boolean[]> fm) {
4802         long[] a = fa.apply(SPECIES.length());
4803         long[] b = fb.apply(SPECIES.length());
4804         boolean[] mask = fm.apply(SPECIES.length());
4805         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4806 
4807         long[] r = new long[a.length];
4808         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4809         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4810             for (int i = 0; i < a.length; i += SPECIES.length()) {
4811                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4812                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4813                 av.slice(origin, bv, vmask).intoArray(r, i);
4814             }
4815         }
4816 
4817         assertArraysEquals(r, a, b, origin, mask, LongMaxVectorTests::slice);
4818     }
4819 
4820     static long[] unsliceUnary(long[] a, int origin, int idx) {
4821         long[] res = new long[SPECIES.length()];
4822         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4823             if(i < origin)
4824                 res[i] = (long)0;
4825             else {
4826                 res[i] = a[idx+j];
4827                 j++;
4828             }
4829         }
4830         return res;
4831     }
4832 
4833     @Test(dataProvider = "longUnaryOpProvider")
4834     static void unsliceUnaryLongMaxVectorTests(IntFunction<long[]> fa) {
4835         long[] a = fa.apply(SPECIES.length());
4836         long[] r = new long[a.length];
4837         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4838         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4839             for (int i = 0; i < a.length; i += SPECIES.length()) {
4840                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4841                 av.unslice(origin).intoArray(r, i);
4842             }
4843         }
4844 
4845         assertArraysEquals(r, a, origin, LongMaxVectorTests::unsliceUnary);
4846     }
4847 
4848     static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) {
4849         long[] res = new long[SPECIES.length()];
4850         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4851             if (part == 0) {
4852                 if (i < origin)
4853                     res[i] = b[idx+i];
4854                 else {
4855                     res[i] = a[idx+j];
4856                     j++;
4857                 }
4858             } else if (part == 1) {
4859                 if (i < origin)
4860                     res[i] = a[idx+SPECIES.length()-origin+i];
4861                 else {
4862                     res[i] = b[idx+origin+j];
4863                     j++;
4864                 }
4865             }
4866         }
4867         return res;
4868     }
4869 
4870     @Test(dataProvider = "longBinaryOpProvider")
4871     static void unsliceBinaryLongMaxVectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4872         long[] a = fa.apply(SPECIES.length());
4873         long[] b = fb.apply(SPECIES.length());
4874         long[] r = new long[a.length];
4875         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4876         int part = (new java.util.Random()).nextInt(2);
4877         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4878             for (int i = 0; i < a.length; i += SPECIES.length()) {
4879                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4880                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4881                 av.unslice(origin, bv, part).intoArray(r, i);
4882             }
4883         }
4884 
4885         assertArraysEquals(r, a, b, origin, part, LongMaxVectorTests::unsliceBinary);
4886     }
4887 
4888     static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) {
4889         long[] res = new long[SPECIES.length()];
4890         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4891             if(i+origin < SPECIES.length())
4892                 res[i] = b[idx+i+origin];
4893             else {
4894                 res[i] = b[idx+j];
4895                 j++;
4896             }
4897         }
4898         for (int i = 0; i < SPECIES.length(); i++){
4899             res[i] = mask[i] ? a[idx+i] : res[i];
4900         }
4901         long[] res1 = new long[SPECIES.length()];
4902         if (part == 0) {
4903             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4904                 if (i < origin)
4905                     res1[i] = b[idx+i];
4906                 else {
4907                    res1[i] = res[j];
4908                    j++;
4909                 }
4910             }
4911         } else if (part == 1) {
4912             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4913                 if (i < origin)
4914                     res1[i] = res[SPECIES.length()-origin+i];
4915                 else {
4916                     res1[i] = b[idx+origin+j];
4917                     j++;
4918                 }
4919             }
4920         }
4921         return res1;
4922     }
4923 
4924     @Test(dataProvider = "longBinaryOpMaskProvider")
4925     static void unsliceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4926     IntFunction<boolean[]> fm) {
4927         long[] a = fa.apply(SPECIES.length());
4928         long[] b = fb.apply(SPECIES.length());
4929         boolean[] mask = fm.apply(SPECIES.length());
4930         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4931         long[] r = new long[a.length];
4932         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4933         int part = (new java.util.Random()).nextInt(2);
4934         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4935             for (int i = 0; i < a.length; i += SPECIES.length()) {
4936                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4937                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4938                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4939             }
4940         }
4941 
4942         assertArraysEquals(r, a, b, origin, part, mask, LongMaxVectorTests::unslice);
4943     }
4944 
4945     static long BITWISE_BLEND(long a, long b, long c) {
4946         return (long)((a&~(c))|(b&c));
4947     }
4948 
4949     static long bitwiseBlend(long a, long b, long c) {
4950         return (long)((a&~(c))|(b&c));
4951     }
4952 
4953     @Test(dataProvider = "longTernaryOpProvider")
4954     static void BITWISE_BLENDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4955         long[] a = fa.apply(SPECIES.length());
4956         long[] b = fb.apply(SPECIES.length());
4957         long[] c = fc.apply(SPECIES.length());
4958         long[] r = fr.apply(SPECIES.length());
4959 
4960         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4961             for (int i = 0; i < a.length; i += SPECIES.length()) {
4962                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4963                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4964                 LongVector cv = LongVector.fromArray(SPECIES, c, i);
4965                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4966             }
4967         }
4968 
4969         assertArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4970     }
4971 
4972     @Test(dataProvider = "longTernaryOpProvider")
4973     static void bitwiseBlendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4974         long[] a = fa.apply(SPECIES.length());
4975         long[] b = fb.apply(SPECIES.length());
4976         long[] c = fc.apply(SPECIES.length());
4977         long[] r = fr.apply(SPECIES.length());
4978 
4979         for (int i = 0; i < a.length; i += SPECIES.length()) {
4980             LongVector av = LongVector.fromArray(SPECIES, a, i);
4981             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4982             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4983             av.bitwiseBlend(bv, cv).intoArray(r, i);
4984         }
4985 
4986         assertArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4987     }
4988 
4989     @Test(dataProvider = "longTernaryOpMaskProvider")
4990     static void BITWISE_BLENDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4991                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4992         long[] a = fa.apply(SPECIES.length());
4993         long[] b = fb.apply(SPECIES.length());
4994         long[] c = fc.apply(SPECIES.length());
4995         long[] r = fr.apply(SPECIES.length());
4996         boolean[] mask = fm.apply(SPECIES.length());
4997         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4998 
4999         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5000             for (int i = 0; i < a.length; i += SPECIES.length()) {
5001                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5002                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
5003                 LongVector cv = LongVector.fromArray(SPECIES, c, i);
5004                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5005             }
5006         }
5007 
5008         assertArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
5009     }
5010 
5011     @Test(dataProvider = "longTernaryOpProvider")
5012     static void BITWISE_BLENDLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
5013         long[] a = fa.apply(SPECIES.length());
5014         long[] b = fb.apply(SPECIES.length());
5015         long[] c = fc.apply(SPECIES.length());
5016         long[] r = fr.apply(SPECIES.length());
5017 
5018         for (int i = 0; i < a.length; i += SPECIES.length()) {
5019             LongVector av = LongVector.fromArray(SPECIES, a, i);
5020             LongVector bv = LongVector.fromArray(SPECIES, b, i);
5021             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5022         }
5023         assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
5024     }
5025 
5026     @Test(dataProvider = "longTernaryOpProvider")
5027     static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
5028         long[] a = fa.apply(SPECIES.length());
5029         long[] b = fb.apply(SPECIES.length());
5030         long[] c = fc.apply(SPECIES.length());
5031         long[] r = fr.apply(SPECIES.length());
5032 
5033         for (int i = 0; i < a.length; i += SPECIES.length()) {
5034             LongVector av = LongVector.fromArray(SPECIES, a, i);
5035             LongVector cv = LongVector.fromArray(SPECIES, c, i);
5036             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5037         }
5038         assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
5039     }
5040 
5041     @Test(dataProvider = "longTernaryOpProvider")
5042     static void bitwiseBlendLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
5043         long[] a = fa.apply(SPECIES.length());
5044         long[] b = fb.apply(SPECIES.length());
5045         long[] c = fc.apply(SPECIES.length());
5046         long[] r = fr.apply(SPECIES.length());
5047 
5048         for (int i = 0; i < a.length; i += SPECIES.length()) {
5049             LongVector av = LongVector.fromArray(SPECIES, a, i);
5050             LongVector bv = LongVector.fromArray(SPECIES, b, i);
5051             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5052         }
5053         assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
5054     }
5055 
5056     @Test(dataProvider = "longTernaryOpProvider")
5057     static void bitwiseBlendLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
5058         long[] a = fa.apply(SPECIES.length());
5059         long[] b = fb.apply(SPECIES.length());
5060         long[] c = fc.apply(SPECIES.length());
5061         long[] r = fr.apply(SPECIES.length());
5062 
5063         for (int i = 0; i < a.length; i += SPECIES.length()) {
5064             LongVector av = LongVector.fromArray(SPECIES, a, i);
5065             LongVector cv = LongVector.fromArray(SPECIES, c, i);
5066             av.bitwiseBlend(b[i], cv).intoArray(r, i);
5067         }
5068         assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
5069     }
5070 
5071     @Test(dataProvider = "longTernaryOpMaskProvider")
5072     static void BITWISE_BLENDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
5073                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
5074         long[] a = fa.apply(SPECIES.length());
5075         long[] b = fb.apply(SPECIES.length());
5076         long[] c = fc.apply(SPECIES.length());
5077         long[] r = fr.apply(SPECIES.length());
5078         boolean[] mask = fm.apply(SPECIES.length());
5079         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5080 
5081         for (int i = 0; i < a.length; i += SPECIES.length()) {
5082             LongVector av = LongVector.fromArray(SPECIES, a, i);
5083             LongVector bv = LongVector.fromArray(SPECIES, b, i);
5084             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5085         }
5086 
5087         assertBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
5088     }
5089 
5090     @Test(dataProvider = "longTernaryOpMaskProvider")
5091     static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
5092                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
5093         long[] a = fa.apply(SPECIES.length());
5094         long[] b = fb.apply(SPECIES.length());
5095         long[] c = fc.apply(SPECIES.length());
5096         long[] r = fr.apply(SPECIES.length());
5097         boolean[] mask = fm.apply(SPECIES.length());
5098         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5099 
5100         for (int i = 0; i < a.length; i += SPECIES.length()) {
5101             LongVector av = LongVector.fromArray(SPECIES, a, i);
5102             LongVector cv = LongVector.fromArray(SPECIES, c, i);
5103             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5104         }
5105 
5106         assertAltBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
5107     }
5108 
5109     @Test(dataProvider = "longTernaryOpProvider")
5110     static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
5111         long[] a = fa.apply(SPECIES.length());
5112         long[] b = fb.apply(SPECIES.length());
5113         long[] c = fc.apply(SPECIES.length());
5114         long[] r = fr.apply(SPECIES.length());
5115 
5116         for (int i = 0; i < a.length; i += SPECIES.length()) {
5117             LongVector av = LongVector.fromArray(SPECIES, a, i);
5118             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5119         }
5120 
5121         assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
5122     }
5123 
5124     @Test(dataProvider = "longTernaryOpProvider")
5125     static void bitwiseBlendLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
5126         long[] a = fa.apply(SPECIES.length());
5127         long[] b = fb.apply(SPECIES.length());
5128         long[] c = fc.apply(SPECIES.length());
5129         long[] r = fr.apply(SPECIES.length());
5130 
5131         for (int i = 0; i < a.length; i += SPECIES.length()) {
5132             LongVector av = LongVector.fromArray(SPECIES, a, i);
5133             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5134         }
5135 
5136         assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
5137     }
5138 
5139     @Test(dataProvider = "longTernaryOpMaskProvider")
5140     static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
5141                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
5142         long[] a = fa.apply(SPECIES.length());
5143         long[] b = fb.apply(SPECIES.length());
5144         long[] c = fc.apply(SPECIES.length());
5145         long[] r = fr.apply(SPECIES.length());
5146         boolean[] mask = fm.apply(SPECIES.length());
5147         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5148 
5149         for (int i = 0; i < a.length; i += SPECIES.length()) {
5150             LongVector av = LongVector.fromArray(SPECIES, a, i);
5151             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5152         }
5153 
5154         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
5155     }
5156 
5157     static long NEG(long a) {
5158         return (long)(-((long)a));
5159     }
5160 
5161     static long neg(long a) {
5162         return (long)(-((long)a));
5163     }
5164 
5165     @Test(dataProvider = "longUnaryOpProvider")
5166     static void NEGLongMaxVectorTests(IntFunction<long[]> fa) {
5167         long[] a = fa.apply(SPECIES.length());
5168         long[] r = fr.apply(SPECIES.length());
5169 
5170         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5171             for (int i = 0; i < a.length; i += SPECIES.length()) {
5172                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5173                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
5174             }
5175         }
5176 
5177         assertArraysEquals(r, a, LongMaxVectorTests::NEG);
5178     }
5179 
5180     @Test(dataProvider = "longUnaryOpProvider")
5181     static void negLongMaxVectorTests(IntFunction<long[]> fa) {
5182         long[] a = fa.apply(SPECIES.length());
5183         long[] r = fr.apply(SPECIES.length());
5184 
5185         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5186             for (int i = 0; i < a.length; i += SPECIES.length()) {
5187                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5188                 av.neg().intoArray(r, i);
5189             }
5190         }
5191 
5192         assertArraysEquals(r, a, LongMaxVectorTests::neg);
5193     }
5194 
5195     @Test(dataProvider = "longUnaryOpMaskProvider")
5196     static void NEGMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5197                                                 IntFunction<boolean[]> fm) {
5198         long[] a = fa.apply(SPECIES.length());
5199         long[] r = fr.apply(SPECIES.length());
5200         boolean[] mask = fm.apply(SPECIES.length());
5201         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5202 
5203         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5204             for (int i = 0; i < a.length; i += SPECIES.length()) {
5205                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5206                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
5207             }
5208         }
5209 
5210         assertArraysEquals(r, a, mask, LongMaxVectorTests::NEG);
5211     }
5212 
5213     static long ABS(long a) {
5214         return (long)(Math.abs((long)a));
5215     }
5216 
5217     static long abs(long a) {
5218         return (long)(Math.abs((long)a));
5219     }
5220 
5221     @Test(dataProvider = "longUnaryOpProvider")
5222     static void ABSLongMaxVectorTests(IntFunction<long[]> fa) {
5223         long[] a = fa.apply(SPECIES.length());
5224         long[] r = fr.apply(SPECIES.length());
5225 
5226         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5227             for (int i = 0; i < a.length; i += SPECIES.length()) {
5228                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5229                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
5230             }
5231         }
5232 
5233         assertArraysEquals(r, a, LongMaxVectorTests::ABS);
5234     }
5235 
5236     @Test(dataProvider = "longUnaryOpProvider")
5237     static void absLongMaxVectorTests(IntFunction<long[]> fa) {
5238         long[] a = fa.apply(SPECIES.length());
5239         long[] r = fr.apply(SPECIES.length());
5240 
5241         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5242             for (int i = 0; i < a.length; i += SPECIES.length()) {
5243                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5244                 av.abs().intoArray(r, i);
5245             }
5246         }
5247 
5248         assertArraysEquals(r, a, LongMaxVectorTests::abs);
5249     }
5250 
5251     @Test(dataProvider = "longUnaryOpMaskProvider")
5252     static void ABSMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5253                                                 IntFunction<boolean[]> fm) {
5254         long[] a = fa.apply(SPECIES.length());
5255         long[] r = fr.apply(SPECIES.length());
5256         boolean[] mask = fm.apply(SPECIES.length());
5257         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5258 
5259         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5260             for (int i = 0; i < a.length; i += SPECIES.length()) {
5261                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5262                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
5263             }
5264         }
5265 
5266         assertArraysEquals(r, a, mask, LongMaxVectorTests::ABS);
5267     }
5268 
5269     static long NOT(long a) {
5270         return (long)(~((long)a));
5271     }
5272 
5273     static long not(long a) {
5274         return (long)(~((long)a));
5275     }
5276 
5277     @Test(dataProvider = "longUnaryOpProvider")
5278     static void NOTLongMaxVectorTests(IntFunction<long[]> fa) {
5279         long[] a = fa.apply(SPECIES.length());
5280         long[] r = fr.apply(SPECIES.length());
5281 
5282         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5283             for (int i = 0; i < a.length; i += SPECIES.length()) {
5284                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5285                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5286             }
5287         }
5288 
5289         assertArraysEquals(r, a, LongMaxVectorTests::NOT);
5290     }
5291 
5292     @Test(dataProvider = "longUnaryOpProvider")
5293     static void notLongMaxVectorTests(IntFunction<long[]> fa) {
5294         long[] a = fa.apply(SPECIES.length());
5295         long[] r = fr.apply(SPECIES.length());
5296 
5297         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5298             for (int i = 0; i < a.length; i += SPECIES.length()) {
5299                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5300                 av.not().intoArray(r, i);
5301             }
5302         }
5303 
5304         assertArraysEquals(r, a, LongMaxVectorTests::not);
5305     }
5306 
5307     @Test(dataProvider = "longUnaryOpMaskProvider")
5308     static void NOTMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5309                                                 IntFunction<boolean[]> fm) {
5310         long[] a = fa.apply(SPECIES.length());
5311         long[] r = fr.apply(SPECIES.length());
5312         boolean[] mask = fm.apply(SPECIES.length());
5313         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5314 
5315         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5316             for (int i = 0; i < a.length; i += SPECIES.length()) {
5317                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5318                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5319             }
5320         }
5321 
5322         assertArraysEquals(r, a, mask, LongMaxVectorTests::NOT);
5323     }
5324 
5325     static long ZOMO(long a) {
5326         return (long)((a==0?0:-1));
5327     }
5328 
5329     @Test(dataProvider = "longUnaryOpProvider")
5330     static void ZOMOLongMaxVectorTests(IntFunction<long[]> fa) {
5331         long[] a = fa.apply(SPECIES.length());
5332         long[] r = fr.apply(SPECIES.length());
5333 
5334         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5335             for (int i = 0; i < a.length; i += SPECIES.length()) {
5336                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5337                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5338             }
5339         }
5340 
5341         assertArraysEquals(r, a, LongMaxVectorTests::ZOMO);
5342     }
5343 
5344     @Test(dataProvider = "longUnaryOpMaskProvider")
5345     static void ZOMOMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5346                                                 IntFunction<boolean[]> fm) {
5347         long[] a = fa.apply(SPECIES.length());
5348         long[] r = fr.apply(SPECIES.length());
5349         boolean[] mask = fm.apply(SPECIES.length());
5350         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5351 
5352         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5353             for (int i = 0; i < a.length; i += SPECIES.length()) {
5354                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5355                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5356             }
5357         }
5358 
5359         assertArraysEquals(r, a, mask, LongMaxVectorTests::ZOMO);
5360     }
5361 
5362     static long BIT_COUNT(long a) {
5363         return (long)(Long.bitCount(a));
5364     }
5365 
5366     @Test(dataProvider = "longUnaryOpProvider")
5367     static void BIT_COUNTLongMaxVectorTests(IntFunction<long[]> fa) {
5368         long[] a = fa.apply(SPECIES.length());
5369         long[] r = fr.apply(SPECIES.length());
5370 
5371         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5372             for (int i = 0; i < a.length; i += SPECIES.length()) {
5373                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5374                 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
5375             }
5376         }
5377 
5378         assertArraysEquals(r, a, LongMaxVectorTests::BIT_COUNT);
5379     }
5380 
5381     @Test(dataProvider = "longUnaryOpMaskProvider")
5382     static void BIT_COUNTMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5383                                                 IntFunction<boolean[]> fm) {
5384         long[] a = fa.apply(SPECIES.length());
5385         long[] r = fr.apply(SPECIES.length());
5386         boolean[] mask = fm.apply(SPECIES.length());
5387         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5388 
5389         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5390             for (int i = 0; i < a.length; i += SPECIES.length()) {
5391                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5392                 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
5393             }
5394         }
5395 
5396         assertArraysEquals(r, a, mask, LongMaxVectorTests::BIT_COUNT);
5397     }
5398 
5399     static long TRAILING_ZEROS_COUNT(long a) {
5400         return (long)(TRAILING_ZEROS_COUNT_scalar(a));
5401     }
5402 
5403     @Test(dataProvider = "longUnaryOpProvider")
5404     static void TRAILING_ZEROS_COUNTLongMaxVectorTests(IntFunction<long[]> fa) {
5405         long[] a = fa.apply(SPECIES.length());
5406         long[] r = fr.apply(SPECIES.length());
5407 
5408         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5409             for (int i = 0; i < a.length; i += SPECIES.length()) {
5410                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5411                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
5412             }
5413         }
5414 
5415         assertArraysEquals(r, a, LongMaxVectorTests::TRAILING_ZEROS_COUNT);
5416     }
5417 
5418     @Test(dataProvider = "longUnaryOpMaskProvider")
5419     static void TRAILING_ZEROS_COUNTMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5420                                                 IntFunction<boolean[]> fm) {
5421         long[] a = fa.apply(SPECIES.length());
5422         long[] r = fr.apply(SPECIES.length());
5423         boolean[] mask = fm.apply(SPECIES.length());
5424         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5425 
5426         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5427             for (int i = 0; i < a.length; i += SPECIES.length()) {
5428                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5429                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
5430             }
5431         }
5432 
5433         assertArraysEquals(r, a, mask, LongMaxVectorTests::TRAILING_ZEROS_COUNT);
5434     }
5435 
5436     static long LEADING_ZEROS_COUNT(long a) {
5437         return (long)(LEADING_ZEROS_COUNT_scalar(a));
5438     }
5439 
5440     @Test(dataProvider = "longUnaryOpProvider")
5441     static void LEADING_ZEROS_COUNTLongMaxVectorTests(IntFunction<long[]> fa) {
5442         long[] a = fa.apply(SPECIES.length());
5443         long[] r = fr.apply(SPECIES.length());
5444 
5445         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5446             for (int i = 0; i < a.length; i += SPECIES.length()) {
5447                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5448                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
5449             }
5450         }
5451 
5452         assertArraysEquals(r, a, LongMaxVectorTests::LEADING_ZEROS_COUNT);
5453     }
5454 
5455     @Test(dataProvider = "longUnaryOpMaskProvider")
5456     static void LEADING_ZEROS_COUNTMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5457                                                 IntFunction<boolean[]> fm) {
5458         long[] a = fa.apply(SPECIES.length());
5459         long[] r = fr.apply(SPECIES.length());
5460         boolean[] mask = fm.apply(SPECIES.length());
5461         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5462 
5463         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5464             for (int i = 0; i < a.length; i += SPECIES.length()) {
5465                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5466                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
5467             }
5468         }
5469 
5470         assertArraysEquals(r, a, mask, LongMaxVectorTests::LEADING_ZEROS_COUNT);
5471     }
5472 
5473     static long REVERSE(long a) {
5474         return (long)(REVERSE_scalar(a));
5475     }
5476 
5477     @Test(dataProvider = "longUnaryOpProvider")
5478     static void REVERSELongMaxVectorTests(IntFunction<long[]> fa) {
5479         long[] a = fa.apply(SPECIES.length());
5480         long[] r = fr.apply(SPECIES.length());
5481 
5482         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5483             for (int i = 0; i < a.length; i += SPECIES.length()) {
5484                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5485                 av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
5486             }
5487         }
5488 
5489         assertArraysEquals(r, a, LongMaxVectorTests::REVERSE);
5490     }
5491 
5492     @Test(dataProvider = "longUnaryOpMaskProvider")
5493     static void REVERSEMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5494                                                 IntFunction<boolean[]> fm) {
5495         long[] a = fa.apply(SPECIES.length());
5496         long[] r = fr.apply(SPECIES.length());
5497         boolean[] mask = fm.apply(SPECIES.length());
5498         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5499 
5500         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5501             for (int i = 0; i < a.length; i += SPECIES.length()) {
5502                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5503                 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
5504             }
5505         }
5506 
5507         assertArraysEquals(r, a, mask, LongMaxVectorTests::REVERSE);
5508     }
5509 
5510     static long REVERSE_BYTES(long a) {
5511         return (long)(Long.reverseBytes(a));
5512     }
5513 
5514     @Test(dataProvider = "longUnaryOpProvider")
5515     static void REVERSE_BYTESLongMaxVectorTests(IntFunction<long[]> fa) {
5516         long[] a = fa.apply(SPECIES.length());
5517         long[] r = fr.apply(SPECIES.length());
5518 
5519         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5520             for (int i = 0; i < a.length; i += SPECIES.length()) {
5521                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5522                 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
5523             }
5524         }
5525 
5526         assertArraysEquals(r, a, LongMaxVectorTests::REVERSE_BYTES);
5527     }
5528 
5529     @Test(dataProvider = "longUnaryOpMaskProvider")
5530     static void REVERSE_BYTESMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5531                                                 IntFunction<boolean[]> fm) {
5532         long[] a = fa.apply(SPECIES.length());
5533         long[] r = fr.apply(SPECIES.length());
5534         boolean[] mask = fm.apply(SPECIES.length());
5535         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5536 
5537         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5538             for (int i = 0; i < a.length; i += SPECIES.length()) {
5539                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5540                 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
5541             }
5542         }
5543 
5544         assertArraysEquals(r, a, mask, LongMaxVectorTests::REVERSE_BYTES);
5545     }
5546 
5547     @Test(dataProvider = "longCompareOpProvider")
5548     static void ltLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
5549         long[] a = fa.apply(SPECIES.length());
5550         long[] b = fb.apply(SPECIES.length());
5551 
5552         for (int i = 0; i < a.length; i += SPECIES.length()) {
5553             LongVector av = LongVector.fromArray(SPECIES, a, i);
5554             VectorMask<Long> mv = av.lt(b[i]);
5555 
5556             // Check results as part of computation.
5557             for (int j = 0; j < SPECIES.length(); j++) {
5558                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5559             }
5560         }
5561     }
5562 
5563     @Test(dataProvider = "longCompareOpProvider")
5564     static void eqLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
5565         long[] a = fa.apply(SPECIES.length());
5566         long[] b = fb.apply(SPECIES.length());
5567 
5568         for (int i = 0; i < a.length; i += SPECIES.length()) {
5569             LongVector av = LongVector.fromArray(SPECIES, a, i);
5570             VectorMask<Long> mv = av.eq(b[i]);
5571 
5572             // Check results as part of computation.
5573             for (int j = 0; j < SPECIES.length(); j++) {
5574                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
5575             }
5576         }
5577     }
5578 
5579     @Test(dataProvider = "longtoIntUnaryOpProvider")
5580     static void toIntArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5581         long[] a = fa.apply(SPECIES.length());
5582 
5583         for (int i = 0; i < a.length; i += SPECIES.length()) {
5584             LongVector av = LongVector.fromArray(SPECIES, a, i);
5585             int[] r = av.toIntArray();
5586             assertArraysEquals(r, a, i);
5587         }
5588     }
5589 
5590     @Test(dataProvider = "longUnaryOpProvider")
5591     static void toLongArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5592         long[] a = fa.apply(SPECIES.length());
5593 
5594         for (int i = 0; i < a.length; i += SPECIES.length()) {
5595             LongVector av = LongVector.fromArray(SPECIES, a, i);
5596             long[] r = av.toLongArray();
5597             assertArraysEquals(r, a, i);
5598         }
5599     }
5600 
5601     @Test(dataProvider = "longUnaryOpProvider")
5602     static void toDoubleArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5603         long[] a = fa.apply(SPECIES.length());
5604 
5605         for (int i = 0; i < a.length; i += SPECIES.length()) {
5606             LongVector av = LongVector.fromArray(SPECIES, a, i);
5607             double[] r = av.toDoubleArray();
5608             assertArraysEquals(r, a, i);
5609         }
5610     }
5611 
5612     @Test(dataProvider = "longUnaryOpProvider")
5613     static void toStringLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5614         long[] a = fa.apply(SPECIES.length());
5615 
5616         for (int i = 0; i < a.length; i += SPECIES.length()) {
5617             LongVector av = LongVector.fromArray(SPECIES, a, i);
5618             String str = av.toString();
5619 
5620             long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5621             Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5622         }
5623     }
5624 
5625     @Test(dataProvider = "longUnaryOpProvider")
5626     static void hashCodeLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5627         long[] a = fa.apply(SPECIES.length());
5628 
5629         for (int i = 0; i < a.length; i += SPECIES.length()) {
5630             LongVector av = LongVector.fromArray(SPECIES, a, i);
5631             int hash = av.hashCode();
5632 
5633             long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5634             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5635             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5636         }
5637     }
5638 
5639 
5640 
5641     @Test(dataProvider = "longUnaryOpProvider")
5642     static void ADDReduceLongLongMaxVectorTests(IntFunction<long[]> fa) {
5643         long[] a = fa.apply(SPECIES.length());
5644         long[] r = fr.apply(SPECIES.length());
5645         long ra = 0;
5646 
5647         for (int i = 0; i < a.length; i += SPECIES.length()) {
5648             LongVector av = LongVector.fromArray(SPECIES, a, i);
5649             r[i] = av.reduceLanesToLong(VectorOperators.ADD);
5650         }
5651 
5652         ra = 0;
5653         for (int i = 0; i < a.length; i ++) {
5654             ra += r[i];
5655         }
5656 
5657         assertReductionArraysEquals(r, ra, a,
5658                 LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll);
5659     }
5660 
5661     @Test(dataProvider = "longUnaryOpMaskProvider")
5662     static void ADDReduceLongLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
5663         long[] a = fa.apply(SPECIES.length());
5664         long[] r = fr.apply(SPECIES.length());
5665         boolean[] mask = fm.apply(SPECIES.length());
5666         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5667         long ra = 0;
5668 
5669         for (int i = 0; i < a.length; i += SPECIES.length()) {
5670             LongVector av = LongVector.fromArray(SPECIES, a, i);
5671             r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
5672         }
5673 
5674         ra = 0;
5675         for (int i = 0; i < a.length; i ++) {
5676             ra += r[i];
5677         }
5678 
5679         assertReductionArraysEqualsMasked(r, ra, a, mask,
5680                 LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked);
5681     }
5682 
5683     @Test(dataProvider = "longUnaryOpSelectFromProvider")
5684     static void SelectFromLongMaxVectorTests(IntFunction<long[]> fa,
5685                                            BiFunction<Integer,Integer,long[]> fs) {
5686         long[] a = fa.apply(SPECIES.length());
5687         long[] order = fs.apply(a.length, SPECIES.length());
5688         long[] r = fr.apply(SPECIES.length());
5689 
5690         for (int i = 0; i < a.length; i += SPECIES.length()) {
5691             LongVector av = LongVector.fromArray(SPECIES, a, i);
5692             LongVector bv = LongVector.fromArray(SPECIES, order, i);
5693             bv.selectFrom(av).intoArray(r, i);
5694         }
5695 
5696         assertSelectFromArraysEquals(r, a, order, SPECIES.length());
5697     }
5698 
5699     @Test(dataProvider = "longUnaryOpSelectFromMaskProvider")
5700     static void SelectFromLongMaxVectorTestsMaskedSmokeTest(IntFunction<long[]> fa,
5701                                                            BiFunction<Integer,Integer,long[]> fs,
5702                                                            IntFunction<boolean[]> fm) {
5703         long[] a = fa.apply(SPECIES.length());
5704         long[] order = fs.apply(a.length, SPECIES.length());
5705         long[] r = fr.apply(SPECIES.length());
5706         boolean[] mask = fm.apply(SPECIES.length());
5707         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5708 
5709         for (int i = 0; i < a.length; i += SPECIES.length()) {
5710             LongVector av = LongVector.fromArray(SPECIES, a, i);
5711             LongVector bv = LongVector.fromArray(SPECIES, order, i);
5712             bv.selectFrom(av, vmask).intoArray(r, i);
5713         }
5714 
5715         assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
5716     }
5717 
5718     @Test(dataProvider = "shuffleProvider")
5719     static void shuffleMiscellaneousLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5720         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5721 
5722         for (int i = 0; i < a.length; i += SPECIES.length()) {
5723             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5724             int hash = shuffle.hashCode();
5725             int length = shuffle.length();
5726 
5727             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5728             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5729             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5730             Assert.assertEquals(length, SPECIES.length());
5731         }
5732     }
5733 
5734     @Test(dataProvider = "shuffleProvider")
5735     static void shuffleToStringLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5736         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5737 
5738         for (int i = 0; i < a.length; i += SPECIES.length()) {
5739             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5740             String str = shuffle.toString();
5741 
5742             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5743             Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
5744                 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5745         }
5746     }
5747 
5748     @Test(dataProvider = "shuffleCompareOpProvider")
5749     static void shuffleEqualsLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
5750         int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5751         int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5752 
5753         for (int i = 0; i < a.length; i += SPECIES.length()) {
5754             var av = VectorShuffle.fromArray(SPECIES, a, i);
5755             var bv = VectorShuffle.fromArray(SPECIES, b, i);
5756             boolean eq = av.equals(bv);
5757             int to = i + SPECIES.length();
5758             Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
5759         }
5760     }
5761 
5762     @Test(dataProvider = "maskCompareOpProvider")
5763     static void maskEqualsLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5764         boolean[] a = fa.apply(SPECIES.length());
5765         boolean[] b = fb.apply(SPECIES.length());
5766 
5767         for (int i = 0; i < a.length; i += SPECIES.length()) {
5768             var av = SPECIES.loadMask(a, i);
5769             var bv = SPECIES.loadMask(b, i);
5770             boolean equals = av.equals(bv);
5771             int to = i + SPECIES.length();
5772             Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
5773         }
5774     }
5775 
5776     static boolean beq(boolean a, boolean b) {
5777         return (a == b);
5778     }
5779 
5780     @Test(dataProvider = "maskCompareOpProvider")
5781     static void maskEqLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5782         boolean[] a = fa.apply(SPECIES.length());
5783         boolean[] b = fb.apply(SPECIES.length());
5784         boolean[] r = new boolean[a.length];
5785 
5786         for (int i = 0; i < a.length; i += SPECIES.length()) {
5787             var av = SPECIES.loadMask(a, i);
5788             var bv = SPECIES.loadMask(b, i);
5789             var cv = av.eq(bv);
5790             cv.intoArray(r, i);
5791         }
5792         assertArraysEquals(r, a, b, LongMaxVectorTests::beq);
5793     }
5794 
5795     @Test(dataProvider = "maskProvider")
5796     static void maskHashCodeLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5797         boolean[] a = fa.apply(SPECIES.length());
5798 
5799         for (int i = 0; i < a.length; i += SPECIES.length()) {
5800             var vmask = SPECIES.loadMask(a, i);
5801             int hash = vmask.hashCode();
5802 
5803             boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5804             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5805             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5806         }
5807     }
5808 
5809     static int maskTrueCount(boolean[] a, int idx) {
5810         int trueCount = 0;
5811         for (int i = idx; i < idx + SPECIES.length(); i++) {
5812             trueCount += a[i] ? 1 : 0;
5813         }
5814         return trueCount;
5815     }
5816 
5817     @Test(dataProvider = "maskProvider")
5818     static void maskTrueCountLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5819         boolean[] a = fa.apply(SPECIES.length());
5820         int[] r = new int[a.length];
5821 
5822         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5823             for (int i = 0; i < a.length; i += SPECIES.length()) {
5824                 var vmask = SPECIES.loadMask(a, i);
5825                 r[i] = vmask.trueCount();
5826             }
5827         }
5828 
5829         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskTrueCount);
5830     }
5831 
5832     static int maskLastTrue(boolean[] a, int idx) {
5833         int i = idx + SPECIES.length() - 1;
5834         for (; i >= idx; i--) {
5835             if (a[i]) {
5836                 break;
5837             }
5838         }
5839         return i - idx;
5840     }
5841 
5842     @Test(dataProvider = "maskProvider")
5843     static void maskLastTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5844         boolean[] a = fa.apply(SPECIES.length());
5845         int[] r = new int[a.length];
5846 
5847         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5848             for (int i = 0; i < a.length; i += SPECIES.length()) {
5849                 var vmask = SPECIES.loadMask(a, i);
5850                 r[i] = vmask.lastTrue();
5851             }
5852         }
5853 
5854         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskLastTrue);
5855     }
5856 
5857     static int maskFirstTrue(boolean[] a, int idx) {
5858         int i = idx;
5859         for (; i < idx + SPECIES.length(); i++) {
5860             if (a[i]) {
5861                 break;
5862             }
5863         }
5864         return i - idx;
5865     }
5866 
5867     @Test(dataProvider = "maskProvider")
5868     static void maskFirstTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5869         boolean[] a = fa.apply(SPECIES.length());
5870         int[] r = new int[a.length];
5871 
5872         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5873             for (int i = 0; i < a.length; i += SPECIES.length()) {
5874                 var vmask = SPECIES.loadMask(a, i);
5875                 r[i] = vmask.firstTrue();
5876             }
5877         }
5878 
5879         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskFirstTrue);
5880     }
5881 
5882     @Test(dataProvider = "maskProvider")
5883     static void maskCompressLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5884         int trueCount = 0;
5885         boolean[] a = fa.apply(SPECIES.length());
5886 
5887         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5888             for (int i = 0; i < a.length; i += SPECIES.length()) {
5889                 var vmask = SPECIES.loadMask(a, i);
5890                 trueCount = vmask.trueCount();
5891                 var rmask = vmask.compress();
5892                 for (int j = 0; j < SPECIES.length(); j++)  {
5893                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
5894                 }
5895             }
5896         }
5897     }
5898 
5899 
5900     @DataProvider
5901     public static Object[][] offsetProvider() {
5902         return new Object[][]{
5903                 {0},
5904                 {-1},
5905                 {+1},
5906                 {+2},
5907                 {-2},
5908         };
5909     }
5910 
5911     @Test(dataProvider = "offsetProvider")
5912     static void indexInRangeLongMaxVectorTestsSmokeTest(int offset) {
5913         int limit = SPECIES.length() * BUFFER_REPS;
5914         for (int i = 0; i < limit; i += SPECIES.length()) {
5915             var actualMask = SPECIES.indexInRange(i + offset, limit);
5916             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5917             assert(actualMask.equals(expectedMask));
5918             for (int j = 0; j < SPECIES.length(); j++)  {
5919                 int index = i + j + offset;
5920                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5921             }
5922         }
5923     }
5924 
5925     @Test(dataProvider = "offsetProvider")
5926     static void indexInRangeLongLongMaxVectorTestsSmokeTest(int offset) {
5927         long limit = SPECIES.length() * BUFFER_REPS;
5928         for (long i = 0; i < limit; i += SPECIES.length()) {
5929             var actualMask = SPECIES.indexInRange(i + offset, limit);
5930             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5931             assert(actualMask.equals(expectedMask));
5932             for (int j = 0; j < SPECIES.length(); j++)  {
5933                 long index = i + j + offset;
5934                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5935             }
5936         }
5937     }
5938 
5939     @DataProvider
5940     public static Object[][] lengthProvider() {
5941         return new Object[][]{
5942                 {0},
5943                 {1},
5944                 {32},
5945                 {37},
5946                 {1024},
5947                 {1024+1},
5948                 {1024+5},
5949         };
5950     }
5951 
5952     @Test(dataProvider = "lengthProvider")
5953     static void loopBoundLongMaxVectorTestsSmokeTest(int length) {
5954         int actualLoopBound = SPECIES.loopBound(length);
5955         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5956         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5957     }
5958 
5959     @Test(dataProvider = "lengthProvider")
5960     static void loopBoundLongLongMaxVectorTestsSmokeTest(int _length) {
5961         long length = _length;
5962         long actualLoopBound = SPECIES.loopBound(length);
5963         long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5964         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5965     }
5966 
5967     @Test
5968     static void ElementSizeLongMaxVectorTestsSmokeTest() {
5969         LongVector av = LongVector.zero(SPECIES);
5970         int elsize = av.elementSize();
5971         Assert.assertEquals(elsize, Long.SIZE);
5972     }
5973 
5974     @Test
5975     static void VectorShapeLongMaxVectorTestsSmokeTest() {
5976         LongVector av = LongVector.zero(SPECIES);
5977         VectorShape vsh = av.shape();
5978         assert(vsh.equals(VectorShape.S_Max_BIT));
5979     }
5980 
5981     @Test
5982     static void ShapeWithLanesLongMaxVectorTestsSmokeTest() {
5983         LongVector av = LongVector.zero(SPECIES);
5984         VectorShape vsh = av.shape();
5985         VectorSpecies species = vsh.withLanes(long.class);
5986         assert(species.equals(SPECIES));
5987     }
5988 
5989     @Test
5990     static void ElementTypeLongMaxVectorTestsSmokeTest() {
5991         LongVector av = LongVector.zero(SPECIES);
5992         assert(av.species().elementType() == long.class);
5993     }
5994 
5995     @Test
5996     static void SpeciesElementSizeLongMaxVectorTestsSmokeTest() {
5997         LongVector av = LongVector.zero(SPECIES);
5998         assert(av.species().elementSize() == Long.SIZE);
5999     }
6000 
6001     @Test
6002     static void VectorTypeLongMaxVectorTestsSmokeTest() {
6003         LongVector av = LongVector.zero(SPECIES);
6004         assert(av.species().vectorType() == av.getClass());
6005     }
6006 
6007     @Test
6008     static void WithLanesLongMaxVectorTestsSmokeTest() {
6009         LongVector av = LongVector.zero(SPECIES);
6010         VectorSpecies species = av.species().withLanes(long.class);
6011         assert(species.equals(SPECIES));
6012     }
6013 
6014     @Test
6015     static void WithShapeLongMaxVectorTestsSmokeTest() {
6016         LongVector av = LongVector.zero(SPECIES);
6017         VectorShape vsh = av.shape();
6018         VectorSpecies species = av.species().withShape(vsh);
6019         assert(species.equals(SPECIES));
6020     }
6021 
6022     @Test
6023     static void MaskAllTrueLongMaxVectorTestsSmokeTest() {
6024         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6025           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
6026         }
6027     }
6028 }